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

Add test about using variable in bundle.git.branch #2118

Merged
merged 10 commits into from
Jan 15, 2025

Conversation

denik
Copy link
Contributor

@denik denik commented Jan 10, 2025

This test checks load git details functionality + variable interpolation there.

The variables are not working there because LoadGitDetails mutator is running before variable interpolation.

This also includes a couple fixes for acceptance tests on Windows:

  • Correctly replace tmp path that is used for DATABRICKS_TF_EXEC_PATH
  • Pass -buildvcs=false to go build. It's not needed on CI but it is needed on my local windows VM.

@denik denik temporarily deployed to test-trigger-is January 10, 2025 11:05 — with GitHub Actions Inactive
@denik denik marked this pull request as draft January 10, 2025 13:12
@denik denik temporarily deployed to test-trigger-is January 10, 2025 13:18 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is January 10, 2025 13:21 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is January 13, 2025 10:45 — with GitHub Actions Inactive
@denik denik marked this pull request as ready for review January 13, 2025 10:51

git-repo-init() {
git init -qb main
git config --global core.autocrlf false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pietern Found out about this option because a warning was printed by git about this and was captured in test output. This must be the reason we need to fix crlf in golden files in integration tests.

Copy link
Contributor

Choose a reason for hiding this comment

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


repls := testdiff.ReplacementsContext{}
repls.Set(execPath, "$CLI")
repls.Set(toJson(t, tempHomeDir), "$TMPHOME")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why both toJson and verbatim values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verbatim does not work in JSON output and vice versa.

If verbatim strings contains \ then you need both replacements if you want replacement to work in json and non-json context.

We don't need non-json here, I added it just in case. However, I think it's best to do that everywhere so you don't think about it -- #2142

"file_path": "/Workspace/Users/[email protected]/.bundle/git/prod/files",
"resource_path": "/Workspace/Users/[email protected]/.bundle/git/prod/resources",
"root_path": "/Workspace/Users/[email protected]/.bundle/git/prod",
"state_path": "/Workspace/Users/[email protected]/.bundle/git/prod/state"
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs rebase on #2120 for $USERNAME.


git-repo-init() {
git init -qb main
git config --global core.autocrlf false
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

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

No blocking comments, approving to unblock merge.

@denik denik force-pushed the denik/variables-git-branch branch from 97f9bfb to 2e6a6f0 Compare January 14, 2025 14:45
@denik denik temporarily deployed to test-trigger-is January 14, 2025 14:45 — with GitHub Actions Inactive
@denik denik changed the base branch from main to denik/replacements-json January 14, 2025 15:01
@denik denik force-pushed the denik/variables-git-branch branch from 2e6a6f0 to 2c919ac Compare January 14, 2025 15:40
@denik denik temporarily deployed to test-trigger-is January 14, 2025 15:40 — with GitHub Actions Inactive
github-merge-queue bot pushed a commit that referenced this pull request Jan 14, 2025
## Changes
Always include both verbatim and json version of replacement.

This helps when the string in question contains \\ or other chars that
need to be quoted.

Needed for #2118

## Tests
Existing tests.
Base automatically changed from denik/replacements-json to main January 14, 2025 15:58

variables:
deployment_branch:
# read from git; inferred should be set to true; current it's not happening
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this belong to the stanza above? I don't understand what you expect to happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the description -- fe0ec6b

trace $CLI bundle validate -o json | grep -v '"commit"'
trace $CLI bundle validate
trace $CLI bundle validate -o json -t dev | grep -v '"commit"'
trace $CLI bundle validate -t dev | grep -v '"commit"'
Copy link
Contributor

Choose a reason for hiding this comment

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

What do the greps do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove line matching '"commit"' because it includes hash that varies from run to run.

@denik denik force-pushed the denik/variables-git-branch branch from 5593021 to fe0ec6b Compare January 14, 2025 20:56
@denik denik temporarily deployed to test-trigger-is January 14, 2025 20:56 — with GitHub Actions Inactive
@denik denik changed the base branch from main to denik/enable-json-replacer January 14, 2025 20:59
@denik
Copy link
Contributor Author

denik commented Jan 14, 2025

@pietern @andrewnester please stamp this PR - #2147 -- it's a dependency of this one.

@denik denik temporarily deployed to test-trigger-is January 14, 2025 22:00 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is January 14, 2025 22:07 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is January 14, 2025 22:18 — with GitHub Actions Inactive
denik added a commit that referenced this pull request Jan 15, 2025
## Changes
Follow up to #2142 which did not actually enabled JSON conversion
because of reversed condition on err.

## Tests
Tested via #2118
Base automatically changed from denik/enable-json-replacer to main January 15, 2025 08:46
@denik denik force-pushed the denik/variables-git-branch branch from 1901998 to 20d424e Compare January 15, 2025 08:49
@denik denik temporarily deployed to test-trigger-is January 15, 2025 08:49 — with GitHub Actions Inactive
@denik denik enabled auto-merge January 15, 2025 08:49
@denik denik disabled auto-merge January 15, 2025 09:32
@denik denik enabled auto-merge January 15, 2025 09:32
@denik denik disabled auto-merge January 15, 2025 09:34
@denik denik enabled auto-merge January 15, 2025 09:34
@denik denik disabled auto-merge January 15, 2025 09:34
@denik denik merged commit 55494a0 into main Jan 15, 2025
8 of 9 checks passed
@denik denik deleted the denik/variables-git-branch branch January 15, 2025 09:34
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.

3 participants