Repository navigation
fix: Describe Affected Detects Component File Changes. fix: Vendored components with source - #2003
Conversation
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
📝 WalkthroughWalkthroughThreaded a gitRepoRoot/basePath parameter through describe-affected code paths and updated component-folder resolution to use a fallback when component field is missing, plus extensive tests and docs to validate repo-root-relative path resolution and vendored-component detection. Changes are limited to parameter passing, path resolution, and tests. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@internal/exec/describe_affected_utils_test.go`:
- Around line 263-264: The inline comment "gitRepoRoot - empty for unit tests
with absolute paths" is missing a trailing period and fails golangci-lint godot;
update that inline comment (adjacent to the gitRepoRoot argument in the test for
describe_affected_utils_test) to end with a period so it reads e.g. "gitRepoRoot
- empty for unit tests with absolute paths." and similarly ensure any other
inline comments in the same test follow the same rule.
- Around line 483-484: Add a unit test case in describe_affected_utils_test.go
that passes a non-empty gitRepoRoot (e.g., "/repo/root" or use filepath.Join to
build a platform-safe path) and uses relative changedFiles (e.g.,
"pkg/foo/file.go", "./pkg/bar.go") to exercise the path-resolution branch; call
the same test helper that currently gets "" for gitRepoRoot and assert the
returned/processed file paths are resolved to absolute/combined paths (use
filepath.Join/gitRepoRoot + changedFile and filepath.Clean in the expected
values) so the test verifies the resolution logic for functions that accept
gitRepoRoot and changedFiles. Ensure the new case is added to the existing test
table (or a new test function) and uses filepath utilities for cross-platform
assertions.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2003 +/- ##
==========================================
+ Coverage 75.21% 75.26% +0.04%
==========================================
Files 785 785
Lines 72460 72479 +19
==========================================
+ Hits 54501 54551 +50
+ Misses 14473 14443 -30
+ Partials 3486 3485 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
source
sourcesource
Replace forward slash path concatenation with filepath.Join to fix Windows CI test failures due to path separator differences. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Document best practices for using filepath.Join in tests to prevent Windows CI failures due to path separator differences. Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@CLAUDE.md`:
- Line 361: The general compatibility guideline currently reads
"Linux/macOS/Windows compatible. Use SDKs over binaries." but dropped the
earlier advice to prefer filepath.Join(); restore it by editing that sentence to
read something like "Linux/macOS/Windows compatible — use SDKs over binaries and
use filepath.Join() instead of hardcoded path separators." Update the same
paragraph that contains the exact string "Linux/macOS/Windows compatible. Use
SDKs over binaries." so the general guidance matches the more specific test
section and references filepath.Join() explicitly.
|
CodeRabbit (@coderabbitai) full review please |
|
🧠 Learnings used✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal/exec/describe_affected_utils_test.go`:
- Around line 419-421: Update the outdated test comment: clarify why
ComponentPath is expected empty despite BuildComponentPath now accepting a
componentNameFallback (refer to BuildComponentPath and the test's usage where
affected[0].ComponentPath is asserted empty). Either document that this code
path intentionally does not pass a componentNameFallback (so fallback isn't
applied) or adjust the test to pass an explicit fallback; make the comment state
the exact reason (e.g., "no fallback passed in this code path, so ComponentPath
remains empty") and reference BuildComponentPath and affected[0].ComponentPath
for context.
|
🧠 Learnings used✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal/exec/describe_affected_utils_test.go`:
- Around line 342-543: The vendored-component path is left empty because
BuildComponentPath is called without the component name fallback; in the code
that sets affected.ComponentPath (call site in describe_affected_utils_2.go
around the findAffected logic), pass the componentName as the third/fallback
argument: BuildComponentPath(atmosConfig, componentSection,
affected.ComponentType, componentName) so BuildComponentPath can resolve a
fallback folder name for JIT-vendored components; then update the test in
internal/exec/describe_affected_utils_test.go (the "Should detect changes for
JIT vendored component with source - simple config" case) to assert the resolved
ComponentPath (the expected path under components/terraform/<componentName>)
instead of expecting it to be empty and adjust the comment accordingly.
🧹 Nitpick comments (1)
website/blog/2025-01-21-describe-affected-component-detection.mdx (1)
51-64: Consider mentioning vendored components withsource.The PR also fixes detection for vendored components using
sourcewithout an explicitcomponentfield. Might be worth a bullet point under "The command now correctly detects" for completeness, though optional.📝 Optional addition
The command now correctly detects: - Changes to component folders (Terraform, Helmfile, Packer) - Changes to individual files within components - Stack configuration changes (as before) +- Vendored components configured with `source` (even without an explicit `component` field)
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@internal/exec/describe_affected_optimizations_test.go`:
- Around line 1263-1267: The scenario comment block in the test (the lines
describing the simulated repo root, Atmos base path, and changed file) violates
golangci-lint’s godot rule because the lines don't end with periods; update
those comment lines in describe_affected_optimizations_test.go so each sentence
ends with a trailing period (e.g., add periods to the lines that start with "-
Git repo root is", "- Atmos base path is", and "- Changed file from git diff
is") to satisfy the lint rule.
In `@website/blog/2025-01-21-describe-affected-component-detection.mdx`:
- Around line 1-8: Update the post's filename and its frontmatter date from 2025
to 2026: rename
website/blog/2025-01-21-describe-affected-component-detection.mdx to
website/blog/2026-01-21-describe-affected-component-detection.mdx and change the
frontmatter date value (the "date:" field) from 2025-01-21T00:00:00.000Z to
2026-01-21T00:00:00.000Z so the file ordering matches the intended release
timeline.
In `@website/blog/2025-01-21-describe-affected-source-vendoring.mdx`:
- Around line 1-8: The frontmatter date and the filename are set to 2025-01-21
but the post is for the 2026 fix; update the frontmatter "date" value to
2026-01-21T00:00:00.000Z (or the correct 2026 timestamp) and rename the file
from 2025-01-21-describe-affected-source-vendoring.mdx to
2026-01-21-describe-affected-source-vendoring.mdx so the filename and the "date"
frontmatter remain consistent with the release timeline; verify the slug/title
remain unchanged.
♻️ Duplicate comments (1)
internal/exec/describe_affected_utils_test.go (1)
419-420: Update the ComponentPath comment to reflect current fallback behavior. The note says BuildComponentPath lacks fallback, but fallback exists; it’s this code path that doesn’t pass it.📝 Suggested fix
- // ComponentPath is empty because BuildComponentPath doesn't have component name fallback. + // ComponentPath is empty because this code path doesn't pass a component name fallback to BuildComponentPath.
🧹 Nitpick comments (1)
internal/exec/stack_utils_test.go (1)
189-226: Prefer a table‑driven test for these fallback scenarios.This trims duplication and matches the repo’s test style for multi‑case coverage.
♻️ Proposed refactor
func TestBuildComponentPathWithFallback(t *testing.T) { atmosConfig := schema.AtmosConfiguration{ BasePath: "/base", Components: schema.Components{ Terraform: schema.Terraform{ BasePath: "terraform", }, }, } - t.Run("uses fallback when component field is missing", func(t *testing.T) { - // Component with source (JIT vendoring) but no explicit component field. - componentSection := map[string]any{ - "source": map[string]any{"uri": "github.com/example/vpc"}, - "vars": map[string]any{"name": "test"}, - } - result := BuildComponentPath(&atmosConfig, &componentSection, cfg.TerraformComponentType, "vpc-sourced") - expected := string(filepath.Separator) + filepath.Join("base", "terraform", "vpc-sourced") - assert.Equal(t, expected, result) - }) - - t.Run("explicit component field takes precedence over fallback", func(t *testing.T) { - componentSection := map[string]any{ - "component": "vpc", - "vars": map[string]any{"name": "test"}, - } - result := BuildComponentPath(&atmosConfig, &componentSection, cfg.TerraformComponentType, "vpc-production") - expected := string(filepath.Separator) + filepath.Join("base", "terraform", "vpc") - assert.Equal(t, expected, result) - }) - - t.Run("returns empty when no component field and no fallback", func(t *testing.T) { - componentSection := map[string]any{ - "vars": map[string]any{"name": "test"}, - } - result := BuildComponentPath(&atmosConfig, &componentSection, cfg.TerraformComponentType) - assert.Equal(t, "", result) - }) + tests := []struct { + name string + componentSection map[string]any + fallback []string + expected string + }{ + { + name: "uses fallback when component field is missing", + componentSection: map[string]any{ + "source": map[string]any{"uri": "github.com/example/vpc"}, + "vars": map[string]any{"name": "test"}, + }, + fallback: []string{"vpc-sourced"}, + expected: filepath.Join("/base", "terraform", "vpc-sourced"), + }, + { + name: "explicit component field takes precedence over fallback", + componentSection: map[string]any{ + "component": "vpc", + "vars": map[string]any{"name": "test"}, + }, + fallback: []string{"vpc-production"}, + expected: filepath.Join("/base", "terraform", "vpc"), + }, + { + name: "returns empty when no component field and no fallback", + componentSection: map[string]any{ + "vars": map[string]any{"name": "test"}, + }, + expected: "", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := BuildComponentPath(&atmosConfig, &tt.componentSection, cfg.TerraformComponentType, tt.fallback...) + assert.Equal(t, tt.expected, result) + }) + } }As per coding guidelines.
|
These changes were released in v1.204.1-rc.4. |
what
atmos describe affectedto correctly detect component file changes (Terraform, Helmfile, Packer)gitRepoRootparameter to path resolution logic to properly resolve relative paths from git diffsourcefor vendoring (components without explicitcomponentfield)why
Issue 1: Git repo root path resolution
filepath.Abs()which resolves paths against the current working directoryatmos -C examples/demo-stacks), paths would not match, causing component changes to go undetectedIssue 2: Vendored components with
sourcesourcefor just-in-time vendoring were not being detectedcomponentfield to determine which folder to monitorcomponentfield is specifiedchanges
Path resolution fix
newChangedFilesIndex()now acceptsgitRepoRootparameterSource component detection fix
GetComponentFolder()helper instack_utils.goto consolidate component folder resolution logicBuildComponentPath()to accept optional fallback parameterprocessTerraformComponentsIndexed(),processHelmfileComponentsIndexed(),processPackerComponentsIndexed()now useGetComponentFolder()which defaults to component name whencomponentfield is missingsourcevendoring are properly trackedtest coverage
All three scenarios are covered by unit tests:
metadata.componentspecifiedTestFindAffectedComponentFolderChanges/explicit_component_field✓TestFindAffectedComponentFolderChanges/inherited_base_component✓TestGetComponentFolder/returns_explicit_component_field_when_set✓sourcespecified (JIT vendoring)TestFindAffectedComponentFolderChanges/JIT_vendored_component_with_source_-_simple_config✓TestFindAffectedComponentFolderChanges/JIT_vendored_component_with_source_-_full_config✓TestFindAffectedHelmfileAndPackerComponents/Helmfile_JIT_vendored_with_source✓TestFindAffectedHelmfileAndPackerComponents/Packer_JIT_vendored_with_source✓source+workdirspecifiedTestFindAffectedHelmfileAndPackerComponents/Terraform_with_source_and_workdir✓TestFindAffectedHelmfileAndPackerComponents/Helmfile_with_source_and_workdir✓TestFindAffectedHelmfileAndPackerComponents/Packer_with_source_and_workdir✓Resolution flow
metadata.component: mock→ Stack processing setscomponentSection["component"] = "mock"→GetComponentFolderuses that valuesourceonly → Nocomponentfield →GetComponentFolderfalls back to componentName (YAML key)source+workdir→ Same as 2 (see note below)Why
provision.workdirdoesn't affect folder resolutionFor
describe affected, the workdir configuration doesn't change how component folders are resolved because:Workdir is runtime-only: The
.workdir/directory is created at runtime when you runatmos terraform plan/apply. It's a temporary copy of the component files.Workdir is not tracked in git: The
.workdir/directory is in.gitignore. Changes to files in.workdir/don't appear ingit diff.describe affectedcompares git branches: It looks at what files changed between commits/branches. Since workdir files aren't tracked, the detection happens on the source files:components/terraform/<component>/source:components/terraform/<component-name>/(where files are vendored)When you modify vendored component files in
components/terraform/vpc-remote-workdir/,describe affecteddetects that change. The fact that at runtime those files get copied to.workdir/doesn't matter for change detection.references
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.