-
Notifications
You must be signed in to change notification settings - Fork 69
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
Include a materialized copy of built-in templates #2146
Conversation
@denik I tried using |
acceptance/bundle/init/default-python/output/my_default_python/.gitignore
Outdated
Show resolved
Hide resolved
We could easily fix that with by using |
I think it would be useful (could be a follow up) to also run "bundle validate" and "bundle deploy" and other commands on these, so bundle/init is not a great name, because it's not just init. bundle/templates ? |
## Changes Replacement was split between the type `ReplacementContext` and the `ReplaceOutput` function. The latter also ran a couple of regular expressions. This change consolidates them such that it is up to the caller to compose the set of replacements to use. This change is required to accommodate UUID replacement in #2146.
3884a71
to
f45b156
Compare
#2166 makes sure that initialized templates are formatted per ruff. |
t.Logf("Overwriting: %s", pathExpected) | ||
testutil.WriteFile(t, pathExpected, valueNew) | ||
} else { | ||
t.Logf("Removing: %s", pathExpected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? It's helpful to update golden test files when files are deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-removal functionality is quite helpful actually. I'd prefer that we keep it.
We can do so by changing readIfExists to return (contents string, exists bool) to distinguish between empty and missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this nuance, thanks.
I updated the code to deal with all combinations of missing files in a single place.
Please re-review the changes to acceptance_test.go
.
## Changes The materialized templates included in #2146 include Python code that we require to be formatted. Instead of running ruff as part of the testcase, we can enforce that all Python code in the repository is formatted. It won't be possible to have a passing acceptance test for template initialization with unformatted code.
} | ||
|
||
if !errors.Is(err, os.ErrNotExist) { | ||
t.Fatalf("%s: %s", path, err) | ||
} | ||
return []byte{} | ||
return []byte{}, false | ||
} | ||
|
||
func CopyDir(src, dst string, inputs, outputs map[string]bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a unit test for this since this is part of the acceptance test infra.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree. The amount of logic here has grown. While the coverage is implied through passing tests, something could slip through.
} else { | ||
t.Logf("Removing: %s", pathExpected) | ||
_ = os.Remove(pathExpected) | ||
func doComparison(t *testing.T, repls testdiff.ReplacementsContext, dirRef, dirNew, relPath string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, I like having all the possible cases in one place.
CLI: * Added text output templates for apps list and list-deployments ([#2175](#2175)). * Fix duplicate "apps" entry in help output ([#2191](#2191)). Bundles: * Allow yaml-anchors in schema ([#2200](#2200)). * Show an error when non-yaml files used in include section ([#2201](#2201)). * Set WorktreeRoot to sync root outside git repo ([#2197](#2197)). * fix: Detailed message for using source-linked deployment with file_path specified ([#2119](#2119)). * Allow using variables in enum fields ([#2199](#2199)). * Add experimental-jobs-as-code template ([#2177](#2177)). * Reading variables from file ([#2171](#2171)). * Fixed an apps message order and added output test ([#2174](#2174)). * Default to forward slash-separated paths for path translation ([#2145](#2145)). * Include a materialized copy of built-in templates ([#2146](#2146)).
CLI: * Added text output templates for apps list and list-deployments ([#2175](#2175)). * Fix duplicate "apps" entry in help output ([#2191](#2191)). Bundles: * Allow yaml-anchors in schema ([#2200](#2200)). * Show an error when non-yaml files used in include section ([#2201](#2201)). * Set WorktreeRoot to sync root outside git repo ([#2197](#2197)). * fix: Detailed message for using source-linked deployment with file_path specified ([#2119](#2119)). * Allow using variables in enum fields ([#2199](#2199)). * Add experimental-jobs-as-code template ([#2177](#2177)). * Reading variables from file ([#2171](#2171)). * Fixed an apps message order and added output test ([#2174](#2174)). * Default to forward slash-separated paths for path translation ([#2145](#2145)). * Include a materialized copy of built-in templates ([#2146](#2146)).
Changes
Include a materialized copy of built-in templates as reference output.
This updates the output comparison logic to work against an output directory. The
doComparison
function now always works on real files. It can now tell apart non-existing files and empty files (e.g., the.gitkeep
files in templates).