Repository navigation
Added e2e tests for multiple package managers #3332
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
686a55c
Added e2e tests for multiple package managers
bhanurp 41128b4
Updated tests for CI VCS properties
bhanurp 89cc7c5
Merge branch 'master' into new-vcs-props-e2e
bhanurp 3b7bf61
UPdated dependencies
bhanurp 73a8934
Fixed conan and other test to mirror CI VCS prop setting logic
bhanurp 7fcee13
Fixed static violations
bhanurp 2273195
Fixed static violations
bhanurp cdd6951
Updated dependencies
bhanurp ade84fa
Added multi file upload test case
bhanurp 7fcd6e7
Merge branch 'master' into new-vcs-props-e2e
bhanurp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |||||||||
|
|
||||||||||
| buildinfo "github.com/jfrog/build-info-go/entities" | ||||||||||
| biutils "github.com/jfrog/build-info-go/utils" | ||||||||||
| "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" | ||||||||||
| coretests "github.com/jfrog/jfrog-cli-core/v2/utils/tests" | ||||||||||
| "github.com/jfrog/jfrog-cli/inttestutils" | ||||||||||
| "github.com/jfrog/jfrog-cli/utils/tests" | ||||||||||
|
|
@@ -467,3 +468,104 @@ func cleanupConanRemote() { | |||||||||
| _ = exec.Command("conan", "remote", "remove", tests.ConanVirtualRepo).Run() | ||||||||||
| _ = exec.Command("conan", "remote", "remove", tests.ConanLocalRepo).Run() | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // TestConanBuildPublishWithCIVcsProps tests that CI VCS properties are set on Conan artifacts | ||||||||||
| // when running build-publish in a CI environment (GitHub Actions). | ||||||||||
| // Conan packages are published via Conan client; build-publish retrieves artifact paths | ||||||||||
| // from Build Info and applies properties via batch API. | ||||||||||
| func TestConanBuildPublishWithCIVcsProps(t *testing.T) { | ||||||||||
| initConanTest(t) | ||||||||||
|
|
||||||||||
| buildName := tests.ConanBuildName + "-civcs" | ||||||||||
| buildNumber := "1" | ||||||||||
|
|
||||||||||
| // Setup GitHub Actions environment (uses real env vars on CI, mock values locally) | ||||||||||
| cleanupEnv, actualOrg, actualRepo := tests.SetupGitHubActionsEnv(t) | ||||||||||
| defer cleanupEnv() | ||||||||||
|
|
||||||||||
| // Clean old build | ||||||||||
| inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, buildName, artHttpDetails) | ||||||||||
| defer inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, buildName, artHttpDetails) | ||||||||||
|
|
||||||||||
| // Prepare project | ||||||||||
| projectPath := createConanProject(t, "conan-civcs-test") | ||||||||||
| wd, err := os.Getwd() | ||||||||||
| require.NoError(t, err) | ||||||||||
| chdirCallback := clientTestUtils.ChangeDirWithCallback(t, wd, projectPath) | ||||||||||
| defer chdirCallback() | ||||||||||
|
|
||||||||||
| // Configure Conan remote | ||||||||||
| configureConanRemote(t) | ||||||||||
| defer cleanupConanRemote() | ||||||||||
|
|
||||||||||
| jfrogCli := coretests.NewJfrogCli(execMain, "jfrog", "") | ||||||||||
|
|
||||||||||
| // Run conan create | ||||||||||
| createArgs := []string{ | ||||||||||
| "conan", "create", ".", | ||||||||||
| "--build=missing", | ||||||||||
| "--build-name=" + buildName, | ||||||||||
| "--build-number=" + buildNumber, | ||||||||||
| } | ||||||||||
| assert.NoError(t, jfrogCli.Exec(createArgs...)) | ||||||||||
|
|
||||||||||
| // Run conan upload | ||||||||||
| uploadArgs := []string{ | ||||||||||
| "conan", "upload", "cli-test-package/*", | ||||||||||
| "-r", tests.ConanLocalRepo, | ||||||||||
| "--confirm", | ||||||||||
| "--build-name=" + buildName, | ||||||||||
| "--build-number=" + buildNumber, | ||||||||||
| } | ||||||||||
| assert.NoError(t, jfrogCli.Exec(uploadArgs...)) | ||||||||||
|
|
||||||||||
| // Publish build info - should set CI VCS props on artifacts | ||||||||||
| assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber)) | ||||||||||
|
|
||||||||||
| // Get the published build info to find artifact paths | ||||||||||
| publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber) | ||||||||||
| require.NoError(t, err) | ||||||||||
| require.True(t, found, "Build info was not found") | ||||||||||
|
|
||||||||||
| // Create service manager for getting artifact properties | ||||||||||
| serviceManager, err := utils.CreateServiceManager(serverDetails, 3, 1000, false) | ||||||||||
| require.NoError(t, err) | ||||||||||
|
|
||||||||||
| // Verify VCS properties on each artifact from build info | ||||||||||
| // Note: Conan artifacts may not have OriginalDeploymentRepo set, so we use Path directly as fallback | ||||||||||
| artifactCount := 0 | ||||||||||
| for _, module := range publishedBuildInfo.BuildInfo.Modules { | ||||||||||
| for _, artifact := range module.Artifacts { | ||||||||||
| // Use same fallback logic as CI VCS: OriginalDeploymentRepo + Path, or Path directly | ||||||||||
| var fullPath string | ||||||||||
| switch { | ||||||||||
| case artifact.OriginalDeploymentRepo != "": | ||||||||||
| fullPath = artifact.OriginalDeploymentRepo + "/" + artifact.Path | ||||||||||
| case artifact.Path != "": | ||||||||||
| fullPath = artifact.Path | ||||||||||
| default: | ||||||||||
| continue // Skip artifacts without any path info | ||||||||||
| } | ||||||||||
|
|
||||||||||
| props, err := serviceManager.GetItemProps(fullPath) | ||||||||||
| assert.NoError(t, err, "Failed to get properties for artifact: %s", fullPath) | ||||||||||
| if props == nil { | ||||||||||
| continue | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Validate VCS properties | ||||||||||
| assert.Contains(t, props.Properties, "vcs.provider", "Missing vcs.provider on %s", artifact.Name) | ||||||||||
| assert.Contains(t, props.Properties["vcs.provider"], "github", "Wrong vcs.provider on %s", artifact.Name) | ||||||||||
|
|
||||||||||
| assert.Contains(t, props.Properties, "vcs.org", "Missing vcs.org on %s", artifact.Name) | ||||||||||
| assert.Contains(t, props.Properties["vcs.org"], actualOrg, "Wrong vcs.org on %s", artifact.Name) | ||||||||||
|
|
||||||||||
| assert.Contains(t, props.Properties, "vcs.repo", "Missing vcs.repo on %s", artifact.Name) | ||||||||||
| assert.Contains(t, props.Properties["vcs.repo"], actualRepo, "Wrong vcs.repo on %s", artifact.Name) | ||||||||||
|
|
||||||||||
| artifactCount++ | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| assert.Greater(t, artifactCount, 0, "No artifacts were validated for CI VCS properties") | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment says "No artifacts were validated" but message could be more specific about what went wrong.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| } | ||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Extract Magic Numbers to Constants