Skip to content

feat: install Atmos from a branch or tag with --use-version=ref:<name>#2569

Merged
Andriy Knysh (aknysh) merged 4 commits into
mainfrom
osterman/baghdad-v4
Jun 5, 2026
Merged

feat: install Atmos from a branch or tag with --use-version=ref:<name>#2569
Andriy Knysh (aknysh) merged 4 commits into
mainfrom
osterman/baghdad-v4

Conversation

@osterman
Copy link
Copy Markdown
Member

@osterman Erik Osterman (Cloud Posse) (osterman) commented Jun 5, 2026

what

  • Add a ref:<name> version spec to --use-version (and version.use in atmos.yaml / ATMOS_USE_VERSION) that installs Atmos from the latest commit of a branch or tag, e.g. atmos --use-version=ref:main version.
  • Accepts branch names, tag names, and slash-qualified refs for disambiguation: ref:main, ref:release/v1.199, ref:v1.199.0, ref:heads/main, ref:tags/v1.199.0.
  • Resolves the ref to its full commit SHA via the GitHub API, then reuses the existing sha: install/cache path unchanged; ref versions always re-execute and fail hard on resolution errors.
  • Docs (version/use.mdx), a minor blog post, and a roadmap milestone.

why

  • Previously --use-version only accepted PR numbers (pr:1234), commit SHAs (sha:ceb7526), and releases — a branch name like main was rejected, even though branch/tag pushes already publish the same build-artifacts-* from the Tests workflow.
  • ref: lets you pin a moving target once (ref:main) instead of chasing a new sha: after every merge, making it trivial to test unreleased fixes on a branch.
  • The ref is re-resolved on every run so a mutable branch always tracks the latest build, while the SHA-keyed cache avoids reinstalling when the ref hasn't moved. Resolving to the full SHA also sidesteps GitHub's head_sha filter, which only matches full (not short) SHAs.

references

  • Docs: Version Pinning
  • Changelog: website/blog/2026-06-04-use-version-ref.mdx

Summary by CodeRabbit

  • New Features

    • Support for git branches/tags via --use-version=ref: (resolves refs to commit SHAs and uses existing artifact download/cache).
  • Behavior Changes

    • CI artifact selection now prefers the newest workflow run that contains the platform artifact (may pick in-progress or failed runs if they include the artifact).
    • Re-exec/version switching treats ref: like immutable versions (resolve → install/cache).
  • Bug Fixes

    • Clearer, user-friendly error when a ref does not exist (with actionable hints).
  • Documentation

    • Added CLI docs, blog post, and roadmap entry describing ref: usage and caching.

Add a `ref:` version spec to `--use-version` (and `version.use` /
ATMOS_USE_VERSION) that resolves a git branch or tag to its latest
commit's CI build artifact, e.g. `atmos --use-version=ref:main version`.

- pkg/toolchain/version_spec.go: new VersionTypeRef, `ref:` parsing,
  IsRefVersion, light ref validation
- pkg/github/artifacts.go: RepositoriesService + GetRefSHA resolves a
  ref to its full commit SHA via GetCommitSHA1 (regenerated mock)
- pkg/toolchain/ref_artifact.go: ResolveRef wrapper with friendly errors
- pkg/version/reexec.go: wire ResolveRef into ReexecConfig; ref always
  re-execs, resolves to a SHA, then reuses the existing SHA install/cache
  path, and fails hard on resolution errors
- docs, blog post, and roadmap milestone (minor)

The ref is re-resolved on every run so a mutable branch like `main`
tracks the latest build, while the SHA-keyed cache avoids reinstalling
when the ref has not moved. Resolving to the full SHA also sidesteps the
GitHub head_sha filter requiring a full (not short) SHA.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@atmos-pro
Copy link
Copy Markdown
Contributor

atmos-pro Bot commented Jun 5, 2026

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Jun 5, 2026
@github-actions github-actions Bot added the size/m Medium size PR label Jun 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a0b3d1bf-ef8a-4bb8-800f-6400c3ab5797

📥 Commits

Reviewing files that changed from the base of the PR and between 99a7f1e and 3228beb.

