Skip to content

Commit

Permalink
[qe] improve windows pr-checks / merges running integration, e2e in p…
Browse files Browse the repository at this point in the history
…arallel

Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
  • Loading branch information
adrianriobo authored and praveenkumar committed Apr 22, 2024
1 parent ae4e57f commit c188994
Show file tree
Hide file tree
Showing 3 changed files with 298 additions and 282 deletions.
128 changes: 63 additions & 65 deletions .github/workflows/windows-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,85 +23,83 @@ jobs:
strategy:
fail-fast: false
matrix:
os:
- windows-2022
go:
- '1.20'
os: ['windows-2022']
go: ['1.20']
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Set path for heat.exe and light.exe
run: echo "$WIX\\bin" >>$GITHUB_PATH
shell: bash
- name: Build Windows installer
run: make out/windows-amd64/crc-windows-installer.zip
- name: Upload windows installer artifact
uses: actions/upload-artifact@v4
with:
name: Windows Installer (${{ matrix.os }})
path: "./out/windows-amd64/crc-windows-installer.zip"
- name: Check out repository code
uses: actions/checkout@v4

build-e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: false
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Set path for heat.exe and light.exe
shell: bash
run: echo "$WIX\\bin" >>$GITHUB_PATH

steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Build Windows installer
run: make out/windows-amd64/crc-windows-installer.zip

- name: Build and archive e2e image
# use github.sha as ID to correlate various workflows triggered by the same event
run: |
CRC_E2E_IMG_VERSION=gh make containerized_e2e
podman save -o ${{ env.IMAGE_NAME_E2E }}.tar quay.io/crcont/${{ env.IMAGE_NAME_E2E}}:gh
- name: Upload e2e image
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME_E2E }}-gh
path: ${{ env.IMAGE_NAME_E2E }}.tar
- name: Upload windows installer artifact
uses: actions/upload-artifact@v4
with:
name: windows-installer
path: "./out/windows-amd64/crc-windows-installer.zip"

build-integration:
build-qe:
runs-on: ubuntu-latest
strategy:
fail-fast: false

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

- name: Build and archive integration image
# use github.sha as ID to correlate various workflows triggered by the same event
run: |
CRC_INTEGRATION_IMG_VERSION=gh make containerized_integration
podman save -o ${{ env.IMAGE_NAME_INTEGRATION }}.tar quay.io/crcont/${{ env.IMAGE_NAME_INTEGRATION }}:gh
matrix:
os: ['darwin','windows', 'linux']
arch: ['amd64', 'arm64']
exclude:
- arch: 'arm64'
os: 'windows'
- arch: 'arm64'
os: 'linux'

- name: Upload integration image
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME_INTEGRATION }}-gh
path: ${{ env.IMAGE_NAME_INTEGRATION }}.tar
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Build qe oci images ${{matrix.os}}-${{matrix.arch}}
run: |
# e2e
CRC_E2E_IMG_VERSION=gh ARCH=${{matrix.arch}} OS=${{matrix.os}} make containerized_e2e
podman save -o ${{ env.IMAGE_NAME_E2E }}-${{matrix.os}}-${{matrix.arch}}.tar \
quay.io/crcont/${{ env.IMAGE_NAME_E2E}}:gh-${{matrix.os}}-${{matrix.arch}}
# integration
CRC_INTEGRATION_IMG_VERSION=gh ARCH=${{matrix.arch}} OS=${{matrix.os}} make containerized_integration
podman save -o ${{ env.IMAGE_NAME_INTEGRATION }}-${{matrix.os}}-${{matrix.arch}}.tar \
quay.io/crcont/${{ env.IMAGE_NAME_INTEGRATION}}:gh-${{matrix.os}}-${{matrix.arch}}
- name: Upload e2e ${{matrix.os}}-${{matrix.arch}}
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME_E2E }}-${{matrix.os}}-${{matrix.arch}}
path: ${{ env.IMAGE_NAME_E2E }}-${{matrix.os}}-${{matrix.arch}}.tar

- name: Upload integration ${{matrix.os}}-${{matrix.arch}}
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME_INTEGRATION }}-${{matrix.os}}-${{matrix.arch}}
path: ${{ env.IMAGE_NAME_INTEGRATION }}-${{matrix.os}}-${{matrix.arch}}.tar

save-gh-context:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:

- name: Save the GH context in an artifact
shell: bash
env:
GH_CONTEXT: ${{ toJSON(github) }}
run: echo $GH_CONTEXT > gh_context.json
- name: Save the GH context in an artifact
env:
GH_CONTEXT: ${{ toJSON(github) }}
run: echo $GH_CONTEXT > gh_context.json

- name: Upload the GH context artifact
uses: actions/upload-artifact@v4
with:
name: gh_context
path: ./gh_context.json
- name: Upload the GH context artifact
uses: actions/upload-artifact@v4
with:
name: gh-context
path: gh_context.json
235 changes: 18 additions & 217 deletions .github/workflows/windows-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Windows e2e
name: tester-windows

on:
workflow_run:
Expand All @@ -7,222 +7,23 @@ on:
- completed

jobs:
windows:
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
windows-e2e-ocp:
uses: crc-org/crc/.github/workflows/windows-qe-tpl.yml@main
strategy:
fail-fast: false
matrix:
windows-version: ['11']
windows-featurepack: ['23h2-ent']

steps:

