Skip to content

ci: resolve contrib repo SHA once for hermetic CI - #5625

Open
mwimpelberg28 wants to merge 4 commits into
open-telemetry:mainfrom
mwimpelberg28:infra/hermetic-contrib-sha
Open

mwimpelberg28 wants to merge 4 commits into
open-telemetry:mainfrom
mwimpelberg28:infra/hermetic-contrib-sha

Conversation

@mwimpelberg28

Copy link
Copy Markdown
Contributor

Summary

Fixes #4305.

CONTRIB_REPO_SHA was independently re-derived from a branch-name expression in four places (ci.yml, misc.yml, test.yml, lint.yml), always resolving to a branch name, not a pinned commit:

CONTRIB_REPO_SHA: ${{ github.event_name == 'pull_request' && (
    contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref ||
    contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref ||
    'main'
  ) || 'main' }}

Since each job re-evaluates this independently, jobs in the same CI run (or a re-run hours later) could end up checking out different contrib commits if contrib's target branch moved in between — not hermetic, and a likely contributor to flakiness like #4853.

This PR resolves the contrib branch to a concrete commit SHA once, in a new resolve-contrib-sha job in ci.yml (via git ls-remote), and passes that SHA down to misc, tests, and contrib via workflow_call inputs instead of each workflow recomputing its own branch-name expression.

While in there, I also removed CORE_REPO_SHA: main from misc.yml/lint.yml/test.yml — it was declared in each workflow's env: block but never actually referenced anywhere in .github/. The one meaningful use of CORE_REPO_SHA (passed to contrib's core_contrib_test.yml reusable workflow) was already correctly pinned to github.sha, so this only removes dead code. lint.yml also never used CONTRIB_REPO_SHA at all, so that's dropped there too.

Changes

  • .github/workflows/templates/ci.yml.j2: add resolve-contrib-sha job; wire its output into misc, tests, and contrib jobs via needs/with
  • .github/workflows/templates/misc.yml.j2 / test.yml.j2: accept contrib-repo-sha as a workflow_call input instead of recomputing it; drop unused CORE_REPO_SHA
  • .github/workflows/templates/lint.yml.j2: drop unused CORE_REPO_SHA / CONTRIB_REPO_SHA (neither is referenced anywhere in this workflow)
  • .github/workflows/{ci,misc,lint,test}.yml: regenerated via tox -e generate-workflows (no manual edits)

Test plan

  • tox -e generate-workflows regenerates the four .yml files with no diff beyond what the template changes produce (confirms templates and generated output stay in sync, matching the repo's own generate-workflows CI check)
  • All four regenerated workflow files parse as valid YAML
  • CI on this PR exercises the new resolve-contrib-sha job and downstream misc/tests/contrib jobs end-to-end

Note: this doesn't fully resolve #4853 (release-branch instrumentation mismatch) on its own — that likely needs a follow-up decision on what should happen when a release-branch PR's contrib ref doesn't have a matching instrumentation set. Left a note on that issue tracking it separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKP2UVjDuXMFBeNLGs6QqE

@mwimpelberg28
mwimpelberg28 requested a review from a team as a code owner September 4, 2026 23:36
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 4, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

mwimpelberg28 added a commit to mwimpelberg28/opentelemetry-python that referenced this pull request Sep 4, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKP2UVjDuXMFBeNLGs6QqE
CONTRIB_REPO_SHA was independently re-derived as a branch name (not a
pinned commit) in ci.yml, misc.yml, test.yml, and lint.yml, so different
jobs in the same CI run (or a later re-run) could end up testing against
different contrib commits if contrib's target branch moved in between.

Resolve the contrib branch to a concrete commit SHA once, in a new
resolve-contrib-sha job in ci.yml, and pass it down to misc/tests/contrib
via workflow_call inputs instead of recomputing it in each workflow.

Also drop CORE_REPO_SHA from misc.yml/lint.yml/test.yml: it was declared
in each workflow's env block but never actually referenced anywhere,
and lint.yml never used CONTRIB_REPO_SHA either, so both are removed
there. The contrib job in ci.yml already pins CORE_REPO_SHA correctly
via github.sha.

Fixes open-telemetry#4305

Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKP2UVjDuXMFBeNLGs6QqE
Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKP2UVjDuXMFBeNLGs6QqE
@mwimpelberg28
mwimpelberg28 force-pushed the infra/hermetic-contrib-sha branch from 1a5b9f0 to 4a3efae Compare September 4, 2026 23:43
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 5, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-09-17 22:24 UTC

Respond to 2 review items (e.g. link a commit, explain why not, ask a follow-up):

  • Inline threads: 1, 2
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@mwimpelberg28
mwimpelberg28 force-pushed the infra/hermetic-contrib-sha branch from ba066ac to f91cdb0 Compare September 10, 2026 12:57

@emdneto emdneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

some comments

# For PRs you can change the inner fallback ('main')
# For pushes you change the outer fallback ('main')
# The logic below is used during releases and depends on having an equivalent branch name in the contrib repo.
CONTRIB_REPO_SHA: {% raw %}${{ github.event_name == 'pull_request' && (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't we need CONTRIB_REPO_SHA in lint?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm pretty sure we use CONTRIB_REPO_SHA in tox.ini, otherwise, CI will fail during releases.

contrib-repo-sha: ${% raw %}{{ needs.resolve-contrib-sha.outputs.sha }}{% endraw %}
contrib:
needs: resolve-contrib-sha
uses: open-telemetry/opentelemetry-python-contrib/.github/workflows/core_contrib_test.yml@main

@emdneto emdneto Sep 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The major problem still this, where we can't pass a dynamic value for the reusable workflow

@emdneto emdneto moved this to Approved PRs that need fixes in Python PR digest Sep 10, 2026
@emdneto emdneto moved this from Approved PRs that need fixes to Reviewed PRs that need fixes in Python PR digest Sep 10, 2026
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Hi @mwimpelberg28 — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.

  • Replying is enough to hand it off — answer, explain why no change is needed, or ask a follow-up. The dashboard routes it onward once nothing on the list is waiting on you.
  • To hand it back for any other reason, including the dashboard getting this wrong, comment /dashboard route:reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

2 participants