Skip to content

Commit acad65e

Browse files
Merge pull request #25 from OpenSourcePolitics/bump/osp_pr
Bump/osp pr
2 parents c1d8eb2 + 4110d20 commit acad65e

File tree

43 files changed

+1272
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1272
-159
lines changed

.github/workflows/build_app.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
ruby_version:
5+
description: 'Ruby Version'
6+
default: "3.1.1"
7+
type: string
8+
required: false
9+
node_version:
10+
description: 'Node version'
11+
default: '18.17.1'
12+
required: false
13+
type: string
14+
jobs:
15+
build_app:
16+
name: Build app
17+
runs-on: ubuntu-22.04
18+
if: "!startsWith(github.head_ref, 'chore/l10n')"
19+
timeout-minutes: 60
20+
env:
21+
DATABASE_USERNAME: postgres
22+
DATABASE_PASSWORD: postgres
23+
DATABASE_HOST: localhost
24+
RUBYOPT: '-W:no-deprecated'
25+
services:
26+
postgres:
27+
image: postgres:14
28+
ports: ["5432:5432"]
29+
options: >-
30+
--health-cmd pg_isready
31+
--health-interval 10s
32+
--health-timeout 5s
33+
--health-retries 5
34+
env:
35+
POSTGRES_PASSWORD: postgres
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 1
40+
- uses: ruby/setup-ruby@v1
41+
with:
42+
ruby-version: ${{ inputs.ruby_version }}
43+
bundler-cache: true
44+
- uses: actions/setup-node@v3
45+
with:
46+
node-version: ${{ inputs.node_version }}
47+
cache: 'npm'
48+
cache-dependency-path: ./package-lock.json
49+
- uses: actions/cache@v3
50+
id: app-cache
51+
with:
52+
path: ./spec/decidim_dummy_app/
53+
key: app-${{ github.sha }}
54+
restore-keys: app-${{ github.sha }}
55+
- run: bundle exec rake test_app
56+
name: Create test app
57+
shell: "bash"
58+
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
59+
name: Create the screenshots folder
60+
shell: "bash"
61+
- run: RAILS_ENV=test bundle exec rails assets:precompile
62+
name: Precompile assets
63+
working-directory: ./spec/decidim_dummy_app/
64+
shell: "bash"
65+
env:
66+
NODE_ENV: "test"

.github/workflows/ci_tests.yml

Lines changed: 30 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
name: "[CI] ExtraUserFields"
2-
on: "push"
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- release/*
7+
- "*-stable"
8+
pull_request:
9+
branches-ignore:
10+
- "chore/l10n*"
11+
paths:
12+
- "*"
13+
- ".github/**"
314

415
env:
516
CI: "true"
617
RUBY_VERSION: 3.1.1
718
NODE_VERSION: 18.17.1
819

20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
22+
cancel-in-progress: true
23+
924
jobs:
25+
build_app:
26+
uses: ./.github/workflows/build_app.yml
27+
secrets: inherit
28+
name: Build test application
29+
1030
lint:
31+
name: Lint code
1132
runs-on: ubuntu-latest
33+
timeout-minutes: 60
1234
steps:
13-
- uses: actions/checkout@v2
35+
- uses: actions/checkout@v3
1436
with:
1537
fetch-depth: 1
1638
- uses: actions/setup-node@master
@@ -24,123 +46,11 @@ jobs:
2446
name: Lint Ruby files
2547
- run: bundle exec erblint app/**/*.erb
2648
name: Lint ERB files
49+
2750
tests:
2851
name: Tests
29-
runs-on: ubuntu-latest
30-
timeout-minutes: 30
31-
services:
32-
postgres:
33-
image: postgres:11
34-
ports: ["5432:5432"]
35-
options: >-
36-
--health-cmd pg_isready
37-
--health-interval 10s
38-
--health-timeout 5s
39-
--health-retries 5
40-
env:
41-
POSTGRES_PASSWORD: postgres
42-
env:
43-
DATABASE_USERNAME: postgres
44-
DATABASE_PASSWORD: postgres
45-
DATABASE_HOST: localhost
46-
steps:
47-
- uses: rokroskar/workflow-run-cleanup-action@v0.3.0
48-
if: "github.ref != 'refs/heads/develop'"
49-
env:
50-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
51-
- uses: actions/checkout@v2.0.0
52-
with:
53-
fetch-depth: 1
54-
- uses: ruby/setup-ruby@v1
55-
with:
56-
bundler-cache: true
57-
- uses: actions/setup-node@v1
58-
with:
59-
node-version: ${{ env.NODE_VERSION }}
60-
- name: Get npm cache directory path
61-
id: npm-cache-dir-path
62-
run: echo "::set-output name=dir::$(npm get cache)-extra_user_fields"
63-
- uses: actions/cache@v2
64-
id: npm-cache
65-
with:
66-
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
67-
key: npm-${{ hashFiles('**/package-lock.json') }}
68-
restore-keys: |
69-
npm-
70-
- run: bundle exec rake test_app
71-
name: Create test app
72-
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
73-
name: Create the screenshots folder
74-
- uses: nanasess/setup-chromedriver@v2
75-
- run: RAILS_ENV=test bundle exec rails assets:precompile
76-
name: Precompile assets
77-
working-directory: ./spec/decidim_dummy_app/
78-
- run: bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb"
79-
name: RSpec
80-
- uses: codecov/codecov-action@v1
81-
- uses: actions/upload-artifact@v2
82-
if: always()
83-
with:
84-
name: screenshots
85-
path: ./spec/decidim_dummy_app/tmp/screenshots
86-
if-no-files-found: ignore
87-
system-tests:
88-
name: System tests
89-
runs-on: ubuntu-latest
90-
timeout-minutes: 30
91-
services:
92-
postgres:
93-
image: postgres:11
94-
ports: ["5432:5432"]
95-
options: >-
96-
--health-cmd pg_isready
97-
--health-interval 10s
98-
--health-timeout 5s
99-
--health-retries 5
100-
env:
101-
POSTGRES_PASSWORD: postgres
102-
env:
103-
DATABASE_USERNAME: postgres
104-
DATABASE_PASSWORD: postgres
105-
DATABASE_HOST: localhost
106-
steps:
107-
- uses: rokroskar/workflow-run-cleanup-action@v0.3.0
108-
if: "github.ref != 'refs/heads/develop'"
109-
env:
110-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
111-
- uses: actions/checkout@v2.0.0
112-
with:
113-
fetch-depth: 1
114-
- uses: ruby/setup-ruby@v1
115-
with:
116-
bundler-cache: true
117-
- uses: actions/setup-node@v1
118-
with:
119-
node-version: ${{ env.NODE_VERSION }}
120-
- name: Get npm cache directory path
121-
id: npm-cache-dir-path
122-
run: echo "::set-output name=dir::$(npm get cache)-extra_user_fields"
123-
- uses: actions/cache@v2
124-
id: npm-cache
125-
with:
126-
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
127-
key: npm-${{ hashFiles('**/package-lock.json') }}
128-
restore-keys: |
129-
npm-
130-
- run: bundle exec rake test_app
131-
name: Create test app
132-
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
133-
name: Create the screenshots folder
134-
- uses: nanasess/setup-chromedriver@v2
135-
- run: RAILS_ENV=test bundle exec rails assets:precompile
136-
name: Precompile assets
137-
working-directory: ./spec/decidim_dummy_app/
138-
- run: bundle exec rspec spec/system
139-
name: RSpec
140-
- uses: codecov/codecov-action@v1
141-
- uses: actions/upload-artifact@v2
142-
if: always()
143-
with:
144-
name: screenshots
145-
path: ./spec/decidim_dummy_app/tmp/screenshots
146-
if-no-files-found: ignore
52+
needs: build_app
53+
uses: ./.github/workflows/test_app.yml
54+
with:
55+
test_command: "bundle exec rspec --pattern './spec/**/*_spec.rb'"
56+
secrets: inherit

