Skip to content

BUILD-11444 Drop Resolve CI metrics gate step; read CI_METRICS_ENABLED directly#81

Open
julien-carsique-sonarsource wants to merge 1 commit into
masterfrom
feat/jcarsique/BUILD-11444-github-env-gate
Open

BUILD-11444 Drop Resolve CI metrics gate step; read CI_METRICS_ENABLED directly#81
julien-carsique-sonarsource wants to merge 1 commit into
masterfrom
feat/jcarsique/BUILD-11444-github-env-gate

Conversation

@julien-carsique-sonarsource
Copy link
Copy Markdown
Contributor

Summary

The pre-job runner hook now writes CI_METRICS_ENABLED=<true|false> to $GITHUB_ENV. This action no longer needs to read/write ${CI_METRICS_DIR}/enabled to communicate the decision between the pre-job hook, workflow steps, and post-job hook.

Changes:

  • Remove the entire Resolve CI metrics gate step (37 lines dropped)
  • Change cache-metrics-prep if: from steps.ci-metrics-gate.outputs.decision == 'true'env.CI_METRICS_ENABLED == 'true'
  • CI_METRICS_DIR is still used by the cache-metrics sub-action for writing cache-*.json files

Why: eliminates the dual-source-of-truth problem (env var + file) and the risk of a stale enabled file from a previous job on the same runner. Simpler, fewer moving parts.

Companion PRs

  • github-runners-infraPR #416: hooks write to / read from $GITHUB_ENV
  • ci-github-actionsPR #286: same gate replacement in ci-metrics/job-completed.sh
  • ci-ami-imagesPR #384: WarpBuild job-started.sh + promote summary

Test plan

  • E2E validation on sonar-dummy dev runner using ci-github-actions/cache@<this-branch> (temp PR)
  • Confirm cache-*.json files still emitted when CI_METRICS_ENABLED=true

…D directly

The pre-job hook now writes CI_METRICS_ENABLED=<true|false> to $GITHUB_ENV,
so the action no longer needs to read/write ${CI_METRICS_DIR}/enabled to
communicate the decision to the post-job hook.

- Remove the "Resolve CI metrics gate" step entirely (37 lines)
- Change cache-metrics-prep `if:` from `steps.ci-metrics-gate.outputs.decision == 'true'`
  to `env.CI_METRICS_ENABLED == 'true'`

Companion changes: github-runners-infra PR #416, ci-github-actions PR #286,
ci-ami-images PR #384.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 5, 2026

@sonarqube-cloud-us
Copy link
Copy Markdown

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Jun 5, 2026

CI failed: The CI failures were caused by the removal of the 'Resolve CI metrics gate' step, which left downstream test and validation scripts unable to find expected outputs like 'cache-size-bytes' or properly honor the 'CI_METRICS_ENABLED' flag.

Overview

Three distinct test and build failures occurred across the suite, all directly resulting from the removal of the 'Resolve CI metrics gate' step in action.yml. The build and test logic still rely on outputs and state files previously managed by that step, leading to missing variable errors and incorrect gate evaluation.

Failures

Missing 'cache-size-bytes' output (confidence: high)

  • Type: build
  • Affected jobs: 79763088292
  • Related to change: yes
  • Root cause: Downstream validation logic expects 'cache-size-bytes' to be populated, but since the generating step was removed, the variable is empty.
  • Suggested fix: Update the validation logic to gracefully handle an empty 'cache-size-bytes' or remove the dependency on this output if it is no longer relevant.

Metrics gate not honoring opt-out (confidence: high)

  • Type: test
  • Affected jobs: 79763088180
  • Related to change: yes
  • Root cause: Despite CI_METRICS_ENABLED=false, the system still created/detected metrics-related files, indicating that underlying scripts are not correctly checking the environment variable.
  • Suggested fix: Ensure all scripts/sub-actions that generate or manage /tmp/ci-metrics/ state are actively checking CI_METRICS_ENABLED and cleaning up existing state if disabled.

Metrics decision file test failure (confidence: high)

  • Type: test
  • Affected jobs: 79763210215
  • Related to change: yes
  • Root cause: The test suite specifically asserts behavior on the metrics gate step, which no longer exists in the workflow definition.
  • Suggested fix: Refactor these test cases to validate the direct usage of the CI_METRICS_ENABLED environment variable rather than checking for the existence/output of the removed step.

Summary

  • Change-related failures: 3 (all failures stem from incomplete migration after removing the gate step).
  • Infrastructure/flaky failures: 0.
  • Recommended action: The developer needs to perform a comprehensive cleanup of all downstream dependencies on the removed gate step. This includes updating test assertions, output variable checks, and ensuring that any logic that previously depended on the step now correctly evaluates the CI_METRICS_ENABLED environment variable directly.