📒 Files selected for processing (4)
  • pkg/github/artifacts_test.go
  • pkg/toolchain/ref_artifact_test.go
  • pkg/toolchain/version_spec_test.go
  • pkg/version/reexec_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/toolchain/ref_artifact_test.go
  • pkg/toolchain/version_spec_test.go
  • pkg/version/reexec_test.go
  • pkg/github/artifacts_test.go

📝 Walkthrough

Walkthrough

Adds support for ref: version specs resolving git branches/tags to commit SHAs and reusing the existing SHA-based CI artifact install/cache flow. Changes cover GitHub ref lookup, artifact-run selection, version spec parsing, toolchain ref resolution and error mapping, re-exec wiring, tests, and docs.

Changes

Git ref-to-SHA resolution for --use-version flag

Layer / File(s) Summary
GitHub API ref-to-SHA resolution & artifact selection
pkg/github/artifacts.go, pkg/github/artifacts_test.go, pkg/github/mock_artifacts_test.go
Adds RepositoriesService and ArtifactFetcher.repositories; implements GetRefSHA/getRefSHA mapping GitHub 404 → ErrRefNotFound and erroring on empty SHA. Replaces completed-run selection with findRunWithArtifact to choose the newest Tests run that contains the platform artifact. Adds mocks and tests for artifact lookup and ref-to-SHA behavior.
Version spec parsing for ref: prefix
pkg/toolchain/version_spec.go, pkg/toolchain/version_spec_test.go
Adds VersionTypeRef, the ref: prefix parser (parseRefPrefix), IsRefVersion, and isValidRef validation (rejects empty/whitespace/control chars). Tests cover qualified and invalid ref forms.
Toolchain ref resolution and error mapping
pkg/toolchain/ref_artifact.go, pkg/toolchain/ref_artifact_test.go
ResolveRef calls github.GetRefSHA with perf logging. handleRefResolveError maps ErrRefNotFoundErrToolNotFound with helpful hints and GitHub URL; other errors → ErrToolInstall while preserving cause. Tests validate both mappings and error chain preservation.
Version re-exec flow integration
pkg/version/reexec.go, pkg/version/reexec_test.go
Adds RefResolver and ReexecConfig.ResolveRef (wired to toolchain.ResolveRef). Ensures ref: triggers re-exec (not skipped), routes VersionTypeRef to findOrInstallRefVersionWithConfig which resolves ref→SHA and reuses SHA cache/install flow. Tests validate cache hit/miss, fresh installs, error propagation, and SHA inputs bypassing ref resolution.
User documentation and roadmap
website/blog/2026-06-04-use-version-ref.mdx, website/docs/cli/configuration/version/use.mdx, website/src/data/roadmap.js
Adds blog post and CLI docs for ref: usage, examples, caching behavior, and guidance vs semver. Updates roadmap progress and adds milestone for branch/tag installation via ref:.

Sequence Diagram(s)

The hidden review stack above includes a sequence diagram that visualizes: GetRefSHA → RepositoriesService commit lookup (success / not-found / empty), and the artifact-run lookup flow that iterates newest-first Tests runs and checks artifacts per run.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • cloudposse/atmos#2223: Documentation and earlier work on version.use / --use-version pages related to supported version formats including the new ref: format.
  • cloudposse/atmos#2556: Related changes to re-exec/version selection paths that intersect with ResolveRef wiring and re-exec behavior.