.github/workflows/test_app.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
ruby_version:
5+
description: 'Ruby Version'
6+
default: "3.1.1"
7+
required: false
8+
type: string
9+
test_command:
10+
description: 'The testing command to be ran'
11+
required: true
12+
type: string
13+
chrome_version:
14+
description: 'Chrome & Chromedriver version'
15+
required: false
16+
default: "126.0.6478.182"
17+
type: string
18+
19+
jobs:
20+
build_app:
21+
name: Test app
22+
runs-on: ubuntu-22.04
23+
if: "!startsWith(github.head_ref, 'chore/l10n')"
24+
timeout-minutes: 60
25+
env:
26+
DATABASE_USERNAME: postgres
27+
DATABASE_PASSWORD: postgres
28+
DATABASE_HOST: localhost
29+
RUBYOPT: '-W:no-deprecated'
30+
services:
31+
validator:
32+
image: ghcr.io/validator/validator:latest
33+
ports: ["8888:8888"]
34+
postgres:
35+
image: postgres:14
36+
ports: ["5432:5432"]
37+
options: >-
38+
--health-cmd pg_isready
39+
--health-interval 10s
40+
--health-timeout 5s
41+
--health-retries 5
42+
env:
43+
POSTGRES_PASSWORD: postgres
44+
steps:
45+
- uses: actions/checkout@v3
46+
with:
47+
fetch-depth: 1
48+
- uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: ${{ inputs.ruby_version }}
51+
bundler-cache: true
52+
- run: |
53+
sudo apt update
54+
sudo apt install libu2f-udev
55+
wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${{inputs.chrome_version}}-1_amd64.deb
56+
sudo dpkg -i /tmp/chrome.deb
57+
rm /tmp/chrome.deb
58+
- uses: nanasess/setup-chromedriver@v2
59+
name: Install Chrome version ${{inputs.chrome_version}}
60+
with:
61+
chromedriver-version: ${{inputs.chrome_version}}
62+
- uses: actions/cache@v3
63+
id: app-cache
64+
with:
65+
path: ./spec/decidim_dummy_app/
66+
key: app-${{ github.sha }}
67+
restore-keys: app-${{ github.sha }}
68+
- run: bundle exec rails db:create db:schema:load
69+
name: Install gems and create db
70+
shell: "bash"
71+
working-directory: ./spec/decidim_dummy_app/
72+
- run: |
73+
sudo Xvfb -ac $DISPLAY -screen 0 1920x1084x24 > /dev/null 2>&1 &
74+
${{ inputs.test_command }}
75+
name: RSpec
76+
working-directory: ./
77+
env:
78+
VALIDATOR_HTML_URI: http://localhost:8888/
79+
RUBY_VERSION: ${{ inputs.ruby_version }}
80+
DECIDIM_MODULE: ${{ inputs.working-directory }}
81+
DISPLAY: ":99"
82+
CI: "true"
83+
SIMPLECOV: "true"
84+
SHAKAPACKER_RUNTIME_COMPILE: "false"
85+
NODE_ENV: "test"
86+
- uses: codecov/codecov-action@v3
87+
name: Upload coverage
88+
with:
89+
name: ${{ inputs.working-directory }}
90+
flags: ${{ inputs.working-directory }}
91+
- uses: actions/upload-artifact@v3
92+
if: always()
93+
with:
94+
name: screenshots
95+
path: ./spec/decidim_dummy_app/tmp/screenshots
96+
if-no-files-found: ignore
97+
overwrite: true

Gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ gem "puma", ">= 4.3"
1515

1616
group :development, :test do
1717
gem "byebug", "~> 11.0", platform: :mri
18-
1918
gem "decidim-dev", DECIDIM_VERSION
2019
end
2120

@@ -28,3 +27,8 @@ group :development do
2827
gem "spring-watcher-listen", "~> 2.0"
2928
gem "web-console", "~> 3.5"
3029
end
30+
31+
group :test do
32+
gem "rubocop-factory_bot", "!= 2.26.0", require: false
33+
gem "rubocop-rspec_rails", "!= 2.29.0", require: false
34+
end

Gemfile.lock

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ GEM
490490
net-smtp (0.3.4)
491491
net-protocol
492492
nio4r (2.7.3)
493+
nokogiri (1.16.6-x86_64-darwin)
494+
racc (~> 1.4)
493495
nokogiri (1.16.6-x86_64-linux)
494496
racc (~> 1.4)
495497
oauth (1.1.0)
@@ -669,7 +671,7 @@ GEM
669671
parser (>= 3.3.1.0)
670672
rubocop-capybara (2.21.0)
671673
rubocop (~> 1.41)
672-
rubocop-factory_bot (2.26.0)
674+
rubocop-factory_bot (2.25.1)
673675
rubocop (~> 1.41)
674676
rubocop-faker (1.1.0)
675677
faker (>= 2.12.0)
@@ -684,7 +686,7 @@ GEM
684686
rubocop-capybara (~> 2.17)
685687
rubocop-factory_bot (~> 2.22)
686688
rubocop-rspec_rails (~> 2.28)
687-
rubocop-rspec_rails (2.29.0)
689+
rubocop-rspec_rails (2.28.3)
688690
rubocop (~> 1.40)
689691
ruby-progressbar (1.13.0)
690692
ruby-vips (2.2.1)
@@ -794,6 +796,7 @@ GEM
794796
zeitwerk (2.6.16)
795797

796798
PLATFORMS
799+
x86_64-darwin-24
797800
x86_64-linux
798801

799802
DEPENDENCIES
@@ -807,7 +810,9 @@ DEPENDENCIES
807810
letter_opener_web (~> 1.3)
808811
listen (~> 3.1)
809812
puma (>= 4.3)
813+
rubocop-factory_bot (!= 2.26.0)
810814
rubocop-faker
815+
rubocop-rspec_rails (!= 2.29.0)
811816
spring (~> 2.0)
812817
spring-watcher-listen (~> 2.0)
813818
web-console (~> 3.5)

0 commit comments

Comments
 (0)