Skip to content

Commit fd065ba

Browse files
committed
test(e2e): adding integration testing via github
workflow and azd - also modified terraform to accomodate running as service principal
1 parent 62c4aed commit fd065ba

16 files changed

Lines changed: 463 additions & 264 deletions

.github/workflows/azure-dev.yaml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/test-azd-deployment.yaml

Lines changed: 0 additions & 163 deletions
This file was deleted.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# composite workflow to test the azd deployment of the app
2+
# uses a github federated identity
3+
name: Test AZD Deployment
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
workflow_dispatch:
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
jobs:
17+
deploy:
18+
outputs:
19+
storeAdminIp: ${{ steps.kubectl_get_service.outputs.STORE_ADMIN_IP }}
20+
storeFrontIp: ${{ steps.kubectl_get_service.outputs.STORE_FRONT_IP }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
25+
26+
- name: Install Terraform
27+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
28+
29+
- name: Install azd
30+
uses: Azure/setup-azd@ae0f8b5482eeac61e940f447327d84c73beb8b1e # v2.1.0
31+
32+
- name: Install kubelogin
33+
uses: azure/use-kubelogin@76597ae0fcbaace21b05e13a2cbf8daee2c6e820 # v1
34+
with:
35+
kubelogin-version: "v0.2.8"
36+
37+
- name: Azure CLI login
38+
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2
39+
with:
40+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
41+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
42+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
43+
44+
- name: Azure Developer CLI login
45+
run: |
46+
azd auth login \
47+
--client-id ${{ secrets.AZURE_CLIENT_ID }} \
48+
--federated-credential-provider "github" \
49+
--tenant-id ${{ secrets.AZURE_TENANT_ID }}
50+
51+
- name: Turn on Helm support for azd
52+
run: azd config set alpha.aks.helm on
53+
54+
- name: Provision and deploy
55+
id: provision_deploy
56+
continue-on-error: true
57+
run: |
58+
azd env new ${{ vars.AZURE_ENV_NAME }}
59+
azd env set AKS_NODE_POOL_VM_SIZE Standard_D2_v4
60+
azd env set BUILD_CONTAINERS false
61+
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
62+
azd env set DEPLOY_AZURE_OPENAI true
63+
azd env set AZURE_OPENAI_LOCATION ${{ vars.AZURE_LOCATION }}
64+
azd env set DEPLOY_AZURE_OPENAI_DALL_E_MODEL false
65+
azd env set DEPLOY_AZURE_SERVICE_BUS true
66+
azd env set DEPLOY_AZURE_COSMOSDB true
67+
azd env set AZURE_COSMOSDB_ACCOUNT_KIND MongoDB
68+
azd env set DEPLOY_OBSERVABILITY_TOOLS true
69+
azd up --no-prompt
70+
env:
71+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
72+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
73+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
74+
75+
- name: Save azd cache
76+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
77+
if: always()
78+
with:
79+
path: |
80+
.azure/
81+
key: ${{ runner.os }}-azd-${{ github.run_id }}-${{ github.sha }}
82+
83+
- name: Check provision and deploy result
84+
if: steps.provision_deploy.outcome == 'failure'
85+
run: |
86+
echo "Provision and deploy failed"
87+
exit 1
88+
89+
- name: Get Store IPs
90+
if: steps.provision_deploy.outcome == 'success'
91+
run: |
92+
eval $(azd env get-values)
93+
storeAdminIp=$(kubectl get service store-admin -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
94+
while [ -z "$storeAdminIp" ]; do
95+
sleep 60
96+
storeAdminIp=$(kubectl get service store-admin -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
97+
done
98+
echo "STORE_ADMIN_IP=${storeAdminIp}"
99+
echo "STORE_ADMIN_IP=${storeAdminIp}" >> "$GITHUB_OUTPUT"
100+
storeFrontIp=$(kubectl get service store-front -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
101+
while [ -z "$storeFrontIp" ]; do
102+
sleep 60
103+
storeFrontIp=$(kubectl get service store-front -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
104+
done
105+
echo "STORE_FRONT_IP=${storeFrontIp}"
106+
echo "STORE_FRONT_IP=${storeFrontIp}" >> "$GITHUB_OUTPUT"
107+
108+
playwright-tests:
109+
needs: deploy
110+
uses: ./.github/workflows/test-playwright.yaml
111+
with:
112+
storeAdminUrl: "http://${{ needs.deploy.outputs.storeAdminIp }}"
113+
storeFrontUrl: "http://${{ needs.deploy.outputs.storeFrontIp }}"
114+
115+
teardown:
116+
if: always()
117+
needs: playwright-tests
118+
runs-on: ubuntu-latest
119+
steps:
120+
- name: Checkout
121+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
122+
123+
- name: Install Terraform
124+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
125+
126+
- name: Install azd
127+
uses: Azure/setup-azd@ae0f8b5482eeac61e940f447327d84c73beb8b1e # v2.1.0
128+
129+
- name: Restore azd cache
130+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
131+
with:
132+
path: |
133+
.azure/
134+
key: ${{ runner.os }}-azd-${{ github.run_id }}-${{ github.sha }}
135+
136+
- name: Azure CLI login
137+
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2
138+
with:
139+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
140+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
141+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
142+
143+
- name: Azure Developer CLI login
144+
run: |
145+
azd auth login \
146+
--client-id ${{ secrets.AZURE_CLIENT_ID }} \
147+
--federated-credential-provider "github" \
148+
--tenant-id ${{ secrets.AZURE_TENANT_ID }}
149+
150+
- name: Destroy environment
151+
run: azd down --force --purge
152+
env:
153+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
154+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
155+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
156+
157+
- name: Remove azd folder
158+
run: rm -rf .azure

0 commit comments

Comments
 (0)