ci: add openapi spec drift check on PRs #3307
This file contains hidden or 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: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint_build: | |
| name: Lint & Build | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node dependencies | |
| uses: ./.github/actions/setup-node-dependencies | |
| - name: Lint | |
| run: npm run lint | |
| - name: Build | |
| run: npm run build | |
| test_unit: | |
| name: Test / Unit | |
| needs: lint_build | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node dependencies | |
| uses: ./.github/actions/setup-node-dependencies | |
| - name: Prepare env files | |
| run: | | |
| cp .env.sample .env | |
| cp .env.test.sample .env.test | |
| - name: Unit tests pass | |
| run: npm run test:unit:coverage | |
| - name: Upload coverage results to Coveralls | |
| uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| file: coverage/lcov.info | |
| format: lcov | |
| parallel: true | |
| flag-name: unit | |
| fail-on-error: false | |
| continue-on-error: true | |
| test_postgres: | |
| name: Test / Postgres | |
| needs: lint_build | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node dependencies | |
| uses: ./.github/actions/setup-node-dependencies | |
| - name: Prepare env files | |
| run: | | |
| cp .env.sample .env | |
| cp .env.test.sample .env.test | |
| - name: Tests pass | |
| run: | | |
| mkdir -p data && chmod -R 777 data && \ | |
| npm run test:coverage:ci | |
| - name: Upload coverage results to Coveralls | |
| uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| file: coverage/lcov.info | |
| format: lcov | |
| parallel: true | |
| flag-name: rest | |
| fail-on-error: false | |
| continue-on-error: true | |
| - name: Verify migration idempotency | |
| env: &migration_idempotency_env | |
| DATABASE_URL: postgresql://postgres:postgres@127.0.0.1/postgres | |
| run: | | |
| pg_dump "$DATABASE_URL" \ | |
| --exclude-table-data=storage.migrations \ | |
| --restrict-key=test \ | |
| > before.sql | |
| npm run migration:test-idempotency | |
| pg_dump "$DATABASE_URL" \ | |
| --exclude-table-data=storage.migrations \ | |
| --restrict-key=test \ | |
| > after.sql | |
| diff before.sql after.sql || (echo 'Schema mismatch!'; exit 1) | |
| test_oriole: | |
| name: Test / OrioleDB | |
| needs: lint_build | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node dependencies | |
| uses: ./.github/actions/setup-node-dependencies | |
| - name: Prepare env files | |
| run: | | |
| cp .env.sample .env | |
| cp .env.test.sample .env.test | |
| - name: Tests pass with OrioleDB | |
| run: | | |
| mkdir -p data && chmod -R 777 data && \ | |
| npm run test:oriole:ci | |
| - name: Verify OrioleDB migration idempotency | |
| env: *migration_idempotency_env | |
| run: | | |
| docker compose --project-directory . \ | |
| -f ./.docker/docker-compose-infra.yml \ | |
| -f ./.docker/docker-compose-infra-oriole-override.yml \ | |
| exec -T tenant_db \ | |
| pg_dump -U postgres -d postgres \ | |
| --exclude-table-data=storage.migrations \ | |
| --restrict-key=test \ | |
| > before-oriole.sql | |
| npm run migration:test-idempotency | |
| docker compose --project-directory . \ | |
| -f ./.docker/docker-compose-infra.yml \ | |
| -f ./.docker/docker-compose-infra-oriole-override.yml \ | |
| exec -T tenant_db \ | |
| pg_dump -U postgres -d postgres \ | |
| --exclude-table-data=storage.migrations \ | |
| --restrict-key=test \ | |
| > after-oriole.sql | |
| diff before-oriole.sql after-oriole.sql || (echo 'Oriole schema mismatch!'; exit 1) | |
| test_multigres: | |
| name: Test / Multigres | |
| needs: lint_build | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node dependencies | |
| uses: ./.github/actions/setup-node-dependencies | |
| - name: Prepare env files | |
| run: | | |
| cp .env.sample .env | |
| cp .env.test.sample .env.test | |
| - name: Pull Multigres cluster image | |
| uses: ./.github/actions/pull-multigres-cluster | |
| - name: Tests pass with Multigres | |
| run: | | |
| mkdir -p data && chmod -R 777 data && \ | |
| npm run test:multigres:ci | |
| coveralls_finish: | |
| name: Coveralls / Finalize | |
| needs: | |
| - test_unit | |
| - test_postgres | |
| if: ${{ always() }} | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Finalize parallel Coveralls build | |
| uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| parallel-finished: true | |
| fail-on-error: false | |
| continue-on-error: true |