From bed3bf87d4e9a3df7665ee2bd975add9b46db0e6 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Mon, 27 Mar 2023 18:14:33 +0200 Subject: [PATCH] .yaml: use HEAD commit ref for PR builds Signed-off-by: Thilo Fromm --- .github/workflows/ci.yaml | 15 +++++++++++++++ .github/workflows/run-kola-tests.yaml | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0a27cf1a6d..a36e9df6de 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -76,6 +76,21 @@ jobs: fetch-depth: 0 submodules: true + # Hack alert: actions/checkout will check out the (disjunct) merge commit of a PR + # instead of its head commit. That commit is not connected to any branch. + # This causes breakage downstream e.g. when the devcontainer test wants to check out + # the ref in the scripts repo that corresponds to this build. + - name: If this is a PR build, use head commit instead of the merge commit + if: ${{ github.event.pull_request.head.sha }} + shell: bash + run: | + exec 2>&1 + set -x + set -euo pipefail + + git checkout ${{ github.event.pull_request.head.sha }} + git submodule update + - name: Set environment shell: bash run: | diff --git a/.github/workflows/run-kola-tests.yaml b/.github/workflows/run-kola-tests.yaml index 9f57223c13..482afda07b 100644 --- a/.github/workflows/run-kola-tests.yaml +++ b/.github/workflows/run-kola-tests.yaml @@ -60,6 +60,22 @@ jobs: fetch-depth: 0 submodules: true + # Hack alert: actions/checkout will check out the (disjunct) merge commit of a PR + # instead of its head commit. That commit is not connected to any branch. + # This is not technically necessary for the tests run but it is done to remain aligned + # with the ref. + - name: If this is a PR build, use head commit instead of the merge commit + if: ${{ github.event.pull_request.head.sha }} + shell: bash + run: | + exec 2>&1 + set -x + set -euo pipefail + + cd scripts + git checkout ${{ github.event.pull_request.head.sha }} + git submodule update + - name: Download binpkgs if: ${{ !inputs.workflow_run_id }} uses: actions/download-artifact@v3