Skip to content

Commit 2f2dd15

Browse files
committed
feat(workflow): AZD deployment testing on PR
1 parent 08c27e8 commit 2f2dd15

5 files changed

Lines changed: 105 additions & 4 deletions

File tree

.github/workflows/audit-bicep.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Scan Bicep code
1+
name: audit-bicep
22
on:
33
push:
44
branches:

.github/workflows/audit-terraform.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# separate terms of service, privacy policy, and support
44
# documentation.
55

6-
name: Scan Terraform code
6+
name: audit-terraform
77

88
on:
99
push:

.github/workflows/test-e2e-main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# composite workflow to test the azd deployment of the app
22
# uses a github federated identity
3-
name: Test AZD Deployment
3+
name: test-e2e-main
44

55
on:
66
push:

.github/workflows/test-e2e-pr.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: test-e2e-pr
2+
3+
on:
4+
pull_request_target:
5+
types: [assigned, opened, synchronize, reopened]
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
11+
jobs:
12+
test-e2e:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
17+
18+
- name: Install Terraform
19+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
20+
21+
- name: Install azd
22+
uses: Azure/setup-azd@ae0f8b5482eeac61e940f447327d84c73beb8b1e # v2.1.0
23+
24+
- name: Install kubelogin
25+
uses: azure/use-kubelogin@76597ae0fcbaace21b05e13a2cbf8daee2c6e820 # v1
26+
with:
27+
kubelogin-version: "v0.2.8"
28+
29+
- name: Azure login
30+
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2
31+
with:
32+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
33+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
34+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
35+
36+
- name: Azure Developer CLI login
37+
run: |
38+
azd auth login \
39+
--client-id ${{ secrets.AZURE_CLIENT_ID }} \
40+
--federated-credential-provider "github" \
41+
--tenant-id ${{ secrets.AZURE_TENANT_ID }}
42+
43+
- name: Turn on Helm support for AKS
44+
run: azd config set alpha.aks.helm on
45+
46+
- name: Set helm chart location
47+
run: sed -i 's/azure-samples.github.io/${{ github.repository_owner }}.github.io/' azure.yaml
48+
49+
- name: Provision and deploy
50+
run: |
51+
azd env new ${{ vars.AZURE_ENV_NAME }}
52+
azd env set BUILD_CONTAINERS true
53+
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
54+
azd env set DEPLOY_AZURE_OPENAI true
55+
azd env set AZURE_OPENAI_LOCATION ${{ vars.AZURE_LOCATION }}
56+
azd env set SOURCE_REGISTRY "ghcr.io/${{ github.repository_owner }}"
57+
azd up --no-prompt
58+
env:
59+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
60+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
61+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
62+
63+
- name: Get Store IPs
64+
id: kubectl_get_service
65+
run: |
66+
eval $(azd env get-values)
67+
storeAdminIp=$(kubectl get service store-admin -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
68+
while [ -z "$storeAdminIp" ]; do
69+
sleep 60
70+
storeAdminIp=$(kubectl get service store-admin -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
71+
done
72+
echo "STORE_ADMIN_IP=${storeAdminIp}"
73+
echo "STORE_ADMIN_IP=${storeAdminIp}" >> "$GITHUB_OUTPUT"
74+
storeFrontIp=$(kubectl get service store-front -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
75+
while [ -z "$storeFrontIp" ]; do
76+
sleep 60
77+
storeFrontIp=$(kubectl get service store-front -n $AZURE_AKS_NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
78+
done
79+
echo "STORE_FRONT_IP=${storeFrontIp}"
80+
echo "STORE_FRONT_IP=${storeFrontIp}" >> "$GITHUB_OUTPUT"
81+
82+
- name: Install Playwright dependencies
83+
run: npm ci
84+
working-directory: tests
85+
86+
- name: Run Playwright tests
87+
run: npx playwright test --config=playwright.service.config.ts --workers=20
88+
working-directory: tests
89+
env:
90+
PLAYWRIGHT_SERVICE_URL: ${{ secrets.PLAYWRIGHT_SERVICE_URL }}
91+
STORE_ADMIN_URL: "http://${{ steps.kubectl_get_service.outputs.STORE_ADMIN_IP }}"
92+
STORE_FRONT_URL: "http://${{ steps.kubectl_get_service.outputs.STORE_FRONT_IP }}"
93+
CI: true
94+
95+
- name: Destroy environment
96+
run: azd down --force --purge
97+
if: always()
98+
env:
99+
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
100+
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
101+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

.github/workflows/test-playwright.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Playwright Tests
1+
name: test-playwright
22

33
on:
44
workflow_call:

0 commit comments

Comments
 (0)