BUILD-11297 Simplify CI_METRICS_ENABLED gate — strict 'true', no bash step#68
Conversation
541f4d9 to
facf38c
Compare
facf38c to
5674b1f
Compare
… step
Drop the dedicated `metrics-flag` shell step and check `env.CI_METRICS_ENABLED == 'true'` directly in the
`cache-metrics-prep` step's `if:` expression. This:
* Removes the bash 3.2 incompatibility that crashed macOS runners with `bad substitution` on `${RAW,,}`
(observed in SonarSource/sonar-dummy#592 Build macOS, run 26091741374), which also cascaded into a
template-validity error for downstream `build-maven` `if:` expressions.
* Removes the case-insensitive variant matching. Accepting only the literal `'true'` matches the convention
of the existing env vars in this action (`CACHE_BACKEND`, `CACHE_IMPORT_GITHUB`) and avoids the GHA-
expression equivalent of bash 4-only `${VAR,,}` (no `tolower` in GHA expressions).
* Eliminates the bash step entirely, so there's no portability surface to worry about across runner
platforms.
The `cache-metrics-prep` step's combined `if: runner.os == 'Linux' && env.CI_METRICS_ENABLED == 'true'`
keeps the Linux-only scope. The downstream `cache-metrics` step continues to chain on
`steps.cache-metrics-prep.outputs.prepared == 'true'`, so when the flag is unset or non-`true` the entire
metrics flow is skipped without warning, matching the pre-#62 behaviour for non-pilot consumers.
README updated to document the strict `true` requirement instead of "case-insensitive".
Surfaced during the BUILD-11297 pilot rollout on sonar-dummy.
5674b1f to
a8dcc86
Compare
|
|
SummaryProblem: The bash 4+ feature Solution: Eliminate the bash step entirely. Evaluate Scope of changes:
What reviewers should knowKey review points:
Testing impact: Vitest suite passes; CI/consumer dogfood (sonar-dummy macOS job) is the real validation.
|
There was a problem hiding this comment.
LGTM! ✅
Straightforward and correct fix. The removed metrics-flag step has no remaining references anywhere in the repo. The downstream "Emit cache metrics" step still chains on steps.cache-metrics-prep.outputs.prepared == 'true' (unchanged), keeping the fail-open behaviour intact. The env.CI_METRICS_ENABLED expression context is the same GHA env context that the old bash step already used (env: RAW: ${{ env.CI_METRICS_ENABLED }}), so variable resolution is equivalent — only the case-insensitivity is lost, which is intentional and fully documented. All "case-insensitive" language is consistently removed from the README with no stale mentions remaining.



Summary
Fix a regression introduced by #62 (BUILD-11294 — cache metrics): the
metrics-flagshell step crashed on macOS runners withbad substitutionbecause${VAR,,}lowercase substitution is bash 4+ only (Apple ships bash 3.2). The crash cascaded into a template-validity error for downstreambuild-mavenif:expressions in consumer workflows.Observed in: sonar-dummy#592 Build macOS, run 26091741374, step 5 line 884.
Fix
Drop the bash step entirely; check
env.CI_METRICS_ENABLED == 'true'directly in thecache-metrics-prepstep'sif:expression.'true'— matches the convention of the existing env vars in this action (CACHE_BACKEND,CACHE_IMPORT_GITHUB). The earlier case-insensitive logic (${VAR,,} == 'true'acceptingTrue/TRUE/true) was an artifact of bash 4 only; GHA expressions don't havetolower, so encoding the same semantic in YAML would require listing variants explicitly. Strict'true'is simpler and consistent.if: runner.os == 'Linux' && env.CI_METRICS_ENABLED == 'true'keeps the metrics flow Linux-only. The downstreamcache-metricsstep continues to chain onsteps.cache-metrics-prep.outputs.prepared == 'true', so when the flag is unset or non-'true'the entire pipeline is skipped without warning.Why ship this now (separate from M2 macOS compliance)
The metrics-flag bash step ran unconditionally on every consumer call to
gh-action_cache@master. On macOS, bash 3.2 errored on${RAW,,}regardless of whetherCI_METRICS_ENABLEDwas set — i.e. this broke the base cache flow on macOS for everyone, not just metrics-pilot repos. Restoring base-flow correctness is independent of (and prerequisite to) the M2 work that will add macOS metrics emission.Behavior on non-Linux after this fix
CI_METRICS_ENABLED=trueset, macOS/Windows runner: cache flow runs unchanged (as it did before BUILD-11294 Add cache-size-bytes output and pipeline runtime metrics JSON #62). No metrics emission, no JSON written, no crash. Matches the documented "Linux only" promise in the README.Test plan
action.yml,cache-metrics/action.yml≤ 140 colsRelated