Code Review 👍 Approved with suggestions 0 resolved / 1 findings

Simplifies CI metrics gating by reading CI_METRICS_ENABLED directly from the environment instead of a file. Please update the README to reflect the removal of the file-based metrics gate.

💡 Quality: README still documents the dropped file-based metrics gate

📄 action.yml:247-249

This PR removes the Resolve CI metrics gate step and changes cache-metrics-prep to gate purely on env.CI_METRICS_ENABLED == 'true', with the runner pre-job hook now writing CI_METRICS_ENABLED to $GITHUB_ENV. The README's ### Pipeline runtime metrics / **Gate resolution** section still describes the old behavior that no longer exists in the action:

  • Item 3 ("Otherwise, on iff ${CI_METRICS_DIR}/enabled exists") — the action no longer reads this decision file; the gate is now env-only.
  • The paragraph stating the action "propagates the workflow CI_METRICS_ENABLED override to the same file (touch on 'true', remove on 'false')" — that propagation step was deleted.
  • The CI_METRICS_DIR env table row still says the directory holds "the runner-side decision file (enabled)"; CI_METRICS_DIR is now only used for the per-invocation cache-*.json files.

This leaves the docs contradicting actual behavior, which can mislead workflow authors (e.g. expecting that touching ${CI_METRICS_DIR}/enabled enables metrics). Update the Gate resolution section to reflect that the gate is now simply CI_METRICS_ENABLED (set directly or via the runner hook writing to $GITHUB_ENV), and drop the decision-file and propagation language.

🤖 Prompt for agents
Code Review: Simplifies CI metrics gating by reading CI_METRICS_ENABLED directly from the environment instead of a file. Please update the README to reflect the removal of the file-based metrics gate.

1. 💡 Quality: README still documents the dropped file-based metrics gate
   Files: action.yml:247-249

   This PR removes the `Resolve CI metrics gate` step and changes `cache-metrics-prep` to gate purely on `env.CI_METRICS_ENABLED == 'true'`, with the runner pre-job hook now writing `CI_METRICS_ENABLED` to `$GITHUB_ENV`. The README's `### Pipeline runtime metrics` / `**Gate resolution**` section still describes the old behavior that no longer exists in the action:
   
   - Item 3 ("Otherwise, on iff `${CI_METRICS_DIR}/enabled` exists") — the action no longer reads this decision file; the gate is now env-only.
   - The paragraph stating the action "propagates the workflow `CI_METRICS_ENABLED` override to the same file (touch on 'true', remove on 'false')" — that propagation step was deleted.
   - The `CI_METRICS_DIR` env table row still says the directory holds "the runner-side decision file (`enabled`)"; `CI_METRICS_DIR` is now only used for the per-invocation `cache-*.json` files.
   
   This leaves the docs contradicting actual behavior, which can mislead workflow authors (e.g. expecting that touching `${CI_METRICS_DIR}/enabled` enables metrics). Update the Gate resolution section to reflect that the gate is now simply `CI_METRICS_ENABLED` (set directly or via the runner hook writing to `$GITHUB_ENV`), and drop the decision-file and propagation language.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Comment thread action.yml
Comment on lines 247 to +249
- name: Prepare local cache-metrics sub-action
id: cache-metrics-prep
if: steps.ci-metrics-gate.outputs.decision == 'true'
if: env.CI_METRICS_ENABLED == 'true'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Quality: README still documents the dropped file-based metrics gate

This PR removes the Resolve CI metrics gate step and changes cache-metrics-prep to gate purely on env.CI_METRICS_ENABLED == 'true', with the runner pre-job hook now writing CI_METRICS_ENABLED to $GITHUB_ENV. The README's ### Pipeline runtime metrics / **Gate resolution** section still describes the old behavior that no longer exists in the action:

  • Item 3 ("Otherwise, on iff ${CI_METRICS_DIR}/enabled exists") — the action no longer reads this decision file; the gate is now env-only.
  • The paragraph stating the action "propagates the workflow CI_METRICS_ENABLED override to the same file (touch on 'true', remove on 'false')" — that propagation step was deleted.
  • The CI_METRICS_DIR env table row still says the directory holds "the runner-side decision file (enabled)"; CI_METRICS_DIR is now only used for the per-invocation cache-*.json files.

This leaves the docs contradicting actual behavior, which can mislead workflow authors (e.g. expecting that touching ${CI_METRICS_DIR}/enabled enables metrics). Update the Gate resolution section to reflect that the gate is now simply CI_METRICS_ENABLED (set directly or via the runner hook writing to $GITHUB_ENV), and drop the decision-file and propagation language.

Was this helpful? React with 👍 / 👎

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.

1 participant