Skip to content

Commit 5fc7fed

Browse files
[GPCAPIM-260]-[Steel Thread integration testing]-[RP]
1 parent 848f4ed commit 5fc7fed

File tree

10 files changed

+357
-458
lines changed

10 files changed

+357
-458
lines changed

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,9 @@ jobs:
8383
IDP_AWS_REPORT_UPLOAD_REGION: ${{ secrets.IDP_AWS_REPORT_UPLOAD_REGION }}
8484
IDP_AWS_REPORT_UPLOAD_ROLE_NAME: ${{ secrets.IDP_AWS_REPORT_UPLOAD_ROLE_NAME }}
8585
IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT: ${{ secrets.IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT }}
86-
test-stage: # Recommended maximum execution time is 5 minutes
87-
name: "Test stage"
88-
needs: [metadata, commit-stage]
89-
uses: ./.github/workflows/stage-2-test.yaml
90-
with:
91-
python_version: "${{ needs.metadata.outputs.python_version }}"
92-
secrets:
93-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
9486
build-stage: # Recommended maximum execution time is 3 minutes
9587
name: "Build stage"
96-
needs: [metadata, test-stage]
88+
needs: [metadata]
9789
uses: ./.github/workflows/stage-3-build.yaml
9890
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
9991
with:
@@ -104,16 +96,3 @@ jobs:
10496
python_version: "${{ needs.metadata.outputs.python_version }}"
10597
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
10698
version: "${{ needs.metadata.outputs.version }}"
107-
acceptance-stage: # Recommended maximum execution time is 10 minutes
108-
name: "Acceptance stage"
109-
needs: [metadata, build-stage]
110-
uses: ./.github/workflows/stage-4-acceptance.yaml
111-
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
112-
with:
113-
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
114-
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
115-
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
116-
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
117-
python_version: "${{ needs.metadata.outputs.python_version }}"
118-
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
119-
version: "${{ needs.metadata.outputs.version }}"

.github/workflows/preview-env.yml

Lines changed: 228 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@ jobs:
155155
ECS_CLUSTER=$(jq -r '.ecs_cluster_name.value' tf-output.json)
156156
echo "ecs_cluster=$ECS_CLUSTER" >> $GITHUB_OUTPUT
157157
158+
- name: Compute preview host
159+
id: set-host
160+
if: github.event.action != 'closed'
161+
run: |
162+
PREVIEW_URL='${{ steps.tf-output.outputs.preview_url }}'
163+
if [ -z "$PREVIEW_URL" ] || [ "$PREVIEW_URL" = "null" ]; then
164+
echo "host=missing" >> "$GITHUB_OUTPUT"
165+
exit 0
166+
fi
167+
HOST=$(printf '%s' "$PREVIEW_URL" | sed -E 's#^https?://##' | sed -E 's#/.*$##')
168+
echo "host=${HOST}" >> "$GITHUB_OUTPUT"
169+
158170
- name: Get proxygen machine user details
159171
id: proxygen-machine-user
160172
uses: aws-actions/aws-secretsmanager-get-secrets@a9a7eb4e2f2871d30dc5b892576fde60a2ecc802
@@ -234,6 +246,14 @@ jobs:
234246
/cds/gateway/dev/mtls/client1-key-public
235247
name-transformation: lowercase
236248

