Skip to content

ci(inspectcode): fix Run InspectCode step exit code 2 on Git Bash (Windows) - #250

Merged
Chris-Wolfgang merged 2 commits into
mainfrom
fix/inspectcode-sln-detection
Jul 14, 2026
Merged

ci(inspectcode): fix Run InspectCode step exit code 2 on Git Bash (Windows)#250
Chris-Wolfgang merged 2 commits into
mainfrom
fix/inspectcode-sln-detection

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Symptom

ReSharper InspectCode job on windows-latest exits with code 2 in the Run InspectCode step, with NO output between the ##[endgroup] and ##[error]Process completed with exit code 2 — a very fast failure that pre-empts the actual jb inspectcode call. Reproduced on PR #249's CI run.

Root cause

The step's first line under -e -o pipefail was:

SLN=$(ls *.slnx 2>/dev/null | head -n1)

On Git Bash for Windows (which is the shell after #248's runs-on: windows-latest switch), when there are no *.slnx files:

  • ls *.slnx 2>/dev/null — glob doesn't match, ls reports the literal to stderr (silenced), exits 2 ("misuse")
  • Piped to head -n1 — head returns 0 but pipefail carries ls's 2 through the pipe
  • Command substitution inside SLN=$(...) — under set -e + pipefail, the entire step exits 2 before the if [ -z ] fallback line even runs

On ubuntu-latest bash the same pattern happened to be tolerated (subtle differences in how set -e propagates through $() on GNU bash), so nobody caught this until we switched runners.

Fix

Replace the ls | head pipeline with a direct glob-iteration loop:

SLN=""
for candidate in *.slnx *.sln; do
  if [ -f "$candidate" ]; then
    SLN="$candidate"
    break
  fi
done

No pipes, no ls, no pipefail interaction. Uniform behavior across Ubuntu bash and Git Bash on Windows.

Protected file

Only .github/workflows/pr.yaml. Detect .NET Projects will fail as expected → admin-bypass required.

Fleet impact

Same fix needed on the 4 downstream repos where #248 landed (AuditTrail #202, ETL-SqlBulkCopy #154, System.Mail-Extensions #209, console-app-template #291) AND the 14 open chore/add-inspectcode fleet PRs that now carry the same buggy block. I'll fold this into the same fan-out mechanism used earlier once merged.

Copilot AI review requested due to automatic review settings July 14, 2026 01:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Windows/Git Bash-specific failure mode in the ReSharper InspectCode workflow step where set -e -o pipefail caused an early exit when no *.slnx file existed.

Changes:

  • Replaced ls | head solution discovery with a pipe-free glob-iteration loop over *.slnx then *.sln.
  • Added inline rationale documenting the Git Bash + pipefail interaction that produced exit code 2.

@Chris-Wolfgang
Chris-Wolfgang merged commit a721ae8 into main Jul 14, 2026
8 of 9 checks passed
@Chris-Wolfgang
Chris-Wolfgang deleted the fix/inspectcode-sln-detection branch July 14, 2026 02:10
Chris-Wolfgang added a commit that referenced this pull request Jul 14, 2026
…-035

docs(changelog): include #250 InspectCode SLN-detection fix in 0.3.5 entry
Chris-Wolfgang added a commit that referenced this pull request Jul 15, 2026
…fixes SC2012)

Same shellcheck / pipefail interaction I fixed in #250 for the InspectCode job's SLN detection: `ls *.snupkg 2>/dev/null | head -n1` under -e -o pipefail exits the step with code 2 when the glob doesn't match, before the `if [ -z ]` fallback runs; shellcheck also flags it as SC2012 ("Use find instead of ls").

Replaced with the direct glob-loop pattern established by #250 — no pipe, no pipefail interaction, no shellcheck complaint. Fails actionlint on the previous invocation.
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