Skip to content

fix(ci-info): detect GitHub Actions before presence-only CI providers [SDK-7081] - #1154

Open
osho-20 wants to merge 1 commit into
masterfrom
fix/sdk-7081-ci-info-detection-order
Open

fix(ci-info): detect GitHub Actions before presence-only CI providers [SDK-7081]#1154
osho-20 wants to merge 1 commit into
masterfrom
fix/sdk-7081-ci-info-detection-order

Conversation

@osho-20

@osho-20 osho-20 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

SDK-7081 — TRA's Re-run control is missing on some of a customer's Cypress builds. obs-api computes the reRun flag per build and force-disables it when the build has no CI build_url; the TRA frontend greys the control off that flag.

In getCiInfo() (bin/helpers/helper.js) the Jenkins check runs first and matches on the mere presence of JENKINS_URL/JENKINS_HOME. On a self-hosted GitHub Actions runner with leftover Jenkins env vars (the customer runs runs-on: [self-hosted, ...]), the build is classified as Jenkins:

{"name": "Jenkins"}

build_url/job_name/build_number are all undefined (Jenkins vars like BUILD_URL aren't set), so the serialized ci_info reaches TestHub without a build_url → re-run permanently greyed for that build — even on the latest CLI.

Note: the customer's currently-affected workflows also pin pre-1.36.5 CLI versions (no GHA detection at all → ci_info: null, same gate). That part is resolved by upgrading the pins to ≥ 1.36.10; this PR closes the remaining variant that can hit current versions.

Fix

Move the GitHub Actions branch — keyed on the explicit GITHUB_ACTIONS === "true" marker — ahead of the presence-only providers. Explicit CI markers now win over incidental env leftovers.

Also: getGitMetaData() now returns after resolve({}) when no git directory is found, instead of falling through and attempting a second resolve.

Scope

Detection order only — every provider's returned fields are unchanged. Pure-Jenkins environments (no GITHUB_ACTIONS/GITHUB_RUN_ID) still resolve to Jenkins. Complements #1123 (SDK-6279), which fixed build_number in the same branch.

Verification

getCiInfo() under env-faithful GitHub Actions vars plus a leaked JENKINS_HOME=/var/lib/jenkins:

State Result
Before {"name":"Jenkins"} — no build_url → re-run greyed
After {"name":"GitHub Actions","build_url":".../actions/runs/27412345678","build_number":"27412345678"}
  • New unit tests in test/unit/bin/helpers/helper.js: GHA detection, the Jenkins-shadowing regression, pure Jenkins, no-CI — all pass.
  • Full suite: 693 passing / 16 failing — the 16 failures are pre-existing on master (verified identical with the change stashed).
  • End-to-end repro of the gate on real builds (identical suite + GHA env, only CLI version differs): TRA build xa9qkg059unqm0s76mshuadvsiphhdcfbqdafurc (ci_info: null, CLI 1.36.3) vs jl1fvypsbnpeq01viexykee0fdfnxlcye4kuctk3 (ci_info populated, CLI 1.36.13), confirmed via GET /ext/v1/builds/<uuid>.

Release

  • minor
  • patch

Release notes: Fixed CI detection so GitHub Actions builds on self-hosted runners with leftover Jenkins environment variables are correctly reported as GitHub Actions, restoring Test Observability's Re-run option for those builds.

🤖 Generated with Claude Code

… [SDK-7081]

getCiInfo() checked Jenkins first on mere presence of JENKINS_URL/
JENKINS_HOME, so a self-hosted GitHub Actions runner with leftover
Jenkins env vars was classified as Jenkins with build_url undefined.
obs-api force-disables the TRA Re-run control for builds without a CI
build_url, greying the button. Move the explicit GITHUB_ACTIONS check
ahead of the presence-only providers.

Also return after resolve({}) in getGitMetaData when no git directory
is found, instead of falling through.

Adds getCiInfo unit coverage: GHA detection, the Jenkins-shadowing
regression, pure Jenkins, and no-CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@osho-20
osho-20 requested a review from a team as a code owner July 27, 2026 13:17
@osho-20

osho-20 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

RUN_TESTS

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.

3 participants