Skip to content

Commit 5223695

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

5 files changed

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