Continuous Integration Testing (prod feature flags) #5522
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
| on: | |
| push: | |
| schedule: | |
| - cron: '1 0-12,20-23 * * 1-5' | |
| - cron: '1 * * * 0,6' | |
| name: Continuous Integration Testing (prod feature flags) | |
| jobs: | |
| changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changes: ${{ steps.filter.outputs.changes }} | |
| steps: | |
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| run-tests: | |
| - '**' | |
| - '!.github/workflows/!(test).yaml' | |
| test-serial: | |
| needs: changes | |
| if: ${{ contains(fromJSON(needs.changes.outputs.changes), 'run-tests') }} | |
| env: | |
| CYPRESS_USER_PW_SECRET: ${{ secrets.CYPRESS_USER_PW_SECRET }} | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16.11-bookworm@sha256:a2420e9555e2224583fe84d0bb3f0b967e69354ae3a0be55a9c14e251388c4eb | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: test_notification_api | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| redis: | |
| image: redis:6.2 | |
| ports: | |
| - 6380:6379 | |
| options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - name: Install libcurl | |
| run: sudo apt-get update && sudo apt-get install libssl-dev libcurl4-openssl-dev | |
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install poetry | |
| env: | |
| POETRY_VERSION: "1.7.1" | |
| run: pip install poetry==${POETRY_VERSION} poetry-plugin-sort && poetry --version | |
| - name: Install requirements | |
| run: poetry install --with test | |
| - name: Generate version file | |
| run: make generate-version-file | |
| - name: Update NOTIFY_ENVIRONMENT for pytest | |
| run: sed -i 's/NOTIFY_ENVIRONMENT=test/NOTIFY_ENVIRONMENT=production_ff/' pytest.ini | |
| - name: Run serial tests | |
| run: | | |
| poetry run py.test --disable-pytest-warnings --cov=app --cov-report=term-missing \ | |
| tests/ --junitxml=test_results_serial.xml -v --maxfail=10 -m "serial" | |
| - name: Notify Slack channel if this job fails | |
| if: ${{ failure() && github.ref == 'refs/heads/main' }} | |
| run: | | |
| json='{"text":"Scheduled CI testing failed: <https://github.com/cds-snc/notification-api/actions/runs/'${{ github.run_id }}'|GitHub actions>"}' | |
| curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.SLACK_WEBHOOK }} | |
| test-parallel: | |
| needs: changes | |
| if: ${{ contains(fromJSON(needs.changes.outputs.changes), 'run-tests') }} | |
| env: | |
| CYPRESS_USER_PW_SECRET: ${{ secrets.CYPRESS_USER_PW_SECRET }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: dao | |
| test-args: "tests/app/dao" | |
| - name: service-v2 | |
| test-args: "tests/app/service tests/app/v2" | |
| - name: clients-celery | |
| test-args: "tests/app/clients tests/app/celery" | |
| - name: rest | |
| test-args: "tests --ignore=tests/app/dao --ignore=tests/app/service --ignore=tests/app/v2 --ignore=tests/app/clients --ignore=tests/app/celery" | |
| services: | |
| postgres: | |
| image: postgres:16.11-bookworm@sha256:a2420e9555e2224583fe84d0bb3f0b967e69354ae3a0be55a9c14e251388c4eb | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: test_notification_api | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| redis: | |
| image: redis:6.2 | |
| ports: | |
| - 6380:6379 | |
| options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - name: Install libcurl | |
| run: sudo apt-get update && sudo apt-get install libssl-dev libcurl4-openssl-dev | |
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0 | |
| with: | |
| python-version: '3.12' | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install poetry | |
| env: | |
| POETRY_VERSION: "1.7.1" | |
| run: pip install poetry==${POETRY_VERSION} poetry-plugin-sort && poetry --version | |
| - name: Install requirements | |
| run: poetry install --with test | |
| - name: Generate version file | |
| run: make generate-version-file | |
| - name: Update NOTIFY_ENVIRONMENT for pytest | |
| run: sed -i 's/NOTIFY_ENVIRONMENT=test/NOTIFY_ENVIRONMENT=production_ff/' pytest.ini | |
| - name: Run parallel tests (${{ matrix.name }}) | |
| run: | | |
| poetry run py.test --disable-pytest-warnings --cov=app --cov-report=term-missing \ | |
| --junitxml=test_results_${{ matrix.name }}.xml -v --maxfail=10 \ | |
| -m "not serial" -n auto \ | |
| ${{ matrix.test-args }} | |
| - name: Notify Slack channel if this job fails | |
| if: ${{ failure() && github.ref == 'refs/heads/main' }} | |
| run: | | |
| json='{"text":"Scheduled CI testing failed: <https://github.com/cds-snc/notification-api/actions/runs/'${{ github.run_id }}'|GitHub actions>"}' | |
| curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.SLACK_WEBHOOK }} |