Repository navigation
Conversation
…the job
GitLab Runner runs a job's before_script and script lines as one shell
script that starts with `set -eo pipefail`. A command before && on any
line but the last cannot fail the job (errexit passes over it), and a
line's `set` holds for the lines after it. Each line was judged as a
script of its own, so neither was seen.
after_script runs in a shell of its own, and GitLab ignores its exit
status: its commands are advisory ("in after_script, whose failure
GitLab ignores").
A `set` command is never reported itself: glib's scripts open with
`set -eux -o pipefail`, which runs before errexit is on.
Part of cpp-best-practices#334
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #340 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 299 299
Lines 18136 18151 +15
Branches 2086 2090 +4
=======================================
+ Hits 18092 18107 +15
Misses 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #334: the GitLab gap left by #338.
What changes
GitLab Runner runs a job's
before_scriptandscriptlines as one shell script that starts withset -eo pipefail. #338 judged each line as a script of its own, which missed two things:a && bon a line that isn't the last. Ifafails, errexit passes over it and the job goes on. On the last line, the failure ends the script with its status, so that line still counts.setcarries over. Aset +eon one line holds for the lines after it, so a later command followed by others cannot fail the job.Now the lines are judged in order.
maskedhas afollowedflag (more of the script comes after these commands) and a newafter()that returns the shell options a script'ssetcommands leave.after_scriptruns in a shell of its own, and GitLab ignores its exit status. Its commands are now advisory:in after_script, whose failure GitLab ignores. A job'sallow_failurestill wins, as before.A
setcommand is never reported itself. glib's repository scripts open withset -eux -o pipefail, which runs before errexit is on, and #338 reported thatsetas masked. Whatsetchanges is the shell's options; it is no step whose failure matters.On the corpus
On the five GitLab projects in the corpus (glib, cmake_template, cabal, kubespray, home-manager), no check result changes. The newly advisory commands, all of them correct, are:
after_scriptcleanup: log tarballs,vagrant destroy -f,tofu … destroy.ln -snf … && echo $TZ > /etc/timezonein the middle of a script.glib's
set -eux -o pipefaillines are no longer reported.Tests
GitLabTestsintests/test_masked_status.py: lines as one script, includingbefore_script;setacross lines;after_script.SequenceTests.test_a_set_command_is_never_reported.Gates: ruff, ruff format, mypy, lizard (30 lines), all 2,478 tests passing (13 expected failures), coverage 99% (100% on the changed files), 0 jscpd clones, strict self-validation. Snapshots are unchanged.
Not covered
PowerShell scripts, on Windows GitLab runners and in GitHub's
pwsh, still aren't judged.🤖 Generated with Claude Code
https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt