Skip to content

fix(ci): avoid pipefail in ci.yaml shell code - #2462

Closed
juenglin wants to merge 1 commit into
NVIDIA:mainfrom
juenglin:ci-shell-issue
Closed

fix(ci): avoid pipefail in ci.yaml shell code#2462
juenglin wants to merge 1 commit into
NVIDIA:mainfrom
juenglin:ci-shell-issue

Conversation

@juenglin

@juenglinjuenglin commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Issue: ci failures like this

The CI failure is a classic SIGPIPE + pipefail interaction.

The original code pipes gh api --paginate into head -1. Under bash -o pipefail
(set by the shell option in the step), when head -1 reads one line and exits, it
closes the pipe. gh api then receives SIGPIPE (exit 141), and pipefail propagates
that non-zero exit code through the command substitution, causing the step to fail
under set -e.

The fix avoids this by:

  1. Collecting all output into an array via mapfile (no pipe to break).
  2. Using || true to suppress any transient gh api exit code from the process substitution.
  3. Taking the first element with ${_tags[0]:-} instead of head -1.

@copy-pr-bot

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actionsgithub-actionsBot added the CI/CD CI/CD infrastructure label Jul 30, 2026
@juenglin
juenglin requested a review from mdboomJuly 30, 2026 22:54
@juenglinjuenglin added the bug Something isn't working label Jul 30, 2026
@juenglinjuenglin self-assigned this Jul 30, 2026
@juenglinjuenglin added this to the cuda.core next milestone Jul 30, 2026

@kkraus14kkraus14 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two small inline notes.

--jq '.[] | select(.name | startswith("cuda-core-v")) | .name' \
| head -1)"
mapfile -t _tags < <(gh api "repos/$GITHUB_REPOSITORY/tags" --paginate \
--jq '.[] | select(.name | startswith("cuda-core-v")) | .name' || true)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

|| true masks every gh api failure, and mapfile cannot propagate a process-substitution status. A later pagination failure can therefore let this job continue after selecting a partial result. Please capture the command output normally before taking its first line.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested shape:

tags="$(gh api "repos/$GITHUB_REPOSITORY/tags" --paginate \ --jq '.[] | select(.name | startswith("cuda-core-v")) | .name')"
tag="${tags%%$'\n'*}"

This consumes the output before selecting the first tag, avoids SIGPIPE, and keeps a gh api failure fatal under -e.

@@ -257,9 +257,9 @@ jobs:
# --paginate fetches all pages; jq outputs one name per line per page;
# head -1 takes the first (newest) match since GitHub returns tags

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This comment still says head -1 selects the tag. Please update it to describe selecting the first collected tag.

@kkraus14

Copy link
Copy Markdown
Collaborator

I think this is no longer needed after #2475?

@juenglinjuenglin closed this Aug 3, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't workingCI/CDCI/CD infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@juenglin@kkraus14