Skip to content

fix(build-go-attest): capture git show failure before set -e aborts#79

Merged
CybotTM merged 1 commit intomainfrom
fix/auto-build-ts-set-e
Apr 21, 2026
Merged

fix(build-go-attest): capture git show failure before set -e aborts#79
CybotTM merged 1 commit intomainfrom
fix/auto-build-ts-set-e

Conversation

@CybotTM
Copy link
Copy Markdown
Member

@CybotTM CybotTM commented Apr 21, 2026

Copilot on #78:

  1. set -e short-circuit: BUILD_TS=$(git show …) under set -euo pipefail aborts before the custom ::error:: diagnostic runs. Wrap in if ! BUILD_TS=$(...); then so the non-zero exit is captured locally; merge stderr into stdout (2>&1) so git's actual error message appears in the annotation.
  2. fetch-depth wording: fetch-depth: 0 also produces a valid HEAD. Reword to 'fetch-depth 0 or >=1 both work'.

Copilot review on #78:

1. 'BUILD_TS=$(git show …)' under 'set -euo pipefail' aborts the
   script on git-show failure BEFORE the custom ::error:: diagnostic
   runs. Wrap in 'if ! BUILD_TS=$(...); then' so the non-zero exit
   is captured locally; stderr now merged into stdout via '2>&1' so
   the actual git error message appears in the annotation.

2. The error text claimed fetch-depth>=1 was required, but
   actions/checkout's fetch-depth: 0 (full history) also produces a
   valid HEAD. Reword to 'fetch-depth 0 or >=1 both work'.

Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de>
Copilot AI review requested due to automatic review settings April 21, 2026 05:02
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@CybotTM CybotTM merged commit 551d89e into main Apr 21, 2026
@CybotTM CybotTM deleted the fix/auto-build-ts-set-e branch April 21, 2026 05:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the reusable build-go-attest workflow to ensure auto-build-timestamp failures are surfaced with a custom GitHub Actions ::error:: annotation even under set -euo pipefail, and refines the guidance text around checkout history requirements.

Changes:

  • Wrap git show -s --format=%cI HEAD in an explicit failure-checking if ! ...; then ... exit 1 block to avoid set -e short-circuiting the custom diagnostic.
  • Reword the “empty build timestamp” error message to clarify that fetch-depth: 0 and fetch-depth >= 1 both produce a valid HEAD.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/build-go-attest.yml
CybotTM added a commit that referenced this pull request Apr 21, 2026
Copilot on [#79](#79):
merging stderr into stdout via `2>&1` meant that if `git show` exited 0
with a warning on stderr, `BUILD_TS` would contain that warning text —
the empty-string check would still pass, and the ldflag would assemble
with a non-timestamp value, breaking `go build` or shipping corrupted
metadata.

Drop the merge. `BUILD_TS` captures stdout only; git's stderr flows to
the Actions step log naturally. The `::error::` annotation points users
at 'the git error above' instead of inlining a potentially corrupted
string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants