Skip to content
Permalink
Browse files

Move test suite to GitHub Actions (#5843)

* Lint code through GitHub Actions

* Actually lint files

* Ignore ruby gems when linting JS files

* Properly cache NPM deps

* Set cache path for npm

* Run rubocop in parallel

* Don't lint ERB files in deps

* Don't make npm verbose

* Test npm caching works

* Remove npm cache

It'sa ctually not working, so it just adds useless seconds to thew
workflow

* Run tests for main folder

* Add tests for core module

* Add missing workflows

Created from a template

* Simplify generators workflow

* Automatically upload screenshots if tests fail

* Ensure path exists before uploading

* Create the screenshots path before uploading it

* Install Ruby deps from inside each module folder

This is how it works on CircleCI.

* Revert "Install Ruby deps from inside each module folder"

This reverts commit ad43682.

* Add README

* Fix screenshots uploads

They should be uploaded always...

* Improve generators workflow

* Try to fix generators workflow

* Try to install ruby deps for generators

* Install gems globally

* Increase max wait time for slow specs

* Run JS tests from comments workflow

* Split proposals workflow in three

* Install codecov

* Set needed ENV vars for Codecov uploads

* Use GitHub Action to upload coverage reports

* Send coverage for main folder

* Use custom names for the parallel proposals workflows

* Delete decidim-dev workflow

This folder doesn't have any test

* Disable Codecov comments

* Remove unused file

* Don't report to CodeClimate from CircleCI

* Revert "Don't report to CodeClimate from CircleCI"

This reverts commit 5a6a087.

* Don't change the formatter for CircleCI

* Remove CircleCI config

* Remove CircleCI build status badge

* Add codecov status badge

* Add test suite badges

* Fix badges

* Fix workflows README

* Update .github/workflows/README.md

Co-Authored-By: Oliver Valls <oliver.vh@coditramuntana.com>

* Remove CircleCI env variable

Co-authored-by: Oliver Valls <oliver.vh@coditramuntana.com>
  • Loading branch information
mrcasals and tramuntanal committed Mar 19, 2020
1 parent 54373f9 commit f6f8da9bb76c4e7d0b21fd61feed8251c73e8d9f
Showing with 1,799 additions and 601 deletions.
  1. +0 −575 .circleci/config.yml
  2. +0 −4 .circleci/install_cc_test_reporter.sh
  3. +1 −0 .eslintignore
  4. +1 −1 {.circleci → .github}/run_erblint.sh
  5. +39 −0 .github/workflows/README.md
  6. +67 −0 .github/workflows/ci_accountability.yml
  7. +67 −0 .github/workflows/ci_admin.yml
  8. +67 −0 .github/workflows/ci_api.yml
  9. +67 −0 .github/workflows/ci_assemblies.yml
  10. +67 −0 .github/workflows/ci_blogs.yml
  11. +67 −0 .github/workflows/ci_budgets.yml
  12. +75 −0 .github/workflows/ci_comments.yml
  13. +67 −0 .github/workflows/ci_conferences.yml
  14. +67 −0 .github/workflows/ci_consultations.yml
  15. +67 −0 .github/workflows/ci_core.yml
  16. +67 −0 .github/workflows/ci_debates.yml
  17. +67 −0 .github/workflows/ci_forms.yml
  18. +54 −0 .github/workflows/ci_generators.yml
  19. +67 −0 .github/workflows/ci_initiatives.yml
  20. +46 −0 .github/workflows/ci_main.yml
  21. +67 −0 .github/workflows/ci_meetings.yml
  22. +67 −0 .github/workflows/ci_pages.yml
  23. +67 −0 .github/workflows/ci_participatory_processes.yml
  24. +67 −0 .github/workflows/ci_proposals_system_admin.yml
  25. +67 −0 .github/workflows/ci_proposals_system_public.yml
  26. +67 −0 .github/workflows/ci_proposals_unit_tests.yml
  27. +67 −0 .github/workflows/ci_sortitions.yml
  28. +67 −0 .github/workflows/ci_surveys.yml
  29. +67 −0 .github/workflows/ci_system.yml
  30. +67 −0 .github/workflows/ci_verifications.yml
  31. +46 −0 .github/workflows/lint_code.yml
  32. +5 −0 .simplecov
  33. +7 −6 Gemfile.lock
  34. +33 −1 README.md
  35. +1 −0 codecov.yml
  36. +2 −1 decidim-dev/decidim-dev.gemspec
  37. +1 −1 decidim-dev/lib/decidim/dev/test/rspec_support/capybara.rb
  38. +7 −6 decidim-generators/Gemfile.lock
  39. 0 decidim-proposals/spec/system/{ → admin}/admin_edits_proposal_spec.rb
  40. 0 decidim-proposals/spec/system/{ → admin}/admin_manages_participatory_texts_spec.rb
  41. 0 decidim-proposals/spec/system/{ → admin}/admin_manages_proposal_valuators_spec.rb
  42. 0 decidim-proposals/spec/system/{ → admin}/admin_manages_proposals_spec.rb
  43. 0 decidim-proposals/spec/system/{ → admin}/valuator_manages_proposals_spec.rb
  44. +7 −6 decidim_app-design/Gemfile.lock

This file was deleted.

This file was deleted.

@@ -12,3 +12,4 @@ entry.js
*_manifest.js
coverage
decidim-dev/**/*/test/**/*.js
vendor/bundle
@@ -2,7 +2,7 @@

shopt -s globstar

bundle exec erblint **/app/{cells,views}/**/*.erb
bundle exec erblint decidim**/app/{cells,views}/**/*.erb

# Store the return code of the erblint execution
EXIT_CODE=$?
@@ -0,0 +1,39 @@
# Decidim GitHub Actions workflows

We use GitHub Actions as CI.

- `lint_code.yml`: runs the linters for Ruby, JS and ERB files.
- `ci_main.yml`: runs the tests for the main folder
- `ci_core.yml`: runs the tests for the `decidim-core` module. The remaining workflows (except noted) are based on this one.

Individual workflows with changes:

- `ci_generators.yml`: `decidim-generators` does not need to create the test_app, so this command is removed. Screenshots uploads and chromedriver setup steps are also not needed for this module and thus removed. We also customize the gems path after running `bundle install`:

```yml
# ci_generators.yml
- run: bundle install --path vendor/bundle --jobs 4 --retry 3
name: Install Ruby deps
- run: cp -R vendor/bundle decidim-generators
- run: bundle exec rake
name: RSpec
working-directory: ${{ env.DECIDIM_MODULE }}
```

- `ci_comments.yml`: Runs tests for the JS files. Tests must run from the project root folder. You'll need to install NodeJS and the JS dependencies:

```yml
- uses: actions/setup-node@master
with:
node-version: ${{ env.NODE_VERSION }}
- run: npm ci
name: Install JS deps
- run: npm run test
name: Test JS files
```

- Proposals specs are split in three workflows:

- `ci_proposals_system_admin.yml`: Runs the system specs for the admin section
- `ci_proposals_system_public.yml`: Runs the system specs for the public section
- `ci_proposals_unit_tests.yml`: Runs the unit tests
@@ -0,0 +1,67 @@
name: "[CI] Accountability"
on: [push]

env:
CI: "true"
SIMPLECOV: "true"
RUBY_VERSION: 2.5.3
DECIDIM_MODULE: decidim-accountability

jobs:
main:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
env:
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: localhost
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2
if: "github.ref != 'refs/heads/master' || github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v2.0.0
with:
fetch-depth: 1
- uses: ruby/setup-ruby@master
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Recover Ruby dependency cache
uses: actions/cache@v1
with:
path: ./vendor/bundle
key: ${{ runner.OS }}-rubydeps-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.OS }}-rubydeps-${{ env.cache-name }}-
${{ runner.OS }}-rubydeps-
${{ runner.OS }}-
- run: bundle install --path vendor/bundle --jobs 4 --retry 3
name: Install Ruby deps
- run: bundle exec rake test_app
name: Create test app
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v1.0.1
- run: bundle exec rake
name: RSpec
working-directory: ${{ env.DECIDIM_MODULE }}
- uses: codecov/codecov-action@v1
with:
file: ./coverage/coverage.xml
name: ${{ env.DECIDIM_MODULE }}
- uses: actions/upload-artifact@v2-preview
if: always()
with:
name: screenshots
path: ./spec/decidim_dummy_app/tmp/screenshots
@@ -0,0 +1,67 @@
name: "[CI] Admin"
on: [push]

