Skip to content

Commit d582c36

Browse files
author
James N.
committed
move test to after deployment
1 parent 393d44d commit d582c36

3 files changed

Lines changed: 116 additions & 42 deletions

File tree

.github/workflows/infrastructure.yml

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ on:
1010
type: string
1111
required: false
1212
default: tf
13+
outputs:
14+
backend_endpoint:
15+
description: "Backend API endpoint URL"
16+
value: ${{ jobs.tf.outputs.BACKEND_API_ENDPOINT }}
17+
mcp_endpoint:
18+
description: "MCP service endpoint URL"
19+
value: ${{ jobs.tf.outputs.MCP_ACA_URL }}
20+
model_endpoint:
21+
description: "Model endpoint URL"
22+
value: ${{ jobs.tf.outputs.MODEL_ENDPOINT }}
1323

1424
workflow_dispatch:
1525
inputs:
@@ -137,43 +147,5 @@ jobs:
137147
env:
138148
BICEP_DEPLOYMENT_RG: ${{ vars.BICEP_DEPLOYMENT_RG }}
139149

140-
test_prep:
141-
name: Integration Test Preparation and Runs
142-
needs: [tf, bicep]
143-
if: always() && (needs.tf.result == 'success' || needs.bicep.result == 'success')
144-
runs-on: ubuntu-latest
145-
# environment: removed to use repo-level variables
146-
permissions:
147-
id-token: write
148-
contents: read
149-
150-
steps:
151-
- uses: actions/checkout@v6
152-
153-
- name: Azure OIDC Login
154-
uses: azure/login@v2
155-
with:
156-
client-id: ${{ vars.AZURE_CLIENT_ID }}
157-
tenant-id: ${{ vars.AZURE_TENANT_ID }}
158-
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
159-
160-
- name: Run integration tests prep
161-
run: |
162-
pip install -r tests/requirements.txt
163-
164-
# Container Apps need time to start after deployment (cold start can take 2+ minutes)
165-
echo "Waiting for Container Apps to warm up..."
166-
sleep 120
167-
env:
168-
MODEL_ENDPOINT: ${{ needs.tf.outputs.MODEL_ENDPOINT }}
169-
170-
- name: Run integration tests
171-
run: pytest -v -m "integration" tests/ --tb=short
172-
continue-on-error: true # Don't fail the whole workflow on test failures
173-
env:
174-
RESOURCE_GROUP: ${{ vars.AZURE_RG }}
175-
MODEL_ENDPOINT: ${{ needs.tf.outputs.MODEL_ENDPOINT }}
176-
MCP_ENDPOINT: ${{ needs.tf.outputs.MCP_ACA_URL }}
177-
BACKEND_API_ENDPOINT: ${{ needs.tf.outputs.BACKEND_API_ENDPOINT }}
178-
# Skip MCP tests if deployed as internal-only (not reachable from GitHub runners)
179-
MCP_INTERNAL_ONLY: "true"
150+
# NOTE: Integration tests are run from orchestrate.yml AFTER containers are deployed
151+
# Do not add test jobs here - tests need to run after update-containers completes
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Integration Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
type: string
8+
required: false
9+
default: 'dev'
10+
backend_endpoint:
11+
type: string
12+
required: true
13+
description: 'Backend API endpoint URL'
14+
mcp_endpoint:
15+
type: string
16+
required: false
17+
description: 'MCP service endpoint URL'
18+
mcp_internal_only:
19+
type: boolean
20+
required: false
21+
default: true
22+
description: 'Whether MCP is internal-only (skip MCP tests)'
23+
24+
workflow_dispatch:
25+
inputs:
26+
environment:
27+
description: Target environment
28+
type: choice
29+
options: [dev, integration, prod]
30+
default: dev
31+
backend_endpoint:
32+
description: 'Backend API endpoint URL'
33+
required: true
34+
mcp_endpoint:
35+
description: 'MCP service endpoint URL (optional if internal)'
36+
required: false
37+
38+
jobs:
39+
integration-tests:
40+
name: Run Integration Tests
41+
runs-on: ubuntu-latest
42+
# No environment needed - uses repo-level variables
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: '3.12'
51+
52+
- name: Install test dependencies
53+
run: |
54+
pip install -r tests/requirements.txt
55+
56+
- name: Wait for Container Apps to warm up
57+
run: |
58+
echo "Waiting 120 seconds for Container Apps to be ready..."
59+
sleep 120
60+
61+
- name: Run integration tests
62+
run: |
63+
cd tests
64+
pytest -v -m "integration" --tb=short
65+
continue-on-error: true # Report results but don't fail the workflow
66+
env:
67+
BACKEND_API_ENDPOINT: ${{ inputs.backend_endpoint }}
68+
MCP_ENDPOINT: ${{ inputs.mcp_endpoint }}
69+
MCP_INTERNAL_ONLY: ${{ inputs.mcp_internal_only && 'true' || 'false' }}
70+
71+
- name: Test Summary
72+
if: always()
73+
run: |
74+
echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY
75+
echo "" >> $GITHUB_STEP_SUMMARY
76+
echo "- Backend Endpoint: ${{ inputs.backend_endpoint }}" >> $GITHUB_STEP_SUMMARY
77+
echo "- MCP Endpoint: ${{ inputs.mcp_endpoint || 'Internal (skipped)' }}" >> $GITHUB_STEP_SUMMARY
78+
echo "- Environment: ${{ inputs.environment }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/orchestrate.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,34 @@ jobs:
122122
}}
123123
secrets: inherit
124124

125+
# Step 4: Run integration tests AFTER containers are deployed and running
126+
integration-tests:
127+
needs: [ deploy-infrastructure, update-containers ]
128+
if: always() && needs.update-containers.result == 'success'
129+
uses: ./.github/workflows/integration-tests.yml
130+
with:
131+
environment: >-
132+
${{
133+
inputs.target_env
134+
|| (github.event_name == 'pull_request' && (
135+
github.base_ref == 'tjs-infra-as-code' && 'dev'
136+
|| github.base_ref == 'int-agentic' && 'integration'
137+
|| github.base_ref == 'main' && 'prod'
138+
))
139+
|| (github.ref_name == 'tjs-infra-as-code' && 'dev')
140+
|| (github.ref_name == 'int-agentic' && 'integration')
141+
|| (github.ref_name == 'main' && 'prod')
142+
|| 'dev'
143+
}}
144+
backend_endpoint: ${{ needs.deploy-infrastructure.outputs.backend_endpoint }}
145+
mcp_endpoint: ${{ needs.deploy-infrastructure.outputs.mcp_endpoint }}
146+
mcp_internal_only: true
147+
secrets: inherit
148+
125149
# Optional: Destroy infrastructure (only for test branches)
126150
destroy-infrastructure:
127-
needs: [ update-containers ]
128-
if: always() && (github.ref_name == 'tjs-infra-as-code' || (inputs.target_env && inputs.target_env == 'dev')) && needs.update-containers.result == 'success'
151+
needs: [ integration-tests ]
152+
if: always() && (github.ref_name == 'tjs-infra-as-code' || (inputs.target_env && inputs.target_env == 'dev')) && needs.integration-tests.result == 'success'
129153
uses: ./.github/workflows/destroy.yml
130154
with:
131155
environment: >-

0 commit comments

Comments
 (0)