ci: energy-hardware fetches the run's own commit by its hash #669

Closed
dcharlot wants to merge 1 commit from ci/energy-hardware-fetch-by-sha into main

View file

@ -21,6 +21,12 @@ name: energy meters on real hardware
# The host has no Node, so there are no JavaScript actions: the source is
# fetched with plain git, and each workspace keeps its target directory in the
# runner's home between runs.
#
# The source is the run's own commit, fetched by its hash, not the branch it was
# pushed to. On a busy main the branch moves on while this run waits for the one
# linux-hw runner, and the push that moved it rarely touches the paths below, so
# no newer run of this workflow follows: a run that refused a moved branch tested
# nothing, and none after it did either.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@ -75,16 +81,15 @@ jobs:
shell: bash
run: |
set -euo pipefail
ref="${{ github.event_name == 'pull_request' && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}"
want="${{ github.event.pull_request.head.sha || github.sha }}"
rm -rf src && mkdir src && cd src
git init -q
git fetch -q --depth 1 http://100.64.224.0:3400/Transaction-Science/open-standards.git "$ref"
git fetch -q --depth 1 http://100.64.224.0:3400/Transaction-Science/open-standards.git "$want"
git checkout -q FETCH_HEAD
got="$(git rev-parse HEAD)"
echo "fetched $ref at $got"
echo "fetched ${{ github.ref }} at $got"
if [ "$got" != "$want" ]; then
echo "::error::$ref is at $got, not $want: it moved after this run started, and a newer run tests it"
echo "::error::asked the forge for $want and was given $got"
exit 1
fi
@ -166,16 +171,15 @@ jobs:
shell: bash
run: |
set -euo pipefail
ref="${{ github.event_name == 'pull_request' && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}"
want="${{ github.event.pull_request.head.sha || github.sha }}"
rm -rf src && mkdir src && cd src
git init -q
git fetch -q --depth 1 http://100.64.224.0:3400/Transaction-Science/open-standards.git "$ref"
git fetch -q --depth 1 http://100.64.224.0:3400/Transaction-Science/open-standards.git "$want"
git checkout -q FETCH_HEAD
got="$(git rev-parse HEAD)"
echo "fetched $ref at $got"
echo "fetched ${{ github.ref }} at $got"
if [ "$got" != "$want" ]; then
echo "::error::$ref is at $got, not $want: it moved after this run started, and a newer run tests it"
echo "::error::asked the forge for $want and was given $got"
exit 1
fi