Skip to content

Commit 52cda32

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 52cda32

13 files changed

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

0 commit comments

Comments
 (0)