Skip to content

Commit b8255d0

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 b8255d0

13 files changed

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

0 commit comments

Comments
 (0)