-
Notifications
You must be signed in to change notification settings - Fork 164
150 lines (128 loc) · 4.62 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---
name: "AzOps - Tests"
on:
workflow_dispatch:
pull_request_target:
branches: [main]
paths:
- "src/**"
- "!src/AzOps.psd1"
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
tests:
name: "Tests"
runs-on: ubuntu-latest
environment: test
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
steps:
# Checkout
- name: "Checkout"
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
# Dependencies
- name: "Dependencies"
shell: pwsh
run: |
./scripts/Dependencies.ps1
# Connect to Azure - TEMPORARY until 2.7.0 credential expiration issue is fixed
- name: "Connect"
shell: pwsh
run: |
$credential = New-Object PSCredential -ArgumentList $env:ARM_CLIENT_ID, (ConvertTo-SecureString -String $env:ARM_CLIENT_SECRET -AsPlainText -Force)
Connect-AzAccount -TenantId $env:ARM_TENANT_ID -ServicePrincipal -Credential $credential -SubscriptionId $env:ARM_SUBSCRIPTION_ID
# # Authenticate Azure context
# - name: OIDC Login to Azure Public Cloud with AzPowershell (enableAzPSSession true)
# uses: azure/login@v1
# with:
# client-id: ${{ env.ARM_CLIENT_ID }}
# tenant-id: ${{ env.ARM_TENANT_ID }}
# subscription-id: ${{ env.ARM_SUBSCRIPTION_ID }}
# enable-AzPSSession: true
# Run General Tests
- name: "Run General Tests"
shell: pwsh
run: |
./src/tests/Pester.ps1 -TestGeneral $true
# Run Functions Tests
- name: "Run Functions Tests"
shell: pwsh
run: |
./src/tests/Pester.ps1 -TestFunctions $true
# Run Environment Primer
- name: "Run Environment Primer"
shell: pwsh
run: |
./src/tests/Pester.ps1 -CleanupEnvironment $true
# Run Functional Tests
- name: "Run Functional Tests"
shell: pwsh
run: |
./src/tests/Pester.ps1 -TestFunctional $true
# Run Integration Tests
- name: "Run Integration Tests"
if: always()
shell: pwsh
run: |
./src/tests/Pester.ps1 -TestIntegration $true
# Run Cleanup Environment
- name: "Run Environment Cleanup"
shell: pwsh
run: |
./src/tests/Pester.ps1 -CleanupEnvironment $true
testsubonly:
needs: tests
name: "Tests - Subscription Only"
runs-on: ubuntu-latest
environment: test
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID_SUB }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET_SUB }}
steps:
# Checkout
- name: "Checkout"
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
# Dependencies
- name: "Dependencies"
shell: pwsh
run: |
./scripts/Dependencies.ps1
# Connect to Azure - TEMPORARY until 2.7.0 credential expiration issue is fixed
- name: "Connect"
shell: pwsh
run: |
$credential = New-Object PSCredential -ArgumentList $env:ARM_CLIENT_ID, (ConvertTo-SecureString -String $env:ARM_CLIENT_SECRET -AsPlainText -Force)
Connect-AzAccount -TenantId $env:ARM_TENANT_ID -ServicePrincipal -Credential $credential -SubscriptionId $env:ARM_SUBSCRIPTION_ID
# # Authenticate Azure context
# - name: OIDC Login to Azure Public Cloud with AzPowershell (enableAzPSSession true)
# uses: azure/login@v1
# with:
# client-id: ${{ env.ARM_CLIENT_ID_SUB }}
# tenant-id: ${{ env.ARM_TENANT_ID }}
# subscription-id: ${{ env.ARM_SUBSCRIPTION_ID }}
# enable-AzPSSession: true
# Run Subscription Only Tests
- name: "Run Subscription Only Tests"
shell: pwsh
run: |
./src/tests/Pester.ps1 -TestSubscriptionOnly $true
# Run Cleanup Environment
- name: "Run Environment Cleanup"
shell: pwsh
run: |
./src/tests/Pester.ps1 -CleanupEnvironment $true