Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: consider untracked/uncommitted in the change detector. #1904

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

i4ki
Copy link
Contributor

@i4ki i4ki commented Oct 7, 2024

What this PR does / why we need it:

This is a breaking change

This change considers untracked and uncommitted files in the change detection.
It means terramate list --changed will show stacks changed by uncommitted or untracked files in the index. The terramate run safeguards will continue to kick in but the user can disable the git safeguards and in this case commands can run in dirty stacks.

Which issue(s) this PR fixes:

Closes #1398

Special notes for your reviewer:

Does this PR introduce a user-facing change?

yes, it's a breaking change that needs documentation!

Copy link

github-actions bot commented Oct 7, 2024

2024/10/09 17:35:24 Terraform detected version: 1.9.7
toolsetPath: /tmp/cmd-terramate-test-2208512536
=== RUN   TestInteropCloudSyncPreview
=== RUN   TestInteropCloudSyncPreview/preview:_basic-drift
    interoperability_test.go:46: using GITHUB_EVENT_FILE=/home/runner/work/_temp/_github_workflow/event.json
=== RUN   TestInteropCloudSyncPreview/preview:_basic-drift-uppercase-id
    interoperability_test.go:46: using GITHUB_EVENT_FILE=/home/runner/work/_temp/_github_workflow/event.json
--- PASS: TestInteropCloudSyncPreview (11.95s)
    --- PASS: TestInteropCloudSyncPreview/preview:_basic-drift (6.28s)
    --- PASS: TestInteropCloudSyncPreview/preview:_basic-drift-uppercase-id (5.66s)
=== RUN   TestInteropSyncDeployment
=== RUN   TestInteropSyncDeployment/deployment:_empty
=== RUN   TestInteropSyncDeployment/deployment:_empty-uppercase-id
--- PASS: TestInteropSyncDeployment (38.46s)
    --- PASS: TestInteropSyncDeployment/deployment:_empty (19.71s)
    --- PASS: TestInteropSyncDeployment/deployment:_empty-uppercase-id (18.75s)
=== RUN   TestInteropDrift
=== RUN   TestInteropDrift/drift:_basic-drift
=== RUN   TestInteropDrift/drift:_basic-drift-uppercase-id
--- PASS: TestInteropDrift (63.14s)
    --- PASS: TestInteropDrift/drift:_basic-drift (31.65s)
    --- PASS: TestInteropDrift/drift:_basic-drift-uppercase-id (31.49s)
PASS
ok  	github.com/terramate-io/terramate/e2etests/cloud/interop	123.937s

Copy link

github-actions bot commented Oct 7, 2024

Preview of ubuntu-focal/go1.21 tests in dce1450

🔍 View Details on Terramate Cloud

.
benchmarks/changed
cmd/terramate/cli
config
git
hcl
stack
e2etests/core

Copy link

github-actions bot commented Oct 7, 2024

Preview of macos-ventura/go1.21 tests in dce1450

🔍 View Details on Terramate Cloud

.
benchmarks/changed
cmd/terramate/cli
config
git
hcl
stack
e2etests/core

Copy link

github-actions bot commented Oct 7, 2024

metric: time/op
ChangeDetection-4: old 3.43ms ± 6%: new 3.49ms ± 6%: delta: 0.00%
ChangeDetectionTFAndTG-4: old 13.5ms ± 3%: new 13.5ms ± 3%: delta: 0.00%
CloudReadLines-4: old 1.05ms ± 4%: new 1.04ms ± 4%: delta: 0.00%
CloudReadLine-4: old 7.35ms ± 2%: new 7.29ms ± 2%: delta: -0.84%
ListFiles-4: old 82.2µs ± 1%: new 81.6µs ± 2%: delta: -0.64%
Generate-4: old 5.14s ± 1%: new 5.17s ± 2%: delta: 0.00%
GenerateRegex-4: old 3.47s ± 2%: new 3.45s ± 2%: delta: 0.00%
TokensForExpressionComplex-4: old 1.26ms ± 1%: new 1.28ms ± 1%: delta: 0.98%
TokensForExpressionPlainStringNoNewline-4: old 794ns ± 1%: new 795ns ± 1%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 24.1µs ± 2%: new 24.1µs ± 3%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 1.46ms ± 0%: new 1.46ms ± 1%: delta: 0.00%
TokensForExpression-4: old 1.27ms ± 0%: new 1.27ms ± 1%: delta: 0.00%
PartialEvalComplex-4: old 529µs ± 2%: new 530µs ± 2%: delta: 0.00%
PartialEvalSmallString-4: old 3.79µs ± 1%: new 3.78µs ± 1%: delta: 0.00%
PartialEvalHugeString-4: old 1.92ms ± 1%: new 1.92ms ± 0%: delta: -0.22%
PartialEvalHugeInterpolatedString-4: old 4.86ms ± 4%: new 4.79ms ± 2%: delta: -1.44%
PartialEvalObject-4: old 25.7µs ± 4%: new 25.4µs ± 3%: delta: -1.43%
TmAllTrueLiteralList-4: old 625µs ± 2%: new 635µs ± 2%: delta: 1.49%
TmAllTrueFuncall-4: old 20.8µs ± 3%: new 20.9µs ± 3%: delta: 0.00%
TmAnyTrueLiteralList-4: old 4.90ms ± 2%: new 4.93ms ± 2%: delta: 0.52%
TmAnyTrueFuncall-4: old 21.0µs ± 2%: new 21.2µs ± 3%: delta: 0.00%
TmTernary-4: old 2.62µs ± 1%: new 2.60µs ± 1%: delta: -1.00%
TmTryUnknownFunc-4: old 2.31µs ± 2%: new 2.29µs ± 1%: delta: -0.98%
TmTryUnknownVariable-4: old 2.21µs ± 1%: new 2.20µs ± 3%: delta: -0.28%
TmTryUnknownObjectKey-4: old 2.55µs ± 2%: new 2.52µs ± 2%: delta: -1.16%
metric: alloc/op
ChangeDetection-4: old 204kB ± 0%: new 204kB ± 0%: delta: 0.00%
ChangeDetectionTFAndTG-4: old 4.80MB ± 0%: new 4.80MB ± 0%: delta: 0.00%
CloudReadLines-4: old 3.12MB ± 0%: new 3.12MB ± 0%: delta: 0.00%
CloudReadLine-4: old 3.37MB ± 0%: new 3.37MB ± 0%: delta: 0.00%
ListFiles-4: old 27.6kB ± 0%: new 27.6kB ± 0%: delta: 0.00%
Generate-4: old 4.47GB ± 0%: new 4.47GB ± 0%: delta: 0.00%
GenerateRegex-4: old 1.84GB ± 0%: new 1.84GB ± 0%: delta: 0.00%
TokensForExpressionComplex-4: old 394kB ± 0%: new 395kB ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 512B ± 0%: new 512B ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 12.5kB ± 0%: new 12.5kB ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 395kB ± 0%: new 395kB ± 0%: delta: 0.00%
TokensForExpression-4: old 395kB ± 0%: new 394kB ± 0%: delta: 0.00%
PartialEvalComplex-4: old 338kB ± 0%: new 338kB ± 0%: delta: 0.00%
PartialEvalSmallString-4: old 1.74kB ± 0%: new 1.74kB ± 0%: delta: 0.00%
PartialEvalHugeString-4: old 196kB ± 0%: new 196kB ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-4: old 4.05MB ± 0%: new 4.05MB ± 0%: delta: 0.00%
PartialEvalObject-4: old 17.2kB ± 0%: new 17.2kB ± 0%: delta: 0.00%
TmAllTrueLiteralList-4: old 321kB ± 0%: new 321kB ± 0%: delta: 0.00%
TmAllTrueFuncall-4: old 10.6kB ± 0%: new 10.6kB ± 0%: delta: 0.00%
TmAnyTrueLiteralList-4: old 2.09MB ± 0%: new 2.09MB ± 0%: delta: 0.00%
TmAnyTrueFuncall-4: old 10.7kB ± 0%: new 10.7kB ± 0%: delta: 0.00%
TmTernary-4: old 1.20kB ± 0%: new 1.20kB ± 0%: delta: 0.00%
TmTryUnknownFunc-4: old 784B ± 0%: new 784B ± 0%: delta: 0.00%
TmTryUnknownVariable-4: old 768B ± 0%: new 768B ± 0%: delta: 0.00%
TmTryUnknownObjectKey-4: old 952B ± 0%: new 952B ± 0%: delta: 0.00%
metric: allocs/op
ChangeDetection-4: old 1.17k ± 0%: new 1.17k ± 0%: delta: 0.00%
ChangeDetectionTFAndTG-4: old 33.6k ± 0%: new 33.6k ± 0%: delta: 0.00%
CloudReadLines-4: old 5.54k ± 0%: new 5.54k ± 0%: delta: 0.00%
CloudReadLine-4: old 60.0k ± 0%: new 60.0k ± 0%: delta: 0.00%
ListFiles-4: old 335 ± 0%: new 335 ± 0%: delta: 0.00%
Generate-4: old 51.4M ± 0%: new 51.4M ± 0%: delta: 0.00%
GenerateRegex-4: old 36.8M ± 0%: new 36.8M ± 0%: delta: 0.00%
TokensForExpressionComplex-4: old 4.83k ± 0%: new 4.83k ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 20.0 ± 0%: new 20.0 ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 227 ± 0%: new 227 ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 3.19k ± 0%: new 3.19k ± 0%: delta: 0.00%
TokensForExpression-4: old 4.83k ± 0%: new 4.83k ± 0%: delta: 0.00%
PartialEvalComplex-4: old 3.48k ± 0%: new 3.48k ± 0%: delta: 0.00%
PartialEvalSmallString-4: old 23.0 ± 0%: new 23.0 ± 0%: delta: 0.00%
PartialEvalHugeString-4: old 35.0 ± 0%: new 35.0 ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-4: old 23.1k ± 0%: new 23.1k ± 0%: delta: 0.00%
PartialEvalObject-4: old 152 ± 0%: new 152 ± 0%: delta: 0.00%
TmAllTrueLiteralList-4: old 5.94k ± 0%: new 5.94k ± 0%: delta: 0.00%
TmAllTrueFuncall-4: old 275 ± 0%: new 275 ± 0%: delta: 0.00%
TmAnyTrueLiteralList-4: old 59.6k ± 0%: new 59.6k ± 0%: delta: 0.00%
TmAnyTrueFuncall-4: old 277 ± 0%: new 277 ± 0%: delta: 0.00%
TmTernary-4: old 28.0 ± 0%: new 28.0 ± 0%: delta: 0.00%
TmTryUnknownFunc-4: old 21.0 ± 0%: new 21.0 ± 0%: delta: 0.00%
TmTryUnknownVariable-4: old 20.0 ± 0%: new 20.0 ± 0%: delta: 0.00%
TmTryUnknownObjectKey-4: old 23.0 ± 0%: new 23.0 ± 0%: delta: 0.00%

Base automatically changed from i4k-bump-v0.10-7-dev to main October 7, 2024 14:44
@i4ki i4ki force-pushed the i4k-enhance-git branch 6 times, most recently from e89fabb to 6f553c3 Compare October 8, 2024 15:05
@i4ki i4ki force-pushed the i4k-enhance-git branch from 6f553c3 to 96f084b Compare October 8, 2024 15:09
i4ki added a commit that referenced this pull request Oct 8, 2024
@i4ki i4ki force-pushed the i4k-enhance-git branch 7 times, most recently from fb211bf to cabc712 Compare October 9, 2024 01:10
@i4ki i4ki marked this pull request as ready for review October 9, 2024 01:30
@i4ki i4ki requested a review from a team as a code owner October 9, 2024 01:30
stack/manager.go Outdated
@@ -130,11 +136,40 @@ func (m *Manager) ListChanged(gitBaseRef string) (*Report, error) {
return nil, errors.E(errListChanged, err)
}

changedFiles, err := m.changedFiles(gitBaseRef)
_, err = m.changedFiles(cfg.BaseRef)
Copy link
Contributor

@snakster snakster Oct 9, 2024

Choose a reason for hiding this comment

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

I think this is hard to reason about, the memoization is just an internal thing, but here the caller relies on that behaviour.

Would it be possible to add checks.UncommittedFiles and checks.UntrackedFiles as params to m.changedFiles (with the option of them being empty), then do the appending in there?

@i4ki i4ki force-pushed the i4k-enhance-git branch from cabc712 to af1186c Compare October 9, 2024 12:01
@i4ki i4ki requested a review from snakster October 9, 2024 12:04
Copy link
Contributor

@snakster snakster left a comment

Choose a reason for hiding this comment

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

👍

@i4ki i4ki merged commit 865b950 into main Oct 9, 2024
7 checks passed
@i4ki i4ki deleted the i4k-enhance-git branch October 9, 2024 20:00
i4ki added a commit that referenced this pull request Oct 11, 2024
## What this PR does / why we need it:

This flag was planned to be added to `experimental trigger` but later
realized as not needed but I forgot to rollback. This is not released,
just introduced in #1904 and does not need a changelog update.

## Which issue(s) this PR fixes:
none

## Special notes for your reviewer:

## Does this PR introduce a user-facing change?
```
no
```
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.

[FEATURE] Change detection for uncommitted files
2 participants