- name: Download GH context
id: download-gh-context-artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: gh_context

- name: Download e2e image
id: download-images-artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: crc-e2e-gh

- name: Download installer
id: download-installer-artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: Windows Installer (windows-2022)

- name: Add correlation variables to GITHUB_ENV
run: |
set -xuo
COMMIT_ID=$(cat gh_context.json | jq -r '.event.after')
# if this is a new PR, .event.after is empty, use .sha instead in that case
if [[ -z "$COMMIT_ID" ]]; then
COMMIT_ID=$(cat gh_context.json | jq -r '.sha')
fi
# COMMIT_SHA used to identify commit whose status needs to be set to reflect test results
echo "COMMIT_SHA=$COMMIT_ID" >> "$GITHUB_ENV"
- name: Add status to the PR check
run: |
set -xuo
OUTCOME="pending"
DESCRIPTION="Running e2e on Windows"
CONTEXT="ci/gh/e2e/windows-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}"
# post result to commit status
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 "{\"state\":\"${OUTCOME}\", \"description\":\"${DESCRIPTION}\", \"context\":\"${CONTEXT}\", \"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
- name: Write pull-secret
env:
PULL_SECRET: ${{ secrets.PULL_SECRET }}
run: |
echo $PULL_SECRET > pull-secret
- 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 }}' \
quay.io/rhqp/qenvs:v0.6.0 azure \
windows create \
--project-name 'windows-desktop' \
--backed-url 'file:///workspace' \
--conn-details-output '/workspace' \
--windows-version '${{ matrix.windows-version }}' \
--windows-featurepack '${{ matrix.windows-featurepack }}' \
--vmsize 'Standard_D8s_v4' \
--tags project=openshift-local,source=github,org=${{ github.repository_owner}} \
--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: Install CRC on host
run: |
# id_rsa for the host should be in pwd
HOST=$(cat host)
USER=$(cat username)
TARGET_FOLDER=crc-support
ASSET_FOLDER=/opt/crc-support
podman run --pull=always --rm -d --name crc-win-support \
-e TARGET_HOST=${HOST} \
-e TARGET_HOST_USERNAME=${USER} \
-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:${ASSET_FOLDER}/crc-windows-installer.zip:z \
quay.io/rhqp/crc-support:v0.0.4-windows ${TARGET_FOLDER}/run.ps1 \
-targetPath "/Users/${USER}/${TARGET_FOLDER}" \
-download 'false' \
-install 'true' \
-forceFresh 'false'
# Check logs
podman logs -f crc-win-support
- name: Run CRC e2e
run: |
# load crc-e2e image from tar file
podman load -i crc-e2e.tar
mkdir output
# id_rsa for the host should be in pwd
HOST=$(cat host)
USER=$(cat username)
# platform tag is inferred from the image
# empty runs the entire suite
E2E_TAGS=""
TARGET_FOLDER="crc-e2e"
podman run --rm -d --name crc-e2e \
-e PLATFORM=windows \
-e TARGET_HOST=${HOST} \
-e TARGET_HOST_USERNAME=${USER} \
-e TARGET_HOST_KEY_PATH=/opt/crc/id_rsa \
-e PULL_SECRET_FILE_PATH=/opt/crc/pull-secret \
-e E2E_TAG_EXPRESSION=${E2E_TAGS} \
-v $PWD/pull-secret:/opt/crc/pull-secret:Z \
-v $PWD/output:/output:Z \
-v $PWD/id_rsa:/opt/crc/id_rsa:Z \
quay.io/crcont/crc-e2e:gh \
-targetFolder ${TARGET_FOLDER} \
-junitResultsPath ${TARGET_FOLDER}/junit
# Check logs
podman logs -f crc-e2e
- name: Test Report
id: test-report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
fail_on_failure: true
include_passed: true
detailed_summary: true
require_tests: true
report_paths: '**/*.xml'

- name: Upload e2e results
uses: actions/upload-artifact@v4
if: always()
with:
name: E2E-results-windows-${{ matrix.windows-version }}${{ matrix.windows-featurepack }}
path: |
**/*.xml
**/*.results
**/*.log
- name: Update status of the PR check
if: always()
run: |
set -xuo
OUTCOME="success"
if [[ ${{steps.test-report.outcome}} != "success" ]]; then
OUTCOME="failure";
fi
DESCRIPTION="Finished"
CONTEXT="ci/gh/e2e/windows-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}"
# post result to commit status
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 "{\"state\":\"${OUTCOME}\", \"description\":\"${DESCRIPTION}\", \"context\":\"${CONTEXT}\", \"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
- name: Destroy instance
if: always()
run: |
# Make sure lock is removed
rm -rf .pulumi/locks/*
# 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 }}' \
quay.io/rhqp/qenvs:v0.6.0 azure \
windows destroy \
--project-name 'windows-desktop' \
--backed-url 'file:///workspace'
# Check logs
podman logs -f windows-destroy
qe-type: ['e2e','integration']
preset: ['openshift', 'microshift', 'all']
exclude:
- qe-type: 'e2e'
preset: 'all'
- qe-type: 'integration'
preset: 'openshift'
- qe-type: 'integration'
preset: 'microshift'
with:
trigger-workflow-id: ${{ github.event.workflow_run.workflow_id }}
qe-type: ${{matrix.qe-type}}
preset: ${{matrix.preset}}
secrets: inherit

Loading

0 comments on commit c188994

Please sign in to comment.