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

test: move lint e2e test to unit test #3334

Merged
merged 10 commits into from
Dec 16, 2024
Merged

test: move lint e2e test to unit test #3334

merged 10 commits into from
Dec 16, 2024

Conversation

AustinAbro321
Copy link
Contributor

@AustinAbro321 AustinAbro321 commented Dec 16, 2024

Description

lint e2e test should be moved to a unit test for simplicity and to avoid checking output from the cli. Also simplifying the e2e test to focus on flavors, variables, and importing as we have other unit tests already for much for the lint rules.

Checklist before merging

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
@AustinAbro321 AustinAbro321 requested review from a team as code owners December 16, 2024 17:48
Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 3240e31
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/67606911d7c0cb00080899f7

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
@@ -130,14 +130,6 @@ init-package: ## Create the zarf init package (must `brew install coreutils` on
release-init-package:
$(ZARF_BIN) package create -o build -a $(ARCH) --set AGENT_IMAGE_TAG=$(AGENT_IMAGE_TAG) --confirm .

# INTERNAL: used to build an iron bank version of the init package with an ib version of the registry image
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shoving this into this PR. We don't do ironbank things anymore in Zarf, no reason to keep this around.

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

@mkcp mkcp left a comment

Choose a reason for hiding this comment

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

Looks good, added a few comments but no changes requested.

This is definitely outside the scope of the PR, but deleting e2e test 12 highlights to me that these should be named in their order. Add or remove one and all of the other tests are affected. If you agree, would you be interested in scoping out an issue to migrate e2e tests to no longer be numbered?

@@ -130,14 +130,6 @@ init-package: ## Create the zarf init package (must `brew install coreutils` on
release-init-package:
$(ZARF_BIN) package create -o build -a $(ARCH) --set AGENT_IMAGE_TAG=$(AGENT_IMAGE_TAG) --confirm .

# INTERNAL: used to build an iron bank version of the init package with an ib version of the registry image
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -128,15 +127,12 @@ func templateZarfObj(zarfObj any, setVariables map[string]string) ([]PackageFind
})
}
if _, present := setVariables[key]; !present {
unSetTemplates = true
findings = append(findings, PackageFinding{
Description: fmt.Sprintf("package template %s is not set and won't be evaluated during lint", key),
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}
cwd, err := os.Getwd()
require.NoError(t, err)
// TODO @austinabro321: remove this and parallelize the test once changing the working directory is no longer required
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense keeping the scope of changes manageable.

@@ -93,3 +95,67 @@ func TestFillObjTemplate(t *testing.T) {
require.ElementsMatch(t, expectedFindings, findings)
require.Equal(t, expectedComponent, component)
}

func TestLintPackageWithImports(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.

In an ideal world we would testing more cases which are smaller. But this makes sense as an iterative step in the right direction.

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
src/pkg/lint/lint.go 67.64% <100.00%> (+26.13%) ⬆️

... and 2 files with indirect coverage changes

@AustinAbro321
Copy link
Contributor Author

@mkcp yeah good call, we do require the numbers right now since the tests have to run in order, but if we parallelize the tests then we should be able to get rid of them. Went into detail about this in #3335

@AustinAbro321 AustinAbro321 added this pull request to the merge queue Dec 16, 2024
Merged via the queue into main with commit 7c9ff9a Dec 16, 2024
26 checks passed
@AustinAbro321 AustinAbro321 deleted the unit-test-lint branch December 16, 2024 19:42
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.

2 participants