5454 description : " Support git LFS"
5555 default : false
5656 required : false
57+ test-api-endpoint :
58+ type : string
59+ description : " The base API URL for running tests against an evaluation function (staging endpoint)"
60+ required : false
61+ run-tests :
62+ type : boolean
63+ description : " Set to true to run the pre-production validation tests."
64+ required : false
65+ default : false
66+
5767 secrets :
5868 aws-key-id :
5969 description : " The AWS access key ID"
7080 gcp_credentials :
7181 description : " The JSON key for deploying to GCP"
7282 required : false
83+ DB_USER :
84+ description : " Database User for fetching test data"
85+ required : false
86+ DB_PASSWORD :
87+ description : " Database Password for fetching test data"
88+ required : false
89+ DB_HOST :
90+ description : " Database Host for fetching test data"
91+ required : false
92+ DB_PORT :
93+ description : " Database Port for fetching test data"
94+ required : false
95+ DB_NAME :
96+ description : " Database Name for fetching test data"
97+ required : false
7398
7499jobs :
75100 setup :
101+ # ... (setup job remains unchanged) ...
76102 name : Setup
77103 runs-on : ubuntu-latest
78104 outputs :
@@ -126,13 +152,10 @@ jobs:
126152 id : set-region
127153 run : |
128154 if [[ -n "${{ inputs.region }}" ]]; then
129- # Use provided region
130155 region="${{ inputs.region }}"
131156 elif [[ "${{ inputs.build-platforms }}" == "aws" ]]; then
132- # Default AWS region
133157 region="eu-west-2"
134158 else
135- # Default GCP region (or other platforms)
136159 region="europe-west2"
137160 fi
138161 echo "region=$region" >> "$GITHUB_OUTPUT"
@@ -152,9 +175,8 @@ jobs:
152175 exit 1
153176 fi
154177
155-
156178 deploy-staging :
157- # Always run staging deployment first when production is requested
179+ # ... (deploy- staging job remains unchanged) ...
158180 if : ${{inputs.environment == 'staging' || inputs.environment == 'production'}}
159181 uses : ./.github/workflows/staging_deploy.yml
160182 needs : setup
@@ -174,12 +196,35 @@ jobs:
174196 function-admin-api-key : ${{ secrets.function-admin-api-key }}
175197 build-secrets : ${{ secrets.build-secrets }}
176198 gcp_credentials : ${{ secrets.gcp_credentials }}
199+
200+ run-pre-production-tests :
201+ name : 🧪 Run Staging Validation Tests
202+ if : ${{ inputs.environment == 'production' && needs.deploy-staging.result == 'success' && inputs.run-tests }}
203+ uses : lambda-feedback/Database-Testing/.github/workflows/test_evaluation_function.yml@main
204+ needs : [setup, deploy-staging]
205+ with :
206+ endpoint : ${{ inputs.test-api-endpoint }}${{ needs.setup.outputs.evaluation_function_name }}
207+ eval_function : ${{ needs.setup.outputs.evaluation_function_name }}
208+ sql_limit : 500
209+ secrets :
210+ DB_USER : ${{ secrets.DB_USER }}
211+ DB_PASSWORD : ${{ secrets.DB_PASSWORD }}
212+ DB_HOST : ${{ secrets.DB_HOST }}
213+ DB_PORT : ${{ secrets.DB_PORT }}
214+ DB_NAME : ${{ secrets.DB_NAME }}
215+
177216
178217 deploy-production :
179- # Only run production if staging succeeded
180- if : ${{inputs.environment == 'production' && needs.deploy-staging.result == 'success'}}
218+ if : >
219+ ${{ inputs.environment == 'production' &&
220+ ( (inputs.run-tests && needs.run-pre-production-tests.result == 'success') ||
221+ (!inputs.run-tests && needs.deploy-staging.result == 'success')
222+ ) }}
181223 uses : ./.github/workflows/production_deploy.yml
182- needs : [setup, deploy-staging]
224+ needs :
225+ - setup
226+ - deploy-staging
227+ - ${{ (inputs.run-tests == true) && 'run-pre-production-tests' || '' }}
183228 with :
184229 evaluation_function_name : ${{ needs.setup.outputs.evaluation_function_name }}
185230 template-repository-name : ${{ inputs.template-repository-name }}
0 commit comments