feat(APIv2): optionally allow the selection of additional fields #4076
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
types: [opened, reopened, synchronize] | |
jobs: | |
static-analysis: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Validate commit message format | |
uses: wagoid/commitlint-github-action@v4 | |
with: | |
configFile: './.commitlint.yml' | |
- name: Setup Ruby and install gems | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Rubocop | |
run: bundle exec rubocop --parallel | |
- name: Brakeman | |
run: bundle exec brakeman | |
- name: ShellCheck | |
uses: ludeeus/[email protected] | |
with: | |
ignore: vendor | |
check_together: true | |
development-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up the environment | |
run: | | |
cp .env.example .env | |
pip3 install podman-compose | |
- name: Build using podman-compose | |
run: podman-compose build | |
- name: Build using docker-compose | |
run: docker-compose build | |
unit-tests: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_USER: insights | |
POSTGRES_DB: insights | |
POSTGRES_PASSWORD: insights | |
ports: ["5432:5432"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Ruby and install gems | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Setup database | |
env: | |
RAILS_ENV: test | |
ACG_CONFIG: ./github-ci.json | |
DATABASE_SERVICE_NAME: postgres | |
POSTGRES_SERVICE_HOST: localhost | |
POSTGRESQL_USER: insights | |
POSTGRESQL_PASSWORD: insights | |
POSTGRESQL_TEST_DATABASE: insights | |
run: | | |
bin/rails db:setup; | |
bundle exec rails db -p < db/cyndi_setup_test.sql; | |
- name: Run zeitwerk check | |
env: | |
RAILS_ENV: test | |
ACG_CONFIG: ./github-ci.json | |
DATABASE_SERVICE_NAME: postgres | |
POSTGRES_SERVICE_HOST: localhost | |
POSTGRESQL_USER: insights | |
POSTGRESQL_PASSWORD: insights | |
POSTGRESQL_TEST_DATABASE: insights | |
run: bin/rails zeitwerk:check | |
- name: Validate the OpenAPI schema | |
env: | |
RAILS_ENV: test | |
SWAGGER_DRY_RUN: false | |
ACG_CONFIG: ./github-ci.json | |
DATABASE_SERVICE_NAME: postgres | |
POSTGRES_SERVICE_HOST: localhost | |
POSTGRESQL_USER: insights | |
POSTGRESQL_PASSWORD: insights | |
POSTGRESQL_TEST_DATABASE: insights | |
run: | | |
bundle exec rails db -p < db/cyndi_setup_test.sql; | |
cp swagger/v1/openapi.json openapi.old.json | |
bin/rake rswag:specs:swaggerize | |
symbols=( '"' '[' '{' ) | |
for symbol in "${symbols[@]}"; do | |
NEW=$(cat swagger/v1/openapi.json | tr -cd "${symbol}" | wc -c) | |
OLD=$(cat openapi.old.json | tr -cd "${symbol}" | wc -c) | |
rm -rf coverage | |
if [[ "${OLD}" != "${NEW}" ]]; then | |
echo 'OpenAPI Spec needs to be updated:' | |
echo '$ bin/rake rswag:specs:swaggerize' | |
diff -s -u --minimal openapi.old.json swagger/v1/openapi.json | |
rm openapi.old.json | |
exit 1 | |
fi | |
done | |
diff <(echo '[]') <(curl -s 'https://validator.swagger.io/validator/debug' -H 'accept: application/json' -H 'Content-Type: application/json' -d @openapi.old.json | jq '.schemaValidationMessages') | |
if [[ $? != 0 ]]; then | |
rm openapi.old.json | |
exit 1 | |
fi | |
rm openapi.old.json | |
exit 0 | |
- name: Run RSpec tests | |
env: | |
HOSTNAME: rails | |
RAILS_ENV: test | |
ACG_CONFIG: ./github-ci.json | |
DATABASE_SERVICE_NAME: postgres | |
POSTGRES_SERVICE_HOST: localhost | |
POSTGRESQL_USER: insights | |
POSTGRESQL_PASSWORD: insights | |
POSTGRESQL_TEST_DATABASE: insights | |
run: bin/rake spec | |
- name: Upload code coverage from RSpec | |
uses: codecov/codecov-action@v2 | |
- name: Run minitest tests | |
env: | |
HOSTNAME: rails | |
RAILS_ENV: test | |
ACG_CONFIG: ./github-ci.json | |
DATABASE_SERVICE_NAME: postgres | |
POSTGRES_SERVICE_HOST: localhost | |
POSTGRESQL_USER: insights | |
POSTGRESQL_PASSWORD: insights | |
POSTGRESQL_TEST_DATABASE: insights | |
run: bin/rake test | |
- name: Upload code coverage from minitest | |
uses: codecov/codecov-action@v2 | |
migration-robustness: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_USER: insights | |
POSTGRES_DB: insights | |
POSTGRES_PASSWORD: insights | |
ports: ["5432:5432"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Ruby and install gems | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Setup database and run migrations | |
env: | |
RAILS_ENV: test | |
ACG_CONFIG: ./github-ci.json | |
DATABASE_SERVICE_NAME: postgres | |
POSTGRES_SERVICE_HOST: localhost | |
POSTGRESQL_USER: insights | |
POSTGRESQL_PASSWORD: insights | |
POSTGRESQL_TEST_DATABASE: insights | |
run: bin/rails db:create db:migrate | |
- name: Check if migrations altered the schema.rb | |
run: "! git diff --unified=0 -- db/schema.rb | grep ^+ActiveRecord" |