Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gha: unify windows builds into one workflow and drop sha ID correlating #3974

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
@@ -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
56 changes: 26 additions & 30 deletions .github/workflows/windows-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Windows e2e

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

Expand All @@ -27,13 +27,24 @@ jobs:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: gh_context

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

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

- name: Add correlation variables to GITHUB_ENV
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 All @@ -49,7 +60,7 @@ jobs:

OUTCOME="pending"
DESCRIPTION="Running e2e on Windows"
CONTEXT="win-ci-e2e"
CONTEXT="ci/gh/e2e/windows-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}"

# post result to commit status
curl -L -v \
Expand All @@ -59,6 +70,12 @@ jobs:
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
Expand Down Expand Up @@ -90,13 +107,6 @@ jobs:
-o ServerAliveCountMax=1200 \
$(cat username)@$(cat host) "systeminfo"

- 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: Install CRC on host
run: |
# id_rsa for the host should be in pwd
Expand Down Expand Up @@ -124,20 +134,6 @@ jobs:
# Check logs
podman logs -f crc-win-support

- name: Write pull-secret
env:
PULL_SECRET: ${{ secrets.PULL_SECRET }}
run: |
echo $PULL_SECRET > pull-secret

- name: Download e2e image
id: download-images-artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow_conclusion: completed
workflow: build-tests.yml
name: crc-e2e-id${{ env.SHA }}

- name: Run CRC e2e
run: |
# load crc-e2e image from tar file
Expand All @@ -163,7 +159,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 @@ -200,8 +196,8 @@ jobs:
OUTCOME="failure";
fi

DESCRIPTION="Finished e2e on Windows"
CONTEXT="win-ci-e2e"
DESCRIPTION="Finished"
CONTEXT="ci/gh/e2e/windows-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}"

# post result to commit status
curl -L -v \
Expand Down Expand Up @@ -229,4 +225,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.

Loading