Skip to content

feat(env): auto-detect 10 additional CI providers (PER-7828)#2194

Merged
pranavz28 merged 3 commits intomasterfrom
feat/per-7828-ci-provider-coverage
Apr 29, 2026
Merged

feat(env): auto-detect 10 additional CI providers (PER-7828)#2194
pranavz28 merged 3 commits intomasterfrom
feat/per-7828-ci-provider-coverage

Conversation

@pranavz28
Copy link
Copy Markdown
Contributor

@pranavz28 pranavz28 commented Apr 23, 2026

Summary

Expands Percy CLI's @percy/env package to auto-detect 12 additional CI providers (10 auto-detect + 2 opt-in): TeamCity, AWS CodeBuild, Google Cloud Build, Atlassian Bamboo, Bitrise, Codemagic, Vercel, Cloudflare Pages, GoCD, Woodpecker, Tekton Pipelines, and Argo Workflows.

Key decisions

  • 10 auto-detect providers set identifying env vars automatically at build time; detection is drop-in (just install @percy/cli in the build).
  • Tekton + Argo are opt-in — these Kubernetes-native systems don't inject provider-identifying env vars into user step containers. Users pass workflow metadata via template substitution:
    # Tekton
    env:
      - name: TEKTON_PIPELINE_RUN
        value: "$(context.pipelineRun.name)"
      - name: TEKTON_COMMIT_SHA
        value: "$(params.commit-sha)"
      - name: TEKTON_BRANCH
        value: "$(params.branch)"
    
    # Argo Workflows
    env:
      - name: ARGO_WORKFLOW_NAME
        value: "{{workflow.name}}"
      - name: ARGO_WORKFLOW_UID
        value: "{{workflow.uid}}"
      - name: ARGO_COMMIT_SHA
        value: "{{workflow.parameters.commit-sha}}"
      - name: ARGO_BRANCH
        value: "{{workflow.parameters.branch}}"

Testing

  • Unit: 123 specs pass (up from 115 previously). Added 9 new test cases across Tekton (4) and Argo Workflows (5), plus modified the Cloudflare Pages nonce assertion to reflect the fix below.

  • E2E: 9 providers verified by creating real Percy builds from each and asserting ci, commit-sha, branch, pull-request-number, parallel-nonce via Percy's admin API:

    Provider Percy build Result
    Vercel #49043427
    Cloudflare Pages #49044968 ✅ (after nonce fix below)
    Codemagic #49043984
    TeamCity #49043998
    Woodpecker #49044258
    Bamboo #49044512 ✅ (local env-inject — Bamboo Docker requires license+UI wizard)
    GoCD #49044542 ✅ (gocd-server+agent Docker confirmed env vars; percy step ran locally with agent-captured values)
    Tekton #49045007 ✅ (local env-inject — opt-in pattern)
    Argo Workflows #49045014 ✅ (local env-inject — opt-in pattern)
    AWS CodeBuild pending creds
    GCP Cloud Build pending creds
    Bitrise workspace out of credits (free tier) after 1 failed build; config verified

Bug found + fixed during E2E

The original Cloudflare Pages nonce formula ${CF_PAGES_COMMIT_SHA}-${CF_PAGES_URL} produced strings >64 chars. Percy's API rejects nonces over 64 chars, so build creation failed even though CI detection itself worked. Fixed to use CF_PAGES_COMMIT_SHA alone (40 chars, deterministic, gives correct rerun dedup).

Scope

  • packages/env/src/environment.js: add 12 providers + 1 nonce fix
  • packages/env/test/: 12 new test files (one per provider) + updated cloudflare-pages.test.js

Post-Deploy Monitoring & Validation

  • What to monitor
    • Logs: filter Percy API build-create logs by user-agent containing any of the 12 new CI slugs (teamcity, aws-codebuild, gcb, bamboo, bitrise, codemagic, vercel, cloudflare-pages, gocd, woodpecker, tekton, argo-workflows).
  • Validation checks
    • SELECT COUNT(*) FROM builds WHERE user_agent LIKE '%; vercel)%' AND created_at > NOW() - INTERVAL 24 HOUR; (and equivalent per provider).
  • Expected healthy
    • Builds from the new providers start landing within 48h with non-null commit_sha, branch, and parallel_nonce fields populated.
  • Failure signal / rollback trigger
    • Spike in Nonce is too long or Sha must be 40 hexadecimal characters build-create errors. If triggered, revert the two commits on feat/per-7828-ci-provider-coverage.
  • Validation window & owner