env:
CI: "true"
SIMPLECOV: "true"
RUBY_VERSION: 2.5.3
DECIDIM_MODULE: decidim-admin

jobs:
main:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
env:
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: localhost
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2
if: "github.ref != 'refs/heads/master' || github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v2.0.0
with:
fetch-depth: 1
- uses: ruby/setup-ruby@master
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Recover Ruby dependency cache
uses: actions/cache@v1
with:
path: ./vendor/bundle
key: ${{ runner.OS }}-rubydeps-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.OS }}-rubydeps-${{ env.cache-name }}-
${{ runner.OS }}-rubydeps-
${{ runner.OS }}-
- run: bundle install --path vendor/bundle --jobs 4 --retry 3
name: Install Ruby deps
- run: bundle exec rake test_app
name: Create test app
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v1.0.1
- run: bundle exec rake
name: RSpec
working-directory: ${{ env.DECIDIM_MODULE }}
- uses: codecov/codecov-action@v1
with:
file: ./coverage/coverage.xml
name: ${{ env.DECIDIM_MODULE }}
- uses: actions/upload-artifact@v2-preview
if: always()
with:
name: screenshots
path: ./spec/decidim_dummy_app/tmp/screenshots
@@ -0,0 +1,67 @@
name: "[CI] Api"
on: [push]

