chore: skip unit tests for DEV environment deployments #2028
Workflow file for this run
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: Build and Test | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '**.md' | |
| - "web-app/**" | |
| - "functions/**" | |
| - ".github/workflows/web-*.yml" | |
| workflow_call: | |
| inputs: | |
| SKIP_TEST: | |
| description: The skip test parameter is useful for DEV environment deployments, not advised for QA and PROD. | |
| required: false | |
| type: boolean | |
| default: false | |
| env: | |
| python_version: '3.11' | |
| java_version: '11' # needed by setup-openapi-generator.sh | |
| SKIP_TESTS: ${{ inputs.SKIP_TEST || false }} | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| permissions: write-all | |
| name: Build & Test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract commit hash and version from git | |
| run: ./scripts/extract-hash-and-version.sh | |
| - name: Set up JDK ${{ env.java_version }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ env.java_version }} | |
| distribution: 'temurin' | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.python_version }} | |
| - name: Docker Compose DB | |
| run: | | |
| docker compose --env-file ./config/.env.local up -d postgres postgres-test | |
| working-directory: ${{ github.workspace }} | |
| - name: Run lint checks | |
| shell: bash | |
| run: | | |
| scripts/lint-tests.sh | |
| - name: Install Liquibase | |
| run: | | |
| wget -O- https://repo.liquibase.com/liquibase.asc | gpg --dearmor > liquibase-keyring.gpg && \ | |
| cat liquibase-keyring.gpg | sudo tee /usr/share/keyrings/liquibase-keyring.gpg > /dev/null && \ | |
| echo 'deb [trusted=yes arch=amd64 signed-by=/usr/share/keyrings/liquibase-keyring.gpg] https://repo.liquibase.com stable main' | sudo tee /etc/apt/sources.list.d/liquibase.list | |
| sudo apt-get update | |
| sudo apt-get install liquibase=4.25.1 | |
| - name: Run Liquibase on Python functions test DB | |
| run: | | |
| export LIQUIBASE_CLASSPATH="liquibase" | |
| export LIQUIBASE_COMMAND_CHANGELOG_FILE="changelog.xml" | |
| export LIQUIBASE_COMMAND_URL=jdbc:postgresql://localhost:54320/MobilityDatabaseTest | |
| export LIQUIBASE_COMMAND_USERNAME=postgres | |
| export LIQUIBASE_COMMAND_PASSWORD=postgres | |
| liquibase update | |
| - name: Generate DB code | |
| run: | | |
| export USE_TEST_DB=true | |
| scripts/db-gen.sh | |
| - name: Generate API code | |
| run: | | |
| scripts/setup-openapi-generator.sh | |
| scripts/api-gen.sh | |
| - name: Generate Operations API code | |
| run: | | |
| scripts/api-operations-gen.sh | |
| - name: Unit tests - API | |
| if: ${{ !env.SKIP_TESTS }} | |
| shell: bash | |
| run: | | |
| scripts/api-tests.sh --folder api --html_report | |
| - name: Unit tests - Python Functions | |
| if: ${{ !env.SKIP_TESTS }} | |
| shell: bash | |
| run: | | |
| scripts/api-tests.sh --folder functions-python --html_report | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage_report | |
| path: scripts/coverage_reports/ | |
| overwrite: true | |
| - name: Upload DB models | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: database_gen | |
| path: api/src/shared/database_gen/ | |
| overwrite: true | |
| - name: Upload API generated code | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: feeds_gen | |
| path: api/src/feeds_gen/ | |
| overwrite: true | |
| - name: Upload Operations API generated code | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: feeds_operations_gen | |
| path: functions-python/operations_api/src/feeds_operations_gen/ | |
| overwrite: true |