Skip to content

Commit

Permalink
chore: add gh action to run e2e tests on Windows Desktops machines
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
  • Loading branch information
adrianriobo committed Jan 10, 2024
1 parent 710e0e6 commit 347bac1
Show file tree
Hide file tree
Showing 7 changed files with 390 additions and 0 deletions.
170 changes: 170 additions & 0 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: all

on:
push:
branches:
- "main"
pull_request: {}

env:
OCI_E2E_NAME: libhvee-e2e
CORRELATE: ${{ github.sha }}

jobs:
build-oci-e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:

- name: Check out repository code
uses: actions/checkout@v4

- name: Build and archive e2e image
# use github.sha as ID to correlate various workflows triggered by the same event
run: |
VERSION=${{ env.CORRELATE}} make build-oci-e2e
podman save -o ${{ env.OCI_E2E_NAME }}.tar quay.io/rhqp/${{ env.OCI_E2E_NAME}}:v${{ env.CORRELATE }}
- name: Upload e2e flat image as artifact
uses: actions/upload-artifact@v4
with:
name: libhvee-e2e-v${{ env.CORRELATE }}
path: libhvee-e2e.tar

build-executables:
runs-on: windows-2022
strategy:
fail-fast: false
steps:

- name: Check out repository code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.18'

- name: Build libhvee executables
run: make build