env:
CI: "true"
SIMPLECOV: "true"
RUBY_VERSION: 2.5.3
DECIDIM_MODULE: decidim-api

jobs:
main:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
env:
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: localhost
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2
if: "github.ref != 'refs/heads/master' || github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v2.0.0
with:
fetch-depth: 1
- uses: ruby/setup-ruby@master
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Recover Ruby dependency cache
uses: actions/cache@v1
with:
path: ./vendor/bundle
key: ${{ runner.OS }}-rubydeps-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.OS }}-rubydeps-${{ env.cache-name }}-
${{ runner.OS }}-rubydeps-
${{ runner.OS }}-
- run: bundle install --path vendor/bundle --jobs 4 --retry 3
name: Install Ruby deps
- run: bundle exec rake test_app
name: Create test app
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v1.0.1
- run: bundle exec rake
name: RSpec
working-directory: ${{ env.DECIDIM_MODULE }}
- uses: codecov/codecov-action@v1
with:
file: ./coverage/coverage.xml
name: ${{ env.DECIDIM_MODULE }}
- uses: actions/upload-artifact@v2-preview
if: always()
with:
name: screenshots
path: ./spec/decidim_dummy_app/tmp/screenshots
@@ -0,0 +1,67 @@
name: "[CI] Assemblies"
on: [push]

env:
CI: "true"
SIMPLECOV: "true"
RUBY_VERSION: 2.5.3
DECIDIM_MODULE: decidim-assemblies

jobs:
main:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
env:
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: localhost
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2
if: "github.ref != 'refs/heads/master' || github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v2.0.0
with:
fetch-depth: 1
- uses: ruby/setup-ruby@master
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Recover Ruby dependency cache
uses: actions/cache@v1
with:
path: ./vendor/bundle
key: ${{ runner.OS }}-rubydeps-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.OS }}-rubydeps-${{ env.cache-name }}-
${{ runner.OS }}-rubydeps-
${{ runner.OS }}-
- run: bundle install --path vendor/bundle --jobs 4 --retry 3
name: Install Ruby deps
- run: bundle exec rake test_app
name: Create test app
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v1.0.1
- run: bundle exec rake
name: RSpec
working-directory: ${{ env.DECIDIM_MODULE }}
- uses: codecov/codecov-action@v1
with:
file: ./coverage/coverage.xml
name: ${{ env.DECIDIM_MODULE }}
- uses: actions/upload-artifact@v2-preview
if: always()
with:
name: screenshots
path: ./spec/decidim_dummy_app/tmp/screenshots
@@ -0,0 +1,67 @@
name: "[CI] Blogs"
on: [push]

env:
CI: "true"
SIMPLECOV: "true"
RUBY_VERSION: 2.5.3
DECIDIM_MODULE: decidim-blogs

jobs:
main:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
env:
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOST: localhost
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2
if: "github.ref != 'refs/heads/master' || github.ref != 'refs/heads/develop'"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v2.0.0
with:
fetch-depth: 1
- uses: ruby/setup-ruby@master
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Recover Ruby dependency cache
uses: actions/cache@v1
with:
path: ./vendor/bundle
key: ${{ runner.OS }}-rubydeps-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.OS }}-rubydeps-${{ env.cache-name }}-
${{ runner.OS }}-rubydeps-
${{ runner.OS }}-
- run: bundle install --path vendor/bundle --jobs 4 --retry 3
name: Install Ruby deps
- run: bundle exec rake test_app
name: Create test app
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v1.0.1
- run: bundle exec rake
name: RSpec
working-directory: ${{ env.DECIDIM_MODULE }}
- uses: codecov/codecov-action@v1
with:
file: ./coverage/coverage.xml
name: ${{ env.DECIDIM_MODULE }}
- uses: actions/upload-artifact@v2-preview
if: always()
with:
name: screenshots
path: ./spec/decidim_dummy_app/tmp/screenshots

0 comments on commit f6f8da9

Please sign in to comment.
You can’t perform that action at this time.