-
Notifications
You must be signed in to change notification settings - Fork 260
225 lines (209 loc) · 8.98 KB
/
Copy pathwindows-qe-tpl.yml
File metadata and controls
225 lines (209 loc) · 8.98 KB
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
220
221
222
223
224
225
# The template is intended to be used from a workflow run
# as it will pick the artifacts from the triger (through workflow_id param)
name: windows-qe-tpl
on:
workflow_call:
inputs:
trigger-workflow-run-id:
required: true
type: string
qe-type:
description: type of test; allowed values e2e or integration
required: true
type: string
preset:
description: preset type only required if qe-type is e2e
type: string
jobs:
windows-qe:
runs-on: ubuntu-latest
permissions:
statuses: write # needed to update commit status (pending/failure/sucess)
checks: write # as documented in https://github.com/mikepenz/action-junit-report?tab=readme-ov-file#pr-run-permissions
strategy:
fail-fast: false
matrix:
windows-version: ['10','11']
windows-featurepack: ['22h2-ent-g2', '23h2-ent']
exclude:
- windows-version: '10'
windows-featurepack: '23h2-ent'
- windows-version: '11'
windows-featurepack: '22h2-ent-g2'
steps:
- name: Download windows installer
id: download-windows-installer-artifact
uses: actions/download-artifact@v7
with:
name: windows-installer
run-id: ${{inputs.trigger-workflow-run-id}}
github-token: ${{ github.token }}
- name: Download qe oci image
id: download-qe-oci-image-artifact
uses: actions/download-artifact@v7
with:
name: crc-${{inputs.qe-type}}-windows-amd64
run-id: ${{inputs.trigger-workflow-run-id}}
github-token: ${{ github.token }}
- name: Correlate
env:
PULL_SECRET: ${{ secrets.PULL_SECRET }}
run: |
# Get origin commit sha for testing
commit_sha=${{ github.event.workflow_run.head_commit.id }}
if [[ -z "${commit_sha}" ]] || [[ "${commit_sha}" == null ]]; then
# if .head_commit.id is empty, then .head_sha is used as commit instead
commit_sha=${{ github.event.workflow_run.head_sha }}
fi
echo "commit_sha=${commit_sha}" >> "$GITHUB_ENV"
# Set status_context
status_context="ci/gh/${{inputs.qe-type}}"
if [[ "${{inputs.qe-type}}" == "e2e" ]]; then
status_context="${status_context}-${{inputs.preset}}"
fi
status_context="${status_context}/windows-${{matrix.windows-version}}-${{matrix.windows-featurepack}}"
echo "status_context=${status_context}" >> "$GITHUB_ENV"
# Save pull-secret as file
echo "${PULL_SECRET}" > pull-secret
- name: Add status to the PR check
run: |
set -xuo
# Status msg
data="{\"state\":\"pending\""
data="${data},\"description\":\"Running ${{inputs.qe-type}}-${{inputs.preset}} on Windows\""
data="${data},\"context\":\"${{ env.status_context }}\""
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
# Create status by API call
curl -L -v -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
-d "${data}"
- name: Create Windows instance
run: |
sudo chmod -R 777 $GITHUB_WORKSPACE
# Create instance
podman run -d --name windows-create --rm \
-v ${PWD}:/workspace:z \
-e ARM_TENANT_ID=${{secrets.ARM_TENANT_ID}} \
-e ARM_SUBSCRIPTION_ID=${{secrets.ARM_SUBSCRIPTION_ID}} \
-e ARM_CLIENT_ID=${{secrets.ARM_CLIENT_ID}} \
-e ARM_CLIENT_SECRET='${{secrets.ARM_CLIENT_SECRET}}' \
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
quay.io/redhat-developer/mapt:v0.9.9 azure \
windows create \
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}-${{inputs.qe-type}}-${{inputs.preset}}' \
--backed-url azblob://crc-qenvs-state/${{ github.repository }}-${{ github.run_id }} \
--conn-details-output '/workspace' \
--nested-virt \
--cpus 8 \
--windows-version '${{matrix.windows-version}}' \
--windows-featurepack '${{matrix.windows-featurepack}}' \
--tags project=openshift-local,source=github,org=${{github.repository_owner}},run=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} \
--spot \
--spot-excluded-regions southafricawest,australiacentral2,eastus2euap
podman logs -f windows-create
sudo chown runner:runner host username id_rsa
- name: Install CRC on host
run: |
podman run --rm -d --name crc-win-support \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-support \
-e TARGET_CLEANUP='false' \
-e OUTPUT_FOLDER=/data \
-e DEBUG='true' \
-v ${PWD}:/data:z \
-v ${PWD}/crc-windows-installer.zip:/opt/crc-support/crc-windows-installer.zip:z \
quay.io/rhqp/crc-support:v0.5-windows crc-support/run.ps1 \
-targetPath "/Users/$(cat username)/crc-support" \
-download 'false' \
-install 'true' \
-forceFresh 'false'
podman logs -f crc-win-support
- name: Run CRC ${{inputs.qe-type}}
run: |
# load image
podman load -i crc-${{inputs.qe-type}}-windows-amd64.tar
# run
cmd="crc-qe/run.ps1 -junitFilename crc-${{inputs.qe-type}}-junit.xml -targetFolder crc-qe"
if [[ "${{inputs.qe-type}}" == "e2e" ]]; then
if [[ "${{inputs.preset}}" == "microshift" ]]; then
cmd="${cmd} -e2eTagExpression '@story_microshift'"
else
cmd="${cmd} -e2eTagExpression '~@minimal && ~@story_microshift'"
fi
else
cmd="${cmd} -suiteTimeout 120m"
fi
podman run --rm -d --name crc-${{inputs.qe-type}} \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=crc-qe \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD/pull-secret:/opt/crc/pull-secret:z \
-v $PWD:/data:z \
quay.io/crcont/crc-${{inputs.qe-type}}:gh-windows-amd64 \
${cmd}
podman logs -f crc-${{inputs.qe-type}}
- name: Test Report
id: test-report
uses: mikepenz/action-junit-report@v6
if: always()
with:
fail_on_failure: true
include_passed: true
detailed_summary: true
require_tests: true
report_paths: '**/*.xml'
- name: Upload ${{inputs.qe-type}} results
uses: actions/upload-artifact@v6
if: always()
with:
name: windows-${{inputs.qe-type}}-${{inputs.preset}}-${{matrix.windows-version}}${{matrix.windows-featurepack}}
path: |
**/*.xml
**/*.results
**/*.log
- name: Update status of the PR check
if: always()
run: |
set -xuo
# Status msg
data="{\"state\":\"success\""
if [[ ${{steps.test-report.outcome}} != "success" ]]; then
data="{\"state\":\"failure\""
fi
data="${data},\"description\":\"Finished ${{inputs.qe-type}}-${{inputs.preset}} on Windows\""
data="${data},\"context\":\"${{ env.status_context }}\""
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
# Create status by API call
curl -L -v -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
-d "${data}"
- name: Destroy instance
if: always()
run: |
# Make sure lock is removed
rm -rf .pulumi/locks/*
# Destroy
podman run -d --name windows-destroy --rm \
-v ${PWD}:/workspace:z \
-e ARM_TENANT_ID=${{secrets.ARM_TENANT_ID}} \
-e ARM_SUBSCRIPTION_ID=${{secrets.ARM_SUBSCRIPTION_ID}} \
-e ARM_CLIENT_ID=${{secrets.ARM_CLIENT_ID}} \
-e ARM_CLIENT_SECRET='${{secrets.ARM_CLIENT_SECRET}}' \
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
quay.io/redhat-developer/mapt:v0.9.9 azure \
windows destroy \
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}-${{inputs.qe-type}}-${{inputs.preset}}' \
--backed-url azblob://crc-qenvs-state/${{ github.repository }}-${{ github.run_id }}
podman logs -f windows-destroy