Skip to content

Commit d52551a

Browse files
authored
chore: skip unit tests for DEV environment deployments (#1130)
1 parent d27ba20 commit d52551a

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

.github/workflows/api-deployer.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ on:
6060
description: Oauth client id part of the authorization for the operations API
6161
required: true
6262
type: string
63+
SKIP_TESTS:
64+
description: The skip test parameter is useful for DEV environment deployments, not advised for QA and PROD.
65+
required: true
66+
type: boolean
6367

6468
env:
6569
python_version: '3.11'
@@ -74,6 +78,8 @@ jobs:
7478
api-build-test:
7579
uses: ./.github/workflows/build-test.yml
7680
name: Build & Test
81+
with:
82+
SKIP_TESTS: ${{ inputs.SKIP_TESTS }}
7783

7884
create-artifact-repo:
7985
runs-on: ubuntu-latest

.github/workflows/api-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
FEED_API_IMAGE_VERSION: ${{ github.sha }}
2222
GLOBAL_RATE_LIMIT_REQ_PER_MINUTE: ${{ vars.GLOBAL_RATE_LIMIT_REQ_PER_MINUTE }}
2323
TF_APPLY: true
24+
SKIP_TESTS: true
2425
VALIDATOR_ENDPOINT: https://stg-gtfs-validator-web-mbzoxaljzq-ue.a.run.app
2526
OPERATIONS_OAUTH2_CLIENT_ID_1PASSWORD: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_RETOOL_OAUTH2_CREDS/username"
2627
secrets:

.github/workflows/api-prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
FEED_API_IMAGE_VERSION: ${{ github.sha }}
1818
GLOBAL_RATE_LIMIT_REQ_PER_MINUTE: ${{ vars.GLOBAL_RATE_LIMIT_REQ_PER_MINUTE }}
1919
TF_APPLY: true
20+
SKIP_TESTS: false
2021
VALIDATOR_ENDPOINT: https://gtfs-validator-web-mbzoxaljzq-ue.a.run.app
2122
OPERATIONS_OAUTH2_CLIENT_ID_1PASSWORD: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_RETOOL_OAUTH2_CREDS/username"
2223
secrets:

.github/workflows/api-qa.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
DEPLOYER_SERVICE_ACCOUNT: ${{ vars.QA_MOBILITY_FEEDS_DEPLOYER_SERVICE_ACCOUNT }}
1717
FEED_API_IMAGE_VERSION: ${{ github.sha }}
1818
TF_APPLY: true
19+
SKIP_TESTS: false
1920
GLOBAL_RATE_LIMIT_REQ_PER_MINUTE: ${{ vars.GLOBAL_RATE_LIMIT_REQ_PER_MINUTE }}
2021
VALIDATOR_ENDPOINT: https://stg-gtfs-validator-web-mbzoxaljzq-ue.a.run.app
2122
OPERATIONS_OAUTH2_CLIENT_ID_1PASSWORD: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_RETOOL_OAUTH2_CREDS/username"

.github/workflows/build-test.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ on:
88
- "functions/**"
99
- ".github/workflows/web-*.yml"
1010
workflow_call:
11+
inputs:
12+
SKIP_TESTS:
13+
description: The skip test parameter is useful for DEV environment deployments, not advised for QA and PROD.
14+
required: false
15+
type: boolean
16+
default: false
1117

1218
env:
1319
python_version: '3.11'
@@ -22,6 +28,19 @@ jobs:
2228
- name: Checkout code
2329
uses: actions/checkout@v4
2430

31+
- name: Set whether to run tests
32+
id: set-should-run-tests
33+
run: |
34+
if [ "$GITHUB_EVENT_NAME" != "workflow_call" ] && [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ]; then
35+
echo "result=true" >> "$GITHUB_OUTPUT"
36+
elif [[ "$INPUTS_SKIP_TESTS" == "false" ]]; then
37+
echo "result=true" >> "$GITHUB_OUTPUT"
38+
else
39+
echo "result=false" >> "$GITHUB_OUTPUT"
40+
fi
41+
env:
42+
INPUTS_SKIP_TESTS: ${{ inputs.SKIP_TESTS }}
43+
2544
- name: Extract commit hash and version from git
2645
run: ./scripts/extract-hash-and-version.sh
2746

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

4362
- name: Run lint checks
63+
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
4464
shell: bash
4565
run: |
4666
scripts/lint-tests.sh
@@ -54,13 +74,6 @@ jobs:
5474
sudo apt-get update
5575
sudo apt-get install liquibase=4.25.1
5676
57-
# Uncomment the following block to test the local databases connections
58-
# - name: Test Database Connection
59-
# run: |
60-
# sudo apt-get update && sudo apt-get install -y postgresql-client
61-
# PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d MobilityDatabase -c "SELECT version();"
62-
# PGPASSWORD=postgres psql -h localhost -p 54320 -U postgres -d MobilityDatabaseTest -c "SELECT version();"
63-
6477
- name: Run Liquibase on Python functions test DB
6578
run: |
6679
export LIQUIBASE_CLASSPATH="liquibase"
@@ -85,24 +98,28 @@ jobs:
8598
scripts/api-operations-gen.sh
8699
87100
- name: Unit tests - API
101+
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
88102
shell: bash
89103
run: |
90104
scripts/api-tests.sh --folder api --html_report
91105
92106
- name: Unit tests - Python Functions
107+
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
93108
shell: bash
94109
run: |
95110
scripts/api-tests.sh --folder functions-python --html_report
96111
97112
- name: Upload coverage report
98113
uses: actions/upload-artifact@v4
114+
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
99115
with:
100116
name: coverage_report
101117
path: scripts/coverage_reports/
102118
overwrite: true
103119

104120
- name: Upload DB models
105121
uses: actions/upload-artifact@v4
122+
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
106123
with:
107124
name: database_gen
108125
path: api/src/shared/database_gen/

0 commit comments

Comments
 (0)