Skip to content

Commit

Permalink
gha: unify all windows artifacts builds into one workflow
Browse files Browse the repository at this point in the history
This helps circumvent multiple complications. One, windows-e2e
workflow does not need to wait for 2 workflows to finish (which is
hard for a workflow_run triggered workflow). Two, we do not need to
worry about matching the right artifacts from builder workflows with
the right workflow_run that needs them (formerly used commit sha to do
this). Third, the organization of workflows becomes logical: builder
that prepares artifacts, and tester that consumes them and runs tests.
  • Loading branch information
jsliacan authored and adrianriobo committed Feb 5, 2024
1 parent 24a6552 commit ee70757
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 113 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/build-tests.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/windows-artifacts.yml
@@ -0,0 +1,99 @@
name: Build Windows artifacts
on:
push:
branches:
- "main"
pull_request: {}

env:
IMAGE_NAME_E2E: crc-e2e
IMAGE_NAME_INTEGRATION: crc-integration

jobs:
build-installer:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-2022
go:
- '1.20'
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
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@v3
with:
name: Windows Installer (${{ matrix.os }})
path: "./out/windows-amd64/crc-windows-installer.zip"

build-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: |
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@v3
with:
name: ${{ env.IMAGE_NAME_E2E }}-gh
path: ${{ env.IMAGE_NAME_E2E }}.tar

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

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

- 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
- name: Upload integration image
uses: actions/upload-artifact@v3
with:
name: ${{ env.IMAGE_NAME_INTEGRATION }}-gh
path: ${{ env.IMAGE_NAME_INTEGRATION }}.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: Upload the GH context artifact
uses: actions/upload-artifact@v3
with:
name: gh_context
path: ./gh_context.json
11 changes: 4 additions & 7 deletions .github/workflows/windows-e2e.yml
Expand Up @@ -2,7 +2,7 @@ name: Windows e2e

on:
workflow_run:
workflows: [Build Windows installer]
workflows: [Build Windows artifacts]
types:
- completed

Expand Down Expand Up @@ -31,9 +31,6 @@ jobs:
run: |
set -xuo
# SHA used as ID to correlate artifacts between buld-tests, windows-installer, and windows-e2e workflows
echo "SHA=$(cat gh_context.json | jq -r '.sha')" >> "$GITHUB_ENV"
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
Expand Down Expand Up @@ -136,7 +133,7 @@ jobs:
with:
workflow_conclusion: completed
workflow: build-tests.yml
name: crc-e2e-id${{ env.SHA }}
name: crc-e2e-gh

- name: Run CRC e2e
run: |
Expand All @@ -163,7 +160,7 @@ jobs:
-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:id-${{ env.SHA }} \
quay.io/crcont/crc-e2e:gh \
-targetFolder ${TARGET_FOLDER} \
-junitResultsPath ${TARGET_FOLDER}/junit
Expand Down Expand Up @@ -229,4 +226,4 @@ jobs:
--project-name 'windows-desktop' \
--backed-url 'file:///workspace'
# Check logs
podman logs -f windows-destroy
podman logs -f windows-destroy
53 changes: 0 additions & 53 deletions .github/workflows/windows-installer.yml

This file was deleted.

0 comments on commit ee70757

Please sign in to comment.