Skip to content

Commit 3799429

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 3799429

13 files changed

Lines changed: 296 additions & 259 deletions

File tree

.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: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
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 BUILD_CONTAINERS false
60+
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
61+
azd env set DEPLOY_AZURE_OPENAI true
62+
azd env set AZURE_OPENAI_LOCATION ${{ vars.AZURE_LOCATION }}
63+
azd env set DEPLOY_AZURE_OPENAI_DALL_E_MODEL false
64+
azd env set DEPLOY_AZURE_SERVICE_BUS true
65+
azd env set DEPLOY_AZURE_COSMOSDB true
66+
azd env set AZURE_COSMOSDB_ACCOUNT_KIND MongoDB
67+
azd env set DEPLOY_OBSERVABILITY_TOOLS true
68+
azd up --no-prompt
69+
env:
70+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
71+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
72+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
73+
74+
- name: Save azd cache
75+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
76+
if: always()
77+
with:
78+
path: |
79+
.azure/
80+
key: ${{ runner.os }}-azd-${{ env.BUST_CACHE }}-${{ github.sha }}
81+
82+
- name: Check provision and deploy result
83+
if: steps.provision_deploy.outcome == 'failure'
84+
run: |
85+
echo "Provision and deploy failed"
86+
exit 1
87+
88+
- name: Get Store IPs
89+
if: steps.provision_deploy.outcome == 'success'
90+
run: |
91+
eval $(azd env get-values)
92+
storeAdminIp=$(kubectl get service store-admin -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
93+
while [ -z "$storeAdminIp" ]; do
94+
sleep 60
95+
storeAdminIp=$(kubectl get service store-admin -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
96+
done
97+
echo "STORE_ADMIN_IP=${storeAdminIp}"
98+
echo "STORE_ADMIN_IP=${storeAdminIp}" >> "$GITHUB_OUTPUT"
99+
storeFrontIp=$(kubectl get service store-front -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
100+
while [ -z "$storeFrontIp" ]; do
101+
sleep 60
102+
storeFrontIp=$(kubectl get service store-front -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
103+
done
104+
echo "STORE_FRONT_IP=${storeFrontIp}"
105+
echo "STORE_FRONT_IP=${storeFrontIp}" >> "$GITHUB_OUTPUT"
106+
107+
playwright-tests:
108+
needs: deploy
109+
uses: ./.github/workflows/test-playwright.yaml
110+
with:
111+
storeAdminUrl: "http://${{ needs.deploy.outputs.storeAdminIp }}"
112+
storeFrontUrl: "http://${{ needs.deploy.outputs.storeFrontIp }}"
113+
114+
teardown:
115+
if: always()
116+
needs: playwright-tests
117+
runs-on: ubuntu-latest
118+
steps:
119+
- name: Checkout
120+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
121+
122+
- name: Install Terraform
123+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
124+
125+
- name: Install azd
126+
uses: Azure/setup-azd@ae0f8b5482eeac61e940f447327d84c73beb8b1e # v2.1.0
127+
128+
- name: Restore azd cache
129+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4
130+
with:
131+
path: |
132+
.azure/
133+
key: ${{ runner.os }}-azd-${{ env.BUST_CACHE }}-${{ github.sha }}
134+
135+
- name: Azure CLI login
136+
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2
137+
with:
138+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
139+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
140+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
141+
142+
- name: Azure Developer CLI login
143+
run: |
144+
azd auth login \
145+
--client-id ${{ secrets.AZURE_CLIENT_ID }} \
146+
--federated-credential-provider "github" \
147+
--tenant-id ${{ secrets.AZURE_TENANT_ID }}
148+
149+
- name: Destroy environment
150+
run: azd down --force --purge
151+
env:
152+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
153+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
154+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

0 commit comments

Comments
 (0)