Skip to content

chore: skip unit tests for DEV environment deployments #1130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/api-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ on:
description: Oauth client id part of the authorization for the operations API
required: true
type: string
SKIP_TESTS:
description: The skip test parameter is useful for DEV environment deployments, not advised for QA and PROD.
required: true
type: boolean

env:
python_version: '3.11'
Expand All @@ -74,6 +78,8 @@ jobs:
api-build-test:
uses: ./.github/workflows/build-test.yml
name: Build & Test
with:
SKIP_TESTS: ${{ inputs.SKIP_TESTS }}

create-artifact-repo:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/api-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
FEED_API_IMAGE_VERSION: ${{ github.sha }}
GLOBAL_RATE_LIMIT_REQ_PER_MINUTE: ${{ vars.GLOBAL_RATE_LIMIT_REQ_PER_MINUTE }}
TF_APPLY: true
SKIP_TESTS: true
VALIDATOR_ENDPOINT: https://stg-gtfs-validator-web-mbzoxaljzq-ue.a.run.app
OPERATIONS_OAUTH2_CLIENT_ID_1PASSWORD: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_RETOOL_OAUTH2_CREDS/username"
secrets:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/api-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
FEED_API_IMAGE_VERSION: ${{ github.sha }}
GLOBAL_RATE_LIMIT_REQ_PER_MINUTE: ${{ vars.GLOBAL_RATE_LIMIT_REQ_PER_MINUTE }}
TF_APPLY: true
SKIP_TESTS: false
VALIDATOR_ENDPOINT: https://gtfs-validator-web-mbzoxaljzq-ue.a.run.app
OPERATIONS_OAUTH2_CLIENT_ID_1PASSWORD: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_RETOOL_OAUTH2_CREDS/username"
secrets:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/api-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
DEPLOYER_SERVICE_ACCOUNT: ${{ vars.QA_MOBILITY_FEEDS_DEPLOYER_SERVICE_ACCOUNT }}
FEED_API_IMAGE_VERSION: ${{ github.sha }}
TF_APPLY: true
SKIP_TESTS: false
GLOBAL_RATE_LIMIT_REQ_PER_MINUTE: ${{ vars.GLOBAL_RATE_LIMIT_REQ_PER_MINUTE }}
VALIDATOR_ENDPOINT: https://stg-gtfs-validator-web-mbzoxaljzq-ue.a.run.app
OPERATIONS_OAUTH2_CLIENT_ID_1PASSWORD: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_RETOOL_OAUTH2_CREDS/username"
Expand Down
31 changes: 24 additions & 7 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:
- "functions/**"
- ".github/workflows/web-*.yml"
workflow_call:
inputs:
SKIP_TESTS:
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'
Expand All @@ -22,6 +28,19 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set whether to run tests
id: set-should-run-tests
run: |
if [ "$GITHUB_EVENT_NAME" != "workflow_call" ] && [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ]; then
echo "result=true" >> "$GITHUB_OUTPUT"
elif [[ "$INPUTS_SKIP_TESTS" == "false" ]]; then
echo "result=true" >> "$GITHUB_OUTPUT"
else
echo "result=false" >> "$GITHUB_OUTPUT"
fi
env:
INPUTS_SKIP_TESTS: ${{ inputs.SKIP_TESTS }}

- name: Extract commit hash and version from git
run: ./scripts/extract-hash-and-version.sh

Expand All @@ -41,6 +60,7 @@ jobs:
working-directory: ${{ github.workspace }}

- name: Run lint checks
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
shell: bash
run: |
scripts/lint-tests.sh
Expand All @@ -54,13 +74,6 @@ jobs:
sudo apt-get update
sudo apt-get install liquibase=4.25.1

# Uncomment the following block to test the local databases connections
# - name: Test Database Connection
# run: |
# sudo apt-get update && sudo apt-get install -y postgresql-client
# PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d MobilityDatabase -c "SELECT version();"
# PGPASSWORD=postgres psql -h localhost -p 54320 -U postgres -d MobilityDatabaseTest -c "SELECT version();"

- name: Run Liquibase on Python functions test DB
run: |
export LIQUIBASE_CLASSPATH="liquibase"
Expand All @@ -85,24 +98,28 @@ jobs:
scripts/api-operations-gen.sh

- name: Unit tests - API
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
shell: bash
run: |
scripts/api-tests.sh --folder api --html_report

- name: Unit tests - Python Functions
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
shell: bash
run: |
scripts/api-tests.sh --folder functions-python --html_report

- name: Upload coverage report
uses: actions/upload-artifact@v4
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
with:
name: coverage_report
path: scripts/coverage_reports/
overwrite: true

- name: Upload DB models
uses: actions/upload-artifact@v4
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
with:
name: database_gen
path: api/src/shared/database_gen/
Expand Down