249+
# Prepare cert files for the following test suites
250+
- name: Prepare mTLS cert files for tests
251+
if: github.event.action != 'closed'
252+
run: |
253+
printf '%s' "$_cds_gateway_dev_mtls_client1_key_secret" > /tmp/client1-key.pem
254+
printf '%s' "$_cds_gateway_dev_mtls_client1_key_public" > /tmp/client1-cert.pem
255+
chmod 600 /tmp/client1-key.pem /tmp/client1-cert.pem
256+
237257
- name: Smoke test preview URL
238258
if: github.event.action != 'closed'
239259
id: smoke-test
@@ -247,9 +267,6 @@ jobs:
247267
exit 0
248268
fi
249269
250-
# Reachability check: allow 404 (app routes might not exist yet) but fail otherwise
251-
printf '%s' "$_cds_gateway_dev_mtls_client1_key_secret" > /tmp/client1-key.pem
252-
printf '%s' "$_cds_gateway_dev_mtls_client1_key_public" > /tmp/client1-cert.pem
253270
STATUS=$(curl \
254271
--cert /tmp/client1-cert.pem \
255272
--key /tmp/client1-key.pem \
@@ -258,8 +275,6 @@ jobs:
258275
--write-out '%{http_code}' \
259276
--head \
260277
--max-time 30 "$PREVIEW_URL"/health || true)
261-
rm -f /tmp/client1-key.pem
262-
rm -f /tmp/client1-cert.pem
263278
264279
if [ "$STATUS" = "404" ]; then
265280
echo "Preview responded with expected 404"
@@ -285,6 +300,214 @@ jobs:
285300
echo "http_result=unexpected-status" >> "$GITHUB_OUTPUT"
286301
exit 0
287302
303+
# ---------- QUALITY CHECKS (Test Suites) ----------
304+
305+
# UNIT TESTS
306+
- name: Run unit tests against preview
307+
if: github.event.action != 'closed'
308+
env:
309+
MTLS_CERT: /tmp/client1-cert.pem
310+
MTLS_KEY: /tmp/client1-key.pem
311+
run: |
312+
make test-unit
313+
314+
- name: Upload unit test results
315+
if: always()
316+
uses: actions/upload-artifact@v5
317+
with:
318+
name: unit-test-results
319+
path: gateway-api/test-artefacts/
320+
retention-days: 30
321+
322+
- name: Check unit-tests.xml exists
323+
id: check-unit
324+
if: always()
325+
run: |
326+
TARGET="gateway-api/test-artefacts/unit-tests.xml"
327+
echo "Checking for $TARGET"
328+
if [ -f "$TARGET" ]; then
329+
echo "exists=true" >> "$GITHUB_OUTPUT"
330+
echo "Found $TARGET"
331+
else
332+
echo "exists=false" >> "$GITHUB_OUTPUT"
333+
echo "Missing $TARGET" >&2
334+
echo "Listing gateway-api/test-artefacts for debugging:"
335+
ls -la gateway-api/test-artefacts || true
336+
fi
337+
338+
- name: Publish unit test results to summary
339+
if: ${{ always() && steps.check-unit.outputs.exists == 'true' }}
340+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86
341+
with:
342+
paths: gateway-api/test-artefacts/unit-tests.xml
343+
344+
# CONTRACT TESTS
345+
- name: Run contract tests
346+
if: github.event.action != 'closed'
347+
env:
348+
BASE_URL: ${{ steps.tf-output.outputs.preview_url }}
349+
MTLS_CERT: /tmp/client1-cert.pem
350+
MTLS_KEY: /tmp/client1-key.pem
351+
run: |
352+
make test-contract
353+
354+
- name: Upload contract test results
355+
if: always()
356+
uses: actions/upload-artifact@v5
357+
with:
358+
name: contract-test-results
359+
path: gateway-api/test-artefacts/
360+
retention-days: 30
361+
362+
- name: Check contract-tests.xml exists
363+
id: check-contract
364+
if: always()
365+
run: |
366+
TARGET="gateway-api/test-artefacts/contract-tests.xml"
367+
echo "Checking for $TARGET"
368+
if [ -f "$TARGET" ]; then
369+
echo "exists=true" >> "$GITHUB_OUTPUT"
370+
echo "Found $TARGET"
371+
else
372+
echo "exists=false" >> "$GITHUB_OUTPUT"
373+
echo "Missing $TARGET" >&2
374+
echo "Listing gateway-api/test-artefacts for debugging:"
375+
ls -la gateway-api/test-artefacts || true
376+
fi
377+
378+
- name: Publish contract test results to summary
379+
if: ${{ always() && steps.check-contract.outputs.exists == 'true' }}
380+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86
381+
with:
382+
paths: gateway-api/test-artefacts/contract-tests.xml
383+
384+
# SCHEMA TESTS
385+
- name: Run schema validation tests against preview
386+
if: github.event.action != 'closed'
387+
env:
388+
BASE_URL: ${{ steps.tf-output.outputs.preview_url }}
389+
MTLS_CERT: /tmp/client1-cert.pem
390+
MTLS_KEY: /tmp/client1-key.pem
391+
run: |
392+
make test-schema
393+
394+
- name: Upload schema test results
395+
if: always()
396+
uses: actions/upload-artifact@v5
397+
with:
398+
name: schema-test-results
399+
path: gateway-api/test-artefacts/
400+
retention-days: 30
401+
402+
- name: Check schema-tests.xml exists
403+
id: check-schema
404+
if: always()
405+
run: |
406+
TARGET="gateway-api/test-artefacts/schema-tests.xml"
407+
echo "Checking for $TARGET"
408+
if [ -f "$TARGET" ]; then
409+
echo "exists=true" >> "$GITHUB_OUTPUT"
410+
echo "Found $TARGET"
411+
else
412+
echo "exists=false" >> "$GITHUB_OUTPUT"
413+
echo "Missing $TARGET" >&2
414+
echo "Listing gateway-api/test-artefacts for debugging:"
415+
ls -la gateway-api/test-artefacts || true
416+
fi
417+
418+
- name: Publish schema test results to summary
419+
if: ${{ always() && steps.check-schema.outputs.exists == 'true' }}
420+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86
421+
with:
422+
paths: gateway-api/test-artefacts/schema-tests.xml
423+
424+
# INTEGRATION TESTS
425+
- name: Run integration tests against preview
426+
if: github.event.action != 'closed'
427+
env:
428+
BASE_URL: ${{ steps.tf-output.outputs.preview_url }}
429+
MTLS_CERT: /tmp/client1-cert.pem
430+
MTLS_KEY: /tmp/client1-key.pem
431+
run: |
432+
make test-integration
433+
434+
- name: Upload integration test results
435+
if: always()
436+
uses: actions/upload-artifact@v5
437+
with:
438+
name: integration-test-results
439+
path: gateway-api/test-artefacts/
440+
retention-days: 30
441+
442+
- name: Check integration-tests.xml exists
443+
id: check-integration
444+
if: always()
445+
run: |
446+
TARGET="gateway-api/test-artefacts/integration-tests.xml"
447+
echo "Checking for $TARGET"
448+
if [ -f "$TARGET" ]; then
449+
echo "exists=true" >> "$GITHUB_OUTPUT"
450+
echo "Found $TARGET"
451+
else
452+
echo "exists=false" >> "$GITHUB_OUTPUT"
453+
echo "Missing $TARGET" >&2
454+
echo "Listing gateway-api/test-artefacts for debugging:"
455+
ls -la gateway-api/test-artefacts || true
456+
fi
457+
458+
- name: Publish integration test results to summary
459+
if: ${{ always() && steps.check-integration.outputs.exists == 'true' }}
460+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86
461+
with:
462+
paths: gateway-api/test-artefacts/integration-tests.xml
463+
464+
# ACCEPTANCE TESTS
465+
- name: Run acceptance tests against preview
466+
if: github.event.action != 'closed'
467+
env:
468+
BASE_URL: ${{ steps.tf-output.outputs.preview_url }}
469+
HOST: ${{ steps.set-host.outputs.host }}
470+
MTLS_CERT: /tmp/client1-cert.pem
471+
MTLS_KEY: /tmp/client1-key.pem
472+
run: |
473+
make test-acceptance
474+
475+
- name: Upload acceptance test results
476+
if: always()
477+
uses: actions/upload-artifact@v5
478+
with:
479+
name: acceptance-test-results
480+
path: gateway-api/test-artefacts/
481+
retention-days: 30
482+
483+
- name: Check acceptance-tests.xml exists
484+
id: check-acceptance
485+
if: always()
486+
run: |
487+
TARGET="gateway-api/test-artefacts/acceptance-tests.xml"
488+
echo "Checking for $TARGET"
489+
if [ -f "$TARGET" ]; then
490+
echo "exists=true" >> "$GITHUB_OUTPUT"
491+
echo "Found $TARGET"
492+
else
493+
echo "exists=false" >> "$GITHUB_OUTPUT"
494+
echo "Missing $TARGET" >&2
495+
echo "Listing gateway-api/test-artefacts for debugging:"
496+
ls -la gateway-api/test-artefacts || true
497+
fi
498+
499+
- name: Publish acceptance test results to summary
500+
if: ${{ always() && steps.check-acceptance.outputs.exists == 'true' }}
501+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86
502+
with:
503+
paths: gateway-api/test-artefacts/acceptance-tests.xml
504+
505+
# Cleanup after tests
506+
- name: Remove mTLS temp files
507+
if: github.event.action != 'closed'
508+
run: |
509+
rm -f /tmp/client1-key.pem /tmp/client1-cert.pem || true
510+
288511
- name: Comment function name on PR
289512
if: github.event_name == 'pull_request' && github.event.action != 'closed'
290513
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd

0 commit comments

Comments
 (0)