From 5b21c043c257a80ab870feb6f8aa727deef86b08 Mon Sep 17 00:00:00 2001 From: Transaction Science Date: Fri, 6 Nov 2026 07:16:39 -0500 Subject: [PATCH] ci: energy-hardware fetches the run's own commit by its hash The two linux-hw jobs fetched the branch a run was started for and failed when it had moved, on the grounds that a newer run would test it. On main the push that moves the branch rarely touches this workflow's paths, so no newer run follows: the run after the merge of #650 and #651 waited behind the one linux-hw runner, main moved on two minutes before it started, and both jobs failed in five seconds having tested nothing. Fetching the commit by hash tests exactly what the run was started for; the forge serves any reachable commit that way, a pull request's head included. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/energy-hardware.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/energy-hardware.yml b/.github/workflows/energy-hardware.yml index 97efed37e..3d8e891c4 100644 --- a/.github/workflows/energy-hardware.yml +++ b/.github/workflows/energy-hardware.yml @@ -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 -- 2.54.0 (Apple Git-157)