- name: Upload libhvee executables as artifact
uses: actions/upload-artifact@v4
with:
name: libhvee-v${{ env.CORRELATE }}
path: bin/*.exe

e2e-windows-destkop:
needs:
- build-oci-e2e
- build-executables
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
windows-version: ['10','11']
windows-featurepack: ['22h2-ent', '23h2-ent']
exclude:
- windows-version: '10'
windows-featurepack: '23h2-ent'
- windows-version: '11'
windows-featurepack: '22h2-ent'

steps:
- name: Create instance
run: |
# 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/rhqp/qenvs:v0.6.1 azure \
windows create \
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}' \
--backed-url azblob://qenvs-state/${{ github.sha }} \
--conn-details-output '/workspace' \
--windows-version '${{ matrix.windows-version }}' \
--windows-featurepack '${{ matrix.windows-featurepack }}' \
--tags org=containers,project=libhvee,origin=ghaction \
--spot
# Check logs
podman logs -f windows-create
- name: Check instance system info
run: |
ssh -i id_rsa \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o ServerAliveInterval=30 \
-o ServerAliveCountMax=1200 \
$(cat username)@$(cat host) "systeminfo"
- name: Download libhvee artifacts
id: download-libhvee-artifacts
uses: actions/download-artifact@v4

- name: Run libhvee e2e
run: |
# Load image from artifact
podman load -i libhvee-e2e-v${{ env.CORRELATE }}/libhvee-e2e.tar
# Run container
podman run --rm -d --name libhvee-e2e \
-v $PWD:/workspace:z \
-v $PWD/libhvee-v${{ env.CORRELATE }}/createvm.exe:/opt/libhvee-e2e/createvm.exe:z \
-v $PWD/libhvee-v${{ env.CORRELATE }}/dumpvms.exe:/opt/libhvee-e2e/dumpvms.exe:z \
-v $PWD/libhvee-v${{ env.CORRELATE }}/kvpctl.exe:/opt/libhvee-e2e/kvpctl.exe:z \
-v $PWD/libhvee-v${{ env.CORRELATE }}/updatevm.exe:/opt/libhvee-e2e/updatevm.exe:z \
-e PLATFORM=windows \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/workspace/id_rsa \
-e TARGET_FOLDER=libhvee-e2e \
-e TARGET_RESULTS=libhvee-e2e.xml \
-e OUTPUT_FOLDER=/workspace \
-e DEBUG=true \
quay.io/rhqp/libhvee-e2e:v${{ env.CORRELATE }} \
libhvee-e2e/run.ps1 \
-targetFolder libhvee-e2e \
-junitResultsFilename libhvee-e2e.xml
# Check logs
podman logs -f libhvee-e2e
- name: Evaluate libhvee e2e results
uses: mikepenz/action-junit-report@v4
with:
fail_on_failure: true
include_passed: true
detailed_summary: true
require_tests: true
report_paths: libhvee-e2e.xml

- name: Upload libhvee e2e results
uses: actions/upload-artifact@v4
with:
name: libhvee-e2e-${{ matrix.windows-version }}${{ matrix.windows-featurepack }}
path: libhvee-e2e.xml

- name: Destroy instance
if: always()
run: |
# Destroy instance
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/rhqp/qenvs:v0.6.1 azure \
windows destroy \
--project-name 'windows-desktop-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}' \
--backed-url azblob://qenvs-state/${{ github.sha }}
# Check logs
podman logs -f windows-destroy
56 changes: 56 additions & 0 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: builder

# on:
# push:
# branches:
# - "main"
# pull_request: {}

env:
OCI_E2E_NAME: libhvee-e2e

jobs:
build-oci-e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Build and archive e2e image
# use github.sha as ID to correlate various workflows triggered by the same event
run: |
VERSION=${{ github.sha }} make build-oci-e2e
podman save -o ${{ env.OCI_E2E_NAME }}.tar quay.io/rhqp/${{ env.OCI_E2E_NAME}}:v${{ github.sha }}
- name: Upload e2e flat image as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.OCI_E2E_NAME }}-v${{ github.sha }}
path: ${{ env.OCI_E2E_NAME }}.tar

build-executables:
runs-on: windows-2022
strategy:
fail-fast: false

steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.18'

- name: Build libhvee executables
run: make build

- name: Upload libhvee executables as artifact
uses: actions/upload-artifact@v3
with:
name: libhvee-v${{ github.sha }}
path: bin/*.exe

95 changes: 95 additions & 0 deletions .github/workflows/tester.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: tester

# TODO unconmment when moved to upstream
# on:
# workflow_run:
# workflows:
# - builder
# types:
# - completed

jobs:
e2e-windows-destkop:
# TODO remove When moved to upstream needs will be removed
# as job will be executed from a workflow_run
needs:
- build-oci-e2e
- build-executables
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
windows-version: ['10','11']
windows-featurepack: ['22h2-ent', '23h2-ent']
exclude:
- windows-version: '10'
windows-featurepack: '23h2-ent'
- windows-version: '11'
windows-featurepack: '22h2-ent'

steps:
# When moving to be executed on upstream we need to save the context
# to try match the ${{ github.sha }} or some other correlation value
- name: Create instance
run: |
# 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/rhqp/qenvs:v0.6.1 azure \
windows create \
--project-name 'windows-desktop' \
--backed-url azblob://qenvs-state/${{ github.sha }} \
--conn-details-output '/workspace' \
--windows-version '${{ matrix.windows-version }}' \
--windows-featurepack '${{ matrix.windows-featurepack }}' \
--tags org=containers,project=libhvee,origin=ghaction \
--spot
# Check logs
podman logs -f windows-create
- name: Check instance system info
run: |
ssh -i id_rsa \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o ServerAliveInterval=30 \
-o ServerAliveCountMax=1200 \
$(cat username)@$(cat host) "systeminfo"
- name: Download e2e flat image as artifact
id: download-images-artifact
uses: dawidd6/action-download-artifact@v3
with:
# workflow_conclusion: completed
# workflow: build-tests.yml
name: libhvee-e2e-v${{ github.sha }}

- name: Run libhvee e2e
run: |
# load libhvee-e2e image from tar file
podman load -i libhvee-e2e.tar
- name: Destroy instance
if: always()
run: |
# Destroy instance
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/rhqp/qenvs:v0.6.1 azure \
windows destroy \
--project-name 'windows-desktop' \
--backed-url azblob://qenvs-state/${{ github.sha }}
# Check logs
podman logs -f windows-destroy
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export GOOS=windows
export GOARCH=amd64
SRC = $(shell find . -type f -name '*.go')
VERSION ?= 0.0.1
IMG ?= quay.io/rhqp/libhvee-e2e:v${VERSION}
CONTAINER_MANAGER ?= podman

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

clean:
rm -rf bin

.PHONY: build-oci-e2e
build-oci-e2e:
${CONTAINER_MANAGER} build -t ${IMG} -f oci/e2e/Containerfile --build-arg=OS=${GOOS} --build-arg=ARCH=${GOARCH} .
29 changes: 29 additions & 0 deletions docs/e2e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# e2e

TBC

## Container

Build container image

```bash
make build-oci-e2e
```

Sample for running the container with e2e on remote target

```bash
podman run --rm -it --name libhvee-e2e \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=libhvee-e2e \
-e TARGET_RESULTS=libhvee-e2e.xml \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD:/data:z \
quay.io/rhqp/libhvee-e2e:v0.0.1 \
libhvee-e2e/run.ps1 \
-targetFolder libhvee-e2e \
-junitResultsFilename libhvee-e2e.xml
```
23 changes: 23 additions & 0 deletions oci/e2e/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

FROM registry.access.redhat.com/ubi9/go-toolset:1.18 as builder

COPY . .

ARG OS
ARG ARCH

RUN GOOS=${OS} GOARCH=${ARCH} go test -v test/e2e/*.go -c -o ./build/libhvee-e2e.exe

FROM quay.io/rhqp/deliverest:v0.0.3

ARG OS
ARG ARCH

ENV ASSETS_FOLDER=/opt/libhvee-e2e \
OS=${OS} \
ARCH=${ARCH}

# LABEL org.opencontainpoders.image.authors="Adrian Riobo<[email protected]>"

COPY --from=builder /opt/app-root/src/build/libhvee-e2e.exe ${ASSETS_FOLDER}/
COPY oci/e2e/run.ps1 ${ASSETS_FOLDER}/
Loading

0 comments on commit 347bac1

Please sign in to comment.