Skip to content

Commit 456d758

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 456d758

13 files changed

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

0 commit comments

Comments
 (0)