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

Move loadGitDetails mutator to Initialize phase #1944

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

denik
Copy link
Contributor

@denik denik commented Nov 29, 2024

This will require API call when run inside a workspace, which will require workspace client (we don't have one at the current point). We want to keep Load phase quick, since it's common across all commands.

bundle/tests/environment_git_test.go Outdated Show resolved Hide resolved
bundle/tests/loader.go Outdated Show resolved Hide resolved
@denik denik requested a review from andrewnester November 29, 2024 11:48
This will require API call and we want to keep Load phase fast.
@denik denik force-pushed the DECO-24125--move-git-load-to-initialize branch from 17f284e to 84d535a Compare December 1, 2024 20:28
@denik denik temporarily deployed to test-trigger-is December 1, 2024 20:28 — with GitHub Actions Inactive
Copy link

github-actions bot commented Dec 1, 2024

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 1944
  • Commit SHA: 84d535a4122130ee5cc4ebf969816db03ffa665c

Checks will be approved automatically on success.

@denik denik temporarily deployed to test-trigger-is December 1, 2024 20:28 — with GitHub Actions Inactive
Copy link
Contributor

@shreyas-goenka shreyas-goenka left a comment

Choose a reason for hiding this comment

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

Thanks! Minor comments regarding the unit tests.

bundle/tests/git_test.go Show resolved Hide resolved
@@ -14,13 +14,15 @@ import (

func TestGitAutoLoad(t *testing.T) {
b := load(t, "./autoload_git")
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of load you can now directly use b := &bundle.Bundle{...} fixture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean. However, I wonder, if it’s better to go through load process first anyway, since that’s always applied on actual Bundle before running this mutator and thus gives more realistic test.

I’d also wary about refactoring tests and functionality in the same PR, as purpose of the tests here is to check that this change is pure refactoring and does not affect behavior in unexpected way.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, the functionality is simple and localized enough that I think we'll be fine testing only the mutator since the functionality/context is localized to the load_git_details mutator.

But that's a personal preference, either way sounds reasonable enough.

"fmt"
"strings"
"testing"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/stretchr/testify/assert"
)

func TestGitAutoLoadWithEnvironment(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We no longer need tests for environment overrides if we move it out of the load phase. The environments are resolves by the time the code gets to the initialize phase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain why we needed this before and don't need this anymore? This PR does not change overall behavior, just reorders some operations.

In any case, if we think this test is not useful anymore I propose to clean it up in a follow up PR. In this PR it serves as proof that whatever it tests was not broken by this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why we needed this before and don't need this anymore?

Environments / Targets are not resolved in the DefaultMutators(). They are resolved right afterwards in the loading process. Since before we loaded the Git details in the loading phase it was relevant to test the environment.

The environments/targets block is already nil by the time the code gets to initialize phase.

@eng-dev-ecosystem-bot
Copy link
Collaborator

Test Details: go/deco-tests/12108786336

@denik denik requested a review from shreyas-goenka December 2, 2024 08:39
@denik denik added this pull request to the merge queue Dec 2, 2024
Merged via the queue into main with commit 00bd98f Dec 2, 2024
10 checks passed
@denik denik deleted the DECO-24125--move-git-load-to-initialize branch December 2, 2024 09:54
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.

4 participants