Skip to content

Commit eef3114

Browse files
author
Jakub Sliacan
committed
Set status on the upstream check
The commit SHA is the same on fork and upstream. Use it to set commit's status.
1 parent 18f0eb5 commit eef3114

File tree

1 file changed

+194
-172
lines changed

1 file changed

+194
-172
lines changed

.github/workflows/windows-e2e.yml

+194-172
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
windows:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
statuses: write # needed to update commit status (pending, failure/sucess)
1214
strategy:
1315
fail-fast: false
1416
matrix:
@@ -24,184 +26,204 @@ jobs:
2426
workflow: ${{ github.event.workflow_run.workflow_id }}
2527
name: gh_context
2628

27-
- name: Add status in PR checks
29+
- name: Add variables to GITHUB_ENV
2830
run: |
29-
set -Eeuo pipefail
30-
OWNER_REPO=$(cat gh_context.json | jq -r '.repository')
31-
AFTER=$(cat gh_context.json | jq -r '.event.after')
31+
# SHA used as ID to correlate artifacts between buld-tests, windows-installer, and windows-e2e workflows
32+
echo "SHA=$(cat gh_context.json | jq -r '.sha')" >> "$GITHUB_ENV"
3233
34+
COMMIT_ID=$(cat gh_context.json | jq -r '.event.after')
35+
# if this is a new PR, .event.after is empty, use .sha instead in that case
36+
if [[ -z "$COMMIT_ID"]]; then
37+
COMMIT_ID=$(cat gh_context.json | jq -r '.sha')
38+
fi
39+
40+
# COMMIT_SHA used to identify commit whose status needs to be set to reflect test results
41+
echo "COMMIT_SHA=$COMMIT_ID" >> "$GITHUB_ENV"
42+
43+
- name: Add status to the PR check
44+
run: |
45+
OUTCOME="pending"
46+
DESCRIPTION="Running e2e on Windows"
47+
CONTEXT="win-ci-e2e"
48+
49+
# post result to commit status
3350
curl -L -v \
3451
-X POST \
3552
-H "Accept: application/vnd.github+json" \
3653
-H "Authorization: Bearer ${{ github.token }}" \
37-
https://api.github.com/repos/${OWNER_REPO}/statuses/${AFTER} \
38-
-d '{"state":"pending", "description":"Running e2e on Windows", "context":"win-ci-e2e"}'
39-
40-
# - name: Create instance
41-
# run: |
42-
# # Create instance
43-
# podman run -d --name windows-create --rm \
44-
# -v ${PWD}:/workspace:z \
45-
# -e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
46-
# -e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
47-
# -e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
48-
# -e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
49-
# quay.io/rhqp/qenvs:v0.6.0 azure \
50-
# windows create \
51-
# --project-name 'windows-desktop' \
52-
# --backed-url 'file:///workspace' \
53-
# --conn-details-output '/workspace' \
54-
# --windows-version '${{ matrix.windows-version }}' \
55-
# --windows-featurepack '${{ matrix.windows-featurepack }}' \
56-
# --vmsize 'Standard_D8s_v4' \
57-
# --tags project=openshift-local,source=github,org=${{ github.repository_owner}} \
58-
# --spot
59-
# # Check logs
60-
# podman logs -f windows-create
61-
62-
# - name: Check instance system info
63-
# run: |
64-
# ssh -i id_rsa \
65-
# -o StrictHostKeyChecking=no \
66-
# -o UserKnownHostsFile=/dev/null \
67-
# -o ServerAliveInterval=30 \
68-
# -o ServerAliveCountMax=1200 \
69-
# $(cat username)@$(cat host) "systeminfo"
70-
71-
# - name: Download installer
72-
# id: download-installer-artifact
73-
# uses: dawidd6/action-download-artifact@v2
74-
# with:
75-
# workflow: ${{ github.event.workflow_run.workflow_id }}
76-
# name: Windows Installer (windows-2022)
77-
78-
# - name: Install CRC on host
79-
# run: |
80-
# # id_rsa for the host should be in pwd
81-
82-
# HOST=$(cat host)
83-
# USER=$(cat username)
84-
# TARGET_FOLDER=crc-support
85-
# ASSET_FOLDER=/opt/crc-support
86-
# podman run --pull=always --rm -d --name crc-win-support \
87-
# -e TARGET_HOST=${HOST} \
88-
# -e TARGET_HOST_USERNAME=${USER} \
89-
# -e TARGET_HOST_KEY_PATH=/data/id_rsa \
90-
# -e TARGET_FOLDER=crc-support \
91-
# -e TARGET_CLEANUP='false' \
92-
# -e OUTPUT_FOLDER=/data \
93-
# -e DEBUG='true' \
94-
# -v ${PWD}:/data:z \
95-
# -v ${PWD}/crc-windows-installer.zip:${ASSET_FOLDER}/crc-windows-installer.zip:z \
96-
# quay.io/rhqp/crc-support:v0.0.4-windows ${TARGET_FOLDER}/run.ps1 \
97-
# -targetPath "/Users/${USER}/${TARGET_FOLDER}" \
98-
# -download 'false' \
99-
# -install 'true' \
100-
# -forceFresh 'false'
54+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \
55+
-d '{"state":${OUTCOME}, "description":${DESCRIPTION}, "context":${CONTEXT}, "target_url":${{ github.run_id }}}'
56+
57+
- name: Create instance
58+
run: |
59+
# Create instance
60+
podman run -d --name windows-create --rm \
61+
-v ${PWD}:/workspace:z \
62+
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
63+
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
64+
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
65+
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
66+
quay.io/rhqp/qenvs:v0.6.0 azure \
67+
windows create \
68+
--project-name 'windows-desktop' \
69+
--backed-url 'file:///workspace' \
70+
--conn-details-output '/workspace' \
71+
--windows-version '${{ matrix.windows-version }}' \
72+
--windows-featurepack '${{ matrix.windows-featurepack }}' \
73+
--vmsize 'Standard_D8s_v4' \
74+
--tags project=openshift-local,source=github,org=${{ github.repository_owner}} \
75+
--spot
76+
# Check logs
77+
podman logs -f windows-create
78+
79+
- name: Check instance system info
80+
run: |
81+
ssh -i id_rsa \
82+
-o StrictHostKeyChecking=no \
83+
-o UserKnownHostsFile=/dev/null \
84+
-o ServerAliveInterval=30 \
85+
-o ServerAliveCountMax=1200 \
86+
$(cat username)@$(cat host) "systeminfo"
87+
88+
- name: Download installer
89+
id: download-installer-artifact
90+
uses: dawidd6/action-download-artifact@v2
91+
with:
92+
workflow: ${{ github.event.workflow_run.workflow_id }}
93+
name: Windows Installer (windows-2022)
94+
95+
- name: Install CRC on host
96+
run: |
97+
# id_rsa for the host should be in pwd
98+
99+
HOST=$(cat host)
100+
USER=$(cat username)
101+
TARGET_FOLDER=crc-support
102+
ASSET_FOLDER=/opt/crc-support
103+
podman run --pull=always --rm -d --name crc-win-support \
104+
-e TARGET_HOST=${HOST} \
105+
-e TARGET_HOST_USERNAME=${USER} \
106+
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
107+
-e TARGET_FOLDER=crc-support \
108+
-e TARGET_CLEANUP='false' \
109+
-e OUTPUT_FOLDER=/data \
110+
-e DEBUG='true' \
111+
-v ${PWD}:/data:z \
112+
-v ${PWD}/crc-windows-installer.zip:${ASSET_FOLDER}/crc-windows-installer.zip:z \
113+
quay.io/rhqp/crc-support:v0.0.4-windows ${TARGET_FOLDER}/run.ps1 \
114+
-targetPath "/Users/${USER}/${TARGET_FOLDER}" \
115+
-download 'false' \
116+
-install 'true' \
117+
-forceFresh 'false'
101118
102-
# # Check logs
103-
# podman logs -f crc-win-support
104-
105-
# - name: Write pull-secret
106-
# env:
107-
# PULL_SECRET: ${{ secrets.PULL_SECRET }}
108-
# run: |
109-
# echo $PULL_SECRET > pull-secret
110-
111-
# - name: Download ID file
112-
# id: download-id-artifact
113-
# uses: dawidd6/action-download-artifact@v2
114-
# with:
115-
# workflow: ${{ github.event.workflow_run.workflow_id }}
116-
# name: id
117-
118-
# - name: Read ID value
119-
# id: id
120-
# uses: juliangruber/read-file-action@v1
121-
# with:
122-
# path: ./id.txt
123-
124-
# - name: Download e2e image
125-
# id: download-images-artifact
126-
# uses: dawidd6/action-download-artifact@v2
127-
# with:
128-
# workflow_conclusion: completed
129-
# workflow: build-tests.yml
130-
# name: crc-e2e-id${{ steps.id.outputs.content }}
131-
132-
# - name: Run CRC e2e
133-
# env:
134-
# ID: ${{ steps.id.outputs.content }}
135-
# run: |
136-
# # Get latest built
137-
# # curl -OL https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/release-info.json
138-
# # VERSION=$(jq -r '.version.crcVersion' release-info.json)
139-
140-
# # load crc-e2e image from tar file
141-
# podman load -i crc-e2e.tar
142-
143-
# mkdir output
144-
# # id_rsa for the host should be in pwd
119+
# Check logs
120+
podman logs -f crc-win-support
121+
122+
- name: Write pull-secret
123+
env:
124+
PULL_SECRET: ${{ secrets.PULL_SECRET }}
125+
run: |
126+
echo $PULL_SECRET > pull-secret
127+
128+
- name: Download e2e image
129+
id: download-images-artifact
130+
uses: dawidd6/action-download-artifact@v2
131+
with:
132+
workflow_conclusion: completed
133+
workflow: build-tests.yml
134+
name: crc-e2e-id${{ env.SHA }}
135+
136+
- name: Run CRC e2e
137+
run: |
138+
# Get latest build
139+
# curl -OL https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/release-info.json
140+
# VERSION=$(jq -r '.version.crcVersion' release-info.json)
141+
142+
# load crc-e2e image from tar file
143+
podman load -i crc-e2e.tar
144+
145+
mkdir output
146+
# id_rsa for the host should be in pwd
145147
146-
# HOST=$(cat host)
147-
# USER=$(cat username)
148-
# # platform tag is inferred from the image
149-
# E2E_TAGS="@minimal"
150-
# TARGET_FOLDER="crc-e2e"
151-
152-
# podman run --rm -d --name crc-e2e \
153-
# -e PLATFORM=windows \
154-
# -e TARGET_HOST=${HOST} \
155-
# -e TARGET_HOST_USERNAME=${USER} \
156-
# -e TARGET_HOST_KEY_PATH=/opt/crc/id_rsa \
157-
# -e PULL_SECRET_FILE_PATH=/opt/crc/pull-secret \
158-
# -e E2E_TAG_EXPRESSION=${E2E_TAGS} \
159-
# -v $PWD/pull-secret:/opt/crc/pull-secret:Z \
160-
# -v $PWD/output:/output:Z \
161-
# -v $PWD/id_rsa:/opt/crc/id_rsa:Z \
162-
# quay.io/crcont/crc-e2e:id-${ID} \
163-
# -targetFolder ${TARGET_FOLDER} \
164-
# -junitResultsPath ${TARGET_FOLDER}/junit
165-
166-
# # Check logs
167-
# podman logs -f crc-e2e
168-
169-
# - name: Test Report
170-
# uses: mikepenz/action-junit-report@v4
171-
# if: always() # always run even if the previous step fails
172-
# with:
173-
# fail_on_failure: true
174-
# include_passed: true
175-
# detailed_summary: true
176-
# require_tests: true
177-
# report_paths: '**/*.xml'
178-
179-
# - name: Upload e2e results
180-
# uses: actions/upload-artifact@v3
181-
# if: always()
182-
# with:
183-
# name: E2E-results-windows-${{ matrix.windows-version }}${{ matrix.windows-featurepack }}
184-
# path: |
185-
# **/*.xml
186-
# **/*.results
187-
# **/*.log
188-
189-
# - name: Destroy instance
190-
# if: always()
191-
# run: |
192-
# # Make sure lock is removed
193-
# rm -rf .pulumi/locks/*
148+
HOST=$(cat host)
149+
USER=$(cat username)
150+
# platform tag is inferred from the image
151+
E2E_TAGS="@minimal"
152+
TARGET_FOLDER="crc-e2e"
153+
154+
podman run --rm -d --name crc-e2e \
155+
-e PLATFORM=windows \
156+
-e TARGET_HOST=${HOST} \
157+
-e TARGET_HOST_USERNAME=${USER} \
158+
-e TARGET_HOST_KEY_PATH=/opt/crc/id_rsa \
159+
-e PULL_SECRET_FILE_PATH=/opt/crc/pull-secret \
160+
-e E2E_TAG_EXPRESSION=${E2E_TAGS} \
161+
-v $PWD/pull-secret:/opt/crc/pull-secret:Z \
162+
-v $PWD/output:/output:Z \
163+
-v $PWD/id_rsa:/opt/crc/id_rsa:Z \
164+
quay.io/crcont/crc-e2e:id-${{ env.SHA }} \
165+
-targetFolder ${TARGET_FOLDER} \
166+
-junitResultsPath ${TARGET_FOLDER}/junit
167+
168+
# Check logs
169+
podman logs -f crc-e2e
170+
171+
- name: Test Report
172+
id: test-report
173+
uses: mikepenz/action-junit-report@v4
174+
if: always() # always run even if the previous step fails
175+
with:
176+
fail_on_failure: true
177+
include_passed: true
178+
detailed_summary: true
179+
require_tests: true
180+
report_paths: '**/*.xml'
181+
182+
- name: Upload e2e results
183+
uses: actions/upload-artifact@v3
184+
if: always()
185+
with:
186+
name: E2E-results-windows-${{ matrix.windows-version }}${{ matrix.windows-featurepack }}
187+
path: |
188+
**/*.xml
189+
**/*.results
190+
**/*.log
191+
192+
- name: Update status of the PR check
193+
run: |
194+
195+
OUTCOME="success"
196+
if [[ ${{steps.test-report.outcome}} != "success"]]; then
197+
OUTCOME="failure";
198+
fi
199+
200+
DESCRIPTION="Finished e2e on Windows"
201+
CONTEXT="win-ci-e2e"
202+
203+
# post result to commit status
204+
curl -L -v \
205+
-X POST \
206+
-H "Accept: application/vnd.github+json" \
207+
-H "Authorization: Bearer ${{ github.token }}" \
208+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \
209+
-d '{"state":${OUTCOME}, "description":${DESCRIPTION}, "context":${CONTEXT}, "target_url":${{ github.run_id }}}'
210+
211+
- name: Destroy instance
212+
if: always()
213+
run: |
214+
# Make sure lock is removed
215+
rm -rf .pulumi/locks/*
194216
195-
# # Destroy instance
196-
# podman run -d --name windows-destroy --rm \
197-
# -v ${PWD}:/workspace:z \
198-
# -e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
199-
# -e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
200-
# -e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
201-
# -e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
202-
# quay.io/rhqp/qenvs:v0.6.0 azure \
203-
# windows destroy \
204-
# --project-name 'windows-desktop' \
205-
# --backed-url 'file:///workspace'
206-
# # Check logs
207-
# podman logs -f windows-destroy
217+
# Destroy instance
218+
podman run -d --name windows-destroy --rm \
219+
-v ${PWD}:/workspace:z \
220+
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
221+
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
222+
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
223+
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
224+
quay.io/rhqp/qenvs:v0.6.0 azure \
225+
windows destroy \
226+
--project-name 'windows-desktop' \
227+
--backed-url 'file:///workspace'
228+
# Check logs
229+
podman logs -f windows-destroy

0 commit comments

Comments
 (0)