Skip to content

tools: do not swallow error in lint-nix workflow#62292

Open
aduh95 wants to merge 3 commits intonodejs:mainfrom
aduh95:lint-nix
Open

tools: do not swallow error in lint-nix workflow#62292
aduh95 wants to merge 3 commits intonodejs:mainfrom
aduh95:lint-nix

Conversation

@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Mar 17, 2026

The workflow is written in a way that if nix-shell fails without changing any local file, the error is swallowed. E.g. in https://github.com/nodejs/node/actions/runs/23114271551/job/67137410705, the linter fails with error: Build failed due to failed dependency but the workflow exits as green.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/actions

@nodejs-github-bot nodejs-github-bot added the meta Issues and PRs related to the general management of the project. label Mar 17, 2026
@aduh95 aduh95 requested a review from Renegade334 March 17, 2026 13:38
Copy link
Member

@Renegade334 Renegade334 left a comment

Choose a reason for hiding this comment

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

I guess the only thing is that this will separate the linter output from the red X step in the GHA viewer. The alternative would be something like

          ' || ( git --no-pager diff && false )

to keep it in the same step.

Comment on lines +159 to +160
- run: git --no-pager diff
if: ${{ failure() && steps.lint-step.conclusion == 'failure' }}
Copy link
Member

Choose a reason for hiding this comment

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

If we go with this approach, then for human readability, it might be helpful if this step had a name.

Comment on lines 155 to +157
nix-shell -I nixpkgs=./tools/nix/pkgs.nix -p 'nixfmt-tree' --run '
treefmt --quiet --ci
' || git --no-pager diff --exit-code
' && EXIT_CODE="$?" || EXIT_CODE="$?"
Copy link
Member

Choose a reason for hiding this comment

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

Nit:

Suggested change
nix-shell -I nixpkgs=./tools/nix/pkgs.nix -p 'nixfmt-tree' --run '
treefmt --quiet --ci
' || git --no-pager diff --exit-code
' && EXIT_CODE="$?" || EXIT_CODE="$?"
nix-shell -I nixpkgs=./tools/nix/pkgs.nix -p 'nixfmt-tree' --run 'treefmt --quiet --ci'
EXIT_CODE="$?"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That wouldn't work AFAICT, GitHub adds -e by default, see https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defaultsrunshell

We need the ||, or an explicit set +e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Issues and PRs related to the general management of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants