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
1218env :
1319 python_version : ' 3.11'
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
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
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