Suggested reviewers

  • nitrocode
  • aknysh
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 65.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature: installing Atmos from branches/tags via the new ref: version specifier for --use-version.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/baghdad-v4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/github/artifacts.go`:
- Around line 117-121: The ArtifactFetcher struct's repositories field is not
being initialized in NewArtifactFetcher, causing GetRefSHA to nil-dereference;
update the constructor NewArtifactFetcher to accept and assign a
RepositoriesService (or pass an existing repositories dependency) into the
ArtifactFetcher.repositories field so any calls to GetRefSHA use a valid service
instance; ensure all constructor call sites that build ArtifactFetcher (and any
similar factory functions around lines referenced) are updated to provide the
repositories dependency.

In `@pkg/version/reexec.go`:
- Around line 450-454: The code calls cfg.ResolveRef unguarded in
findOrInstallRefVersionWithConfig which can panic if ResolveRef is nil on a
partial ReexecConfig; update findOrInstallRefVersionWithConfig to check cfg !=
nil and cfg.ResolveRef != nil before invoking ResolveRef, and if missing return
a clear typed error (e.g., ErrResolveRefUnavailable or a descriptive
install/config error) so callers get a proper error instead of a nil-func panic;
reference the findOrInstallRefVersionWithConfig function and the
ReexecConfig.ResolveRef field when making this change.

In `@website/src/data/roadmap.js`:
- Line 449: The shipped milestone object for "Branch and tag installation via
--use-version (ref:)" in website/src/data/roadmap.js is missing the required pr
metadata and the initiative progress needs updating; add a pr: <PR_NUMBER> field
to that milestone object (alongside existing status: 'shipped' and changelog:
'use-version-ref') and then update the corresponding initiative's progress
percentage to reflect this shipped item so the roadmap metadata contract is
satisfied.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fb56167f-9edc-4451-b902-e3ac411ff39c

📥 Commits

Reviewing files that changed from the base of the PR and between 860a0ec and 06c4c7f.

📒 Files selected for processing (12)
  • pkg/github/artifacts.go
  • pkg/github/artifacts_test.go
  • pkg/github/mock_artifacts_test.go
  • pkg/toolchain/ref_artifact.go
  • pkg/toolchain/ref_artifact_test.go
  • pkg/toolchain/version_spec.go
  • pkg/toolchain/version_spec_test.go
  • pkg/version/reexec.go
  • pkg/version/reexec_test.go
  • website/blog/2026-06-04-use-version-ref.mdx
  • website/docs/cli/configuration/version/use.mdx
  • website/src/data/roadmap.js

Comment thread pkg/github/artifacts.go
Comment thread pkg/version/reexec.go
Comment thread website/src/data/roadmap.js Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 83.49515% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.91%. Comparing base (860a0ec) to head (3228beb).

Files with missing lines Patch % Lines
pkg/github/artifacts.go 82.22% 7 Missing and 1 partial ⚠️
pkg/toolchain/ref_artifact.go 69.56% 7 Missing ⚠️
pkg/version/reexec.go 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2569      +/-   ##
==========================================
+ Coverage   78.87%   78.91%   +0.03%     
==========================================
  Files        1197     1198       +1     
  Lines      114715   114797      +82     
==========================================
+ Hits        90485    90594     +109     
+ Misses      19261    19235      -26     
+ Partials     4969     4968       -1     
Flag Coverage Δ
unittests 78.91% <83.49%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/toolchain/version_spec.go 94.05% <100.00%> (+1.46%) ⬆️
pkg/version/reexec.go 93.00% <86.66%> (-0.52%) ⬇️
pkg/toolchain/ref_artifact.go 69.56% <69.56%> (ø)
pkg/github/artifacts.go 82.17% <82.22%> (-1.53%) ⬇️

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add the pr reference to the shipped "Branch and tag installation via
--use-version (ref:)" roadmap milestone, per CodeRabbit review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… completes

`--use-version=pr:`, `sha:`, and `ref:` re-exec by downloading the Atmos
build artifact for a commit. The run finder filtered workflow runs on
`Status: "completed"`, but GitHub only marks the "Tests" run completed once
every job finishes — including the ~20-min acceptance-test matrix. So even
though the Build job had already uploaded the binary in ~6 min, the artifact
was invisible and install failed with "tool not found / CI build may be
failing".

Gate on artifact availability instead of run completion: replace
findCompletedWorkflowRun with findRunWithArtifact, which includes in-progress
runs and returns the most recent "Tests" run that actually has the platform
artifact uploaded (falling back to an older run on re-runs). One shared
finder fixes all three --use-version modes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added size/l Large size PR and removed size/m Medium size PR labels Jun 5, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 5, 2026
Document the ref:/sha: version-install test functions with godoc-style
summaries describing what each verifies, and promote a few inline comments
to doc comments. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@aknysh Andriy Knysh (aknysh) merged commit 3c0b3e5 into main Jun 5, 2026
59 checks passed
@aknysh Andriy Knysh (aknysh) deleted the osterman/baghdad-v4 branch June 5, 2026 15:34
@atmos-pro
Copy link
Copy Markdown
Contributor

atmos-pro Bot commented Jun 5, 2026

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

These changes were released in v1.221.0-rc.5.

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

Labels

minor New features that do not break anything size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants