Skip to content

Commit 347bac1

Browse files
committed
chore: add gh action to run e2e tests on Windows Desktops machines
Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
1 parent 710e0e6 commit 347bac1

File tree

7 files changed

+390
-0
lines changed

7 files changed

+390
-0
lines changed

.github/workflows/all.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: all
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request: {}
8+
9+
env:
10+
OCI_E2E_NAME: libhvee-e2e
11+
CORRELATE: ${{ github.sha }}
12+
13+
jobs:
14+
build-oci-e2e:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
steps:
19+
20+
- name: Check out repository code
21+
uses: actions/checkout@v4
22+
23+
- name: Build and archive e2e image
24+
# use github.sha as ID to correlate various workflows triggered by the same event
25+
run: |
26+
VERSION=${{ env.CORRELATE}} make build-oci-e2e
27+
podman save -o ${{ env.OCI_E2E_NAME }}.tar quay.io/rhqp/${{ env.OCI_E2E_NAME}}:v${{ env.CORRELATE }}
28+
29+
- name: Upload e2e flat image as artifact
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: libhvee-e2e-v${{ env.CORRELATE }}
33+
path: libhvee-e2e.tar
34+
35+
build-executables:
36+
runs-on: windows-2022
37+
strategy:
38+
fail-fast: false
39+
steps:
40+
41+
- name: Check out repository code
42+
uses: actions/checkout@v4
43+
44+
- name: Set up Go
45+
uses: actions/setup-go@v4
46+
with:
47+
go-version: '1.18'
48+
49+
- name: Build libhvee executables
50+
run: make build
51+
52+
- name: Upload libhvee executables as artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: libhvee-v${{ env.CORRELATE }}
56+
path: bin/*.exe
57+
58+
e2e-windows-destkop:
59+
needs:
60+
- build-oci-e2e
61+
- build-executables
62+
runs-on: ubuntu-latest
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
windows-version: ['10','11']
67+
windows-featurepack: ['22h2-ent', '23h2-ent']
68+
exclude:
69+
- windows-version: '10'
70+
windows-featurepack: '23h2-ent'
71+
- windows-version: '11'
72+
windows-featurepack: '22h2-ent'
73+
74+
steps:
75+
- name: Create instance
76+
run: |
77+
# Create instance
78+
podman run -d --name windows-create --rm \
79+
-v ${PWD}:/workspace:z \
80+
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
81+
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
82+
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
83+
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
84+
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
85+
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
86+
quay.io/rhqp/qenvs:v0.6.1 azure \
87+
windows create \
88+
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}' \
89+
--backed-url azblob://qenvs-state/${{ github.sha }} \
90+
--conn-details-output '/workspace' \
91+
--windows-version '${{ matrix.windows-version }}' \
92+
--windows-featurepack '${{ matrix.windows-featurepack }}' \
93+
--tags org=containers,project=libhvee,origin=ghaction \
94+
--spot
95+
# Check logs
96+
podman logs -f windows-create
97+
98+
- name: Check instance system info
99+
run: |
100+
ssh -i id_rsa \
101+
-o StrictHostKeyChecking=no \
102+
-o UserKnownHostsFile=/dev/null \
103+
-o ServerAliveInterval=30 \
104+
-o ServerAliveCountMax=1200 \
105+
$(cat username)@$(cat host) "systeminfo"
106+
107+
- name: Download libhvee artifacts
108+
id: download-libhvee-artifacts
109+
uses: actions/download-artifact@v4
110+
111+
- name: Run libhvee e2e
112+
run: |
113+
# Load image from artifact
114+
podman load -i libhvee-e2e-v${{ env.CORRELATE }}/libhvee-e2e.tar
115+
116+
# Run container
117+
podman run --rm -d --name libhvee-e2e \
118+
-v $PWD:/workspace:z \
119+
-v $PWD/libhvee-v${{ env.CORRELATE }}/createvm.exe:/opt/libhvee-e2e/createvm.exe:z \
120+
-v $PWD/libhvee-v${{ env.CORRELATE }}/dumpvms.exe:/opt/libhvee-e2e/dumpvms.exe:z \
121+
-v $PWD/libhvee-v${{ env.CORRELATE }}/kvpctl.exe:/opt/libhvee-e2e/kvpctl.exe:z \
122+
-v $PWD/libhvee-v${{ env.CORRELATE }}/updatevm.exe:/opt/libhvee-e2e/updatevm.exe:z \
123+
-e PLATFORM=windows \
124+
-e TARGET_HOST=$(cat host) \
125+
-e TARGET_HOST_USERNAME=$(cat username) \
126+
-e TARGET_HOST_KEY_PATH=/workspace/id_rsa \
127+
-e TARGET_FOLDER=libhvee-e2e \
128+
-e TARGET_RESULTS=libhvee-e2e.xml \
129+
-e OUTPUT_FOLDER=/workspace \
130+
-e DEBUG=true \
131+
quay.io/rhqp/libhvee-e2e:v${{ env.CORRELATE }} \
132+
libhvee-e2e/run.ps1 \
133+
-targetFolder libhvee-e2e \
134+
-junitResultsFilename libhvee-e2e.xml
135+
# Check logs
136+
podman logs -f libhvee-e2e
137+
138+
- name: Evaluate libhvee e2e results
139+
uses: mikepenz/action-junit-report@v4
140+
with:
141+
fail_on_failure: true
142+
include_passed: true
143+
detailed_summary: true
144+
require_tests: true
145+
report_paths: libhvee-e2e.xml
146+
147+
- name: Upload libhvee e2e results
148+
uses: actions/upload-artifact@v4
149+
with:
150+
name: libhvee-e2e-${{ matrix.windows-version }}${{ matrix.windows-featurepack }}
151+
path: libhvee-e2e.xml
152+
153+
- name: Destroy instance
154+
if: always()
155+
run: |
156+
# Destroy instance
157+
podman run -d --name windows-destroy --rm \
158+
-v ${PWD}:/workspace:z \
159+
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
160+
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
161+
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
162+
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
163+
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
164+
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
165+
quay.io/rhqp/qenvs:v0.6.1 azure \
166+
windows destroy \
167+
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}' \
168+
--backed-url azblob://qenvs-state/${{ github.sha }}
169+
# Check logs
170+
podman logs -f windows-destroy

.github/workflows/builder.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: builder
2+
3+
# on:
4+
# push:
5+
# branches:
6+
# - "main"
7+
# pull_request: {}
8+
9+
env:
10+
OCI_E2E_NAME: libhvee-e2e
11+
12+
jobs:
13+
build-oci-e2e:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
18+
steps:
19+
- name: Check out repository code
20+
uses: actions/checkout@v3
21+
22+
- name: Build and archive e2e image
23+
# use github.sha as ID to correlate various workflows triggered by the same event
24+
run: |
25+
VERSION=${{ github.sha }} make build-oci-e2e
26+
podman save -o ${{ env.OCI_E2E_NAME }}.tar quay.io/rhqp/${{ env.OCI_E2E_NAME}}:v${{ github.sha }}
27+
28+
- name: Upload e2e flat image as artifact
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: ${{ env.OCI_E2E_NAME }}-v${{ github.sha }}
32+
path: ${{ env.OCI_E2E_NAME }}.tar
33+
34+
build-executables:
35+
runs-on: windows-2022
36+
strategy:
37+
fail-fast: false
38+
39+
steps:
40+
- name: Check out repository code
41+
uses: actions/checkout@v3
42+
43+
- name: Set up Go
44+
uses: actions/setup-go@v4
45+
with:
46+
go-version: '1.18'
47+
48+
- name: Build libhvee executables
49+
run: make build
50+
51+
- name: Upload libhvee executables as artifact
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: libhvee-v${{ github.sha }}
55+
path: bin/*.exe
56+

.github/workflows/tester.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: tester
2+
3+
# TODO unconmment when moved to upstream
4+
# on:
5+
# workflow_run:
6+
# workflows:
7+
# - builder
8+
# types:
9+
# - completed
10+
11+
jobs:
12+
e2e-windows-destkop:
13+
# TODO remove When moved to upstream needs will be removed
14+
# as job will be executed from a workflow_run
15+
needs:
16+
- build-oci-e2e
17+
- build-executables
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
windows-version: ['10','11']
23+
windows-featurepack: ['22h2-ent', '23h2-ent']
24+
exclude:
25+
- windows-version: '10'
26+
windows-featurepack: '23h2-ent'
27+
- windows-version: '11'
28+
windows-featurepack: '22h2-ent'
29+
30+
steps:
31+
# When moving to be executed on upstream we need to save the context
32+
# to try match the ${{ github.sha }} or some other correlation value
33+
- name: Create instance
34+
run: |
35+
# Create instance
36+
podman run -d --name windows-create --rm \
37+
-v ${PWD}:/workspace:z \
38+
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
39+
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
40+
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
41+
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
42+
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
43+
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
44+
quay.io/rhqp/qenvs:v0.6.1 azure \
45+
windows create \
46+
--project-name 'windows-desktop' \
47+
--backed-url azblob://qenvs-state/${{ github.sha }} \
48+
--conn-details-output '/workspace' \
49+
--windows-version '${{ matrix.windows-version }}' \
50+
--windows-featurepack '${{ matrix.windows-featurepack }}' \
51+
--tags org=containers,project=libhvee,origin=ghaction \
52+
--spot
53+
# Check logs
54+
podman logs -f windows-create
55+
56+
- name: Check instance system info
57+
run: |
58+
ssh -i id_rsa \
59+
-o StrictHostKeyChecking=no \
60+
-o UserKnownHostsFile=/dev/null \
61+
-o ServerAliveInterval=30 \
62+
-o ServerAliveCountMax=1200 \
63+
$(cat username)@$(cat host) "systeminfo"
64+
65+
- name: Download e2e flat image as artifact
66+
id: download-images-artifact
67+
uses: dawidd6/action-download-artifact@v3
68+
with:
69+
# workflow_conclusion: completed
70+
# workflow: build-tests.yml
71+
name: libhvee-e2e-v${{ github.sha }}
72+
73+
- name: Run libhvee e2e
74+
run: |
75+
# load libhvee-e2e image from tar file
76+
podman load -i libhvee-e2e.tar
77+
78+
- name: Destroy instance
79+
if: always()
80+
run: |
81+
# Destroy instance
82+
podman run -d --name windows-destroy --rm \
83+
-v ${PWD}:/workspace:z \
84+
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
85+
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
86+
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
87+
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
88+
-e AZURE_STORAGE_ACCOUNT='${{ secrets.AZURE_STORAGE_ACCOUNT }}' \
89+
-e AZURE_STORAGE_KEY='${{ secrets.AZURE_STORAGE_KEY }}' \
90+
quay.io/rhqp/qenvs:v0.6.1 azure \
91+
windows destroy \
92+
--project-name 'windows-desktop' \
93+
--backed-url azblob://qenvs-state/${{ github.sha }}
94+
# Check logs
95+
podman logs -f windows-destroy

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export GOOS=windows
22
export GOARCH=amd64
33
SRC = $(shell find . -type f -name '*.go')
4+
VERSION ?= 0.0.1
5+
IMG ?= quay.io/rhqp/libhvee-e2e:v${VERSION}
6+
CONTAINER_MANAGER ?= podman
47

58
.PHONY: default
69
default: build
@@ -37,3 +40,7 @@ bin/updatevm.exe: $(SRC) go.mod go.sum
3740

3841
clean:
3942
rm -rf bin
43+
44+
.PHONY: build-oci-e2e
45+
build-oci-e2e:
46+
${CONTAINER_MANAGER} build -t ${IMG} -f oci/e2e/Containerfile --build-arg=OS=${GOOS} --build-arg=ARCH=${GOARCH} .

docs/e2e.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# e2e
2+
3+
TBC
4+
5+
## Container
6+
7+
Build container image
8+
9+
```bash
10+
make build-oci-e2e
11+
```
12+
13+
Sample for running the container with e2e on remote target
14+
15+
```bash
16+
podman run --rm -it --name libhvee-e2e \
17+
-e TARGET_HOST=$(cat host) \
18+
-e TARGET_HOST_USERNAME=$(cat username) \
19+
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
20+
-e TARGET_FOLDER=libhvee-e2e \
21+
-e TARGET_RESULTS=libhvee-e2e.xml \
22+
-e OUTPUT_FOLDER=/data \
23+
-e DEBUG=true \
24+
-v $PWD:/data:z \
25+
quay.io/rhqp/libhvee-e2e:v0.0.1 \
26+
libhvee-e2e/run.ps1 \
27+
-targetFolder libhvee-e2e \
28+
-junitResultsFilename libhvee-e2e.xml
29+
```

oci/e2e/Containerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
FROM registry.access.redhat.com/ubi9/go-toolset:1.18 as builder
3+
4+
COPY . .
5+
6+
ARG OS
7+
ARG ARCH
8+
9+
RUN GOOS=${OS} GOARCH=${ARCH} go test -v test/e2e/*.go -c -o ./build/libhvee-e2e.exe
10+
11+
FROM quay.io/rhqp/deliverest:v0.0.3
12+
13+
ARG OS
14+
ARG ARCH
15+
16+
ENV ASSETS_FOLDER=/opt/libhvee-e2e \
17+
OS=${OS} \
18+
ARCH=${ARCH}
19+
20+
# LABEL org.opencontainpoders.image.authors="Adrian Riobo<[email protected]>"
21+
22+
COPY --from=builder /opt/app-root/src/build/libhvee-e2e.exe ${ASSETS_FOLDER}/
23+
COPY oci/e2e/run.ps1 ${ASSETS_FOLDER}/

0 commit comments

Comments
 (0)