-
Notifications
You must be signed in to change notification settings - Fork 55
220 lines (186 loc) · 6.66 KB
/
e2e-windows.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: e2e test windows
on:
workflow_dispatch:
workflow_call:
inputs:
scheduled:
description: Whether this is a scheduled run.
type: boolean
default: false
required: false
jobs:
build-cli:
name: Build Windows CLI
runs-on: ubuntu-22.04
permissions:
id-token: write
checks: write
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
- name: Setup bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
- name: Log in to the Container registry
uses: ./.github/actions/container_registry_login
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build CLI
uses: ./.github/actions/build_cli
with:
targetOS: "windows"
targetArch: "amd64"
enterpriseCLI: true
outputPath: "build/constellation"
push: true
- name: Upload CLI artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
path: build/constellation.exe
name: "constell-exe"
e2e-test:
name: E2E Test Windows
runs-on: windows-2022
needs: build-cli
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
- name: Download CLI artifact
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: "constell-exe"
- name: Check CLI version
shell: pwsh
run: |
.\constellation.exe version
Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`n127.0.0.1`tlicense.confidential.cloud" -Force
- name: Login to Azure (IAM service principal)
uses: ./.github/actions/login_azure
with:
azure_credentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
- name: Create IAM configuration
shell: pwsh
run: |
$uid = Get-Random -Minimum 1000 -Maximum 9999
$rgName = "e2e-win-${{ github.run_id }}-${{ github.run_attempt }}-$uid"
.\constellation.exe config generate azure
.\constellation.exe iam create azure --region=westus --resourceGroup=$rgName-rg --servicePrincipal=$rgName-sp --update-config --debug -y
- name: Login to Azure (Cluster service principal)
uses: ./.github/actions/login_azure
with:
azure_credentials: ${{ secrets.AZURE_E2E_CLUSTER_CREDENTIALS }}
- name: Apply config
shell: pwsh
run: |
.\constellation.exe apply --debug -y
- name: Liveness probe
shell: pwsh
run: |
$retryIntervalSeconds = 30
$maxRetries = 50
$retryCount = 0
$allNodesReady = $false
while (-not $allNodesReady -and $retryCount -lt $maxRetries) {
${retryCount}++
Write-Host "Retry ${retryCount}: Checking node status..."
$nodesOutput = & kubectl get nodes --kubeconfig "$PWD\constellation-admin.conf"
$status = $?
$nodesOutput
if ($status) {
$lines = $nodesOutput -split "`r?`n" | Select-Object -Skip 1
if ($lines.count -eq 4) {
$allNodesReady = $true
foreach ($line in $lines) {
$columns = $line -split '\s+' | Where-Object { $_ -ne '' }
$nodeName = $columns[0]
$status = $columns[1]
if ($status -ne "Ready") {
Write-Host "Node $nodeName is not ready!"
$allNodesReady = $false
}
}
}
}
if (-not $allNodesReady -and $retryCount -lt $maxRetries) {
Write-Host "Retrying in $retryIntervalSeconds seconds..."
Start-Sleep -Seconds $retryIntervalSeconds
}
}
if ($allNodesReady) {
Write-Host "All nodes are ready!"
}
else {
Write-Host "Node status check failed after $maxRetries retries."
EXIT 1
}
- name: Terminate cluster
if: always()
shell: pwsh
run: |
.\constellation.exe terminate --debug -y
- name: Login to Azure (IAM service principal)
if: always()
uses: ./.github/actions/login_azure
with:
azure_credentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
- name: Delete IAM configuration
if: always()
shell: pwsh
run: |
.\constellation.exe iam destroy --debug -y
notify-failure:
name: Notify about failure
runs-on: ubuntu-22.04
needs: e2e-test
if: |
failure() &&
github.ref == 'refs/heads/main' &&
inputs.scheduled
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
- name: Setup bazel
uses: ./.github/actions/setup_bazel_nix
with:
useCache: "true"
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
- name: Notify about failure
continue-on-error: true
uses: ./.github/actions/notify_e2e_failure
with:
projectWriteToken: ${{ secrets.PROJECT_WRITE_TOKEN }}
test: Windows E2E Test
provider: Azure
attestationVariant: "azure-sev-snp"
upload-tfstate:
name: Upload terraform state
runs-on: ubuntu-22.04
needs: e2e-test
if: always()
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
- name: Upload tfstate
if: always()
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ github.run_id }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
skipDeletion: true