🤖 Generated with Claude Opus 4.7 (1M context) via Claude Code + Compound Engineering v2.50.0

Add detection plus commit/branch/PR/parallel-nonce extraction for:
TeamCity, AWS CodeBuild, Google Cloud Build, Atlassian Bamboo, Bitrise,
Codemagic, Vercel, Cloudflare Pages, GoCD, Woodpecker.

Detection ordering:
- Woodpecker placed before Drone (guards against pre-3.x Woodpecker
  installs that set DRONE=true for backwards compatibility).
- GCB placed last before the CI/unknown fallback because BUILD_ID +
  PROJECT_ID is the most generic marker; defensive !JENKINS_URL guard
  added.

Parallel-nonce rerun-stability choices:
- Bamboo uses bamboo_buildResultKey (includes build-N suffix) rather
  than bamboo_buildNumber (reused on rerun).
- Cloudflare Pages uses a composite \${commit}-\${url} nonce with a
  strict null-guard on commit SHA so we never emit "undefined".
- GoCD uses a composite \${pipeline}.\${stage} counter so stage reruns
  do not collide.

Each provider gets a dedicated test file covering detection, PR builds
(where applicable), edge cases (CodeBuild manual triggers, GCB manual
submits, Vercel system-env-vars-off, Woodpecker Drone-compat collision,
Jenkins-over-GCB precedence), and PERCY_* override precedence.

API side is a no-op: the 'source' field is free-form metadata with no
allowlist.

Tekton/Argo excluded — no standard git env vars.
Documentation for the 10 new providers (plus doc gaps for Harness,
Heroku CI, Probo.CI) ships in a follow-up PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pranavz28 pranavz28 requested a review from a team as a code owner April 23, 2026 05:51
pranavz28 and others added 2 commits April 23, 2026 23:31
E2E testing revealed the Cloudflare Pages composite nonce
(CF_PAGES_COMMIT_SHA-CF_PAGES_URL) exceeded Percy's 64-char
API limit, causing build creation to fail. Switched to
CF_PAGES_COMMIT_SHA alone — this also gives correct rerun
dedup behavior since the URL changes per redeploy.

Added opt-in detection for Tekton Pipelines and Argo Workflows.
Neither auto-injects identifying env vars into step containers,
so users set them via template substitution:

  # Tekton
  env:
    - name: TEKTON_PIPELINE_RUN
      value: "$(context.pipelineRun.name)"
    - name: TEKTON_COMMIT_SHA
      value: "$(params.commit-sha)"
    - name: TEKTON_BRANCH
      value: "$(params.branch)"

  # Argo Workflows
  env:
    - name: ARGO_WORKFLOW_NAME
      value: "{{workflow.name}}"
    - name: ARGO_WORKFLOW_UID
      value: "{{workflow.uid}}"
    - name: ARGO_COMMIT_SHA
      value: "{{workflow.parameters.commit-sha}}"
    - name: ARGO_BRANCH
      value: "{{workflow.parameters.branch}}"

🤖 Generated with Claude Opus 4.7 (1M context) via Claude Code
  + Compound Engineering v2.50.0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds README entries for the 10 auto-detect providers (TeamCity, AWS
CodeBuild, GCB, Bamboo, Bitrise, Codemagic, Vercel, Cloudflare Pages,
GoCD, Woodpecker), backfills Harness CI (was detected in code but
missing from the list), and documents the opt-in setup for Tekton
Pipelines and Argo Workflows with copy-paste YAML snippets.

Also calls out the Vercel System Env Vars + PERCY_PARALLEL_TOTAL=-1
requirement surfaced during E2E testing.

🤖 Generated with Claude Opus 4.7 (1M context) via Claude Code
  + Compound Engineering v2.50.0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pranavz28 pranavz28 merged commit 4ed5ac0 into master Apr 29, 2026
45 checks passed
@pranavz28 pranavz28 deleted the feat/per-7828-ci-provider-coverage branch April 29, 2026 09:52
@pranavz28 pranavz28 added the ✨ enhancement New feature or request label Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants