From 9acb3e0f7ab054e7199837671afbd1580b955506 Mon Sep 17 00:00:00 2001 From: Uday Date: Mon, 10 Aug 2026 12:23:09 +0530 Subject: [PATCH] RTECO-1784 - Add --project build-info e2e for agent plugins and skills Co-authored-by: Cursor --- agent_plugins_test.go | 36 ++++++++++++++++++++++++++++++++++++ agent_skills_test.go | 37 +++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 76 insertions(+), 3 deletions(-) diff --git a/agent_plugins_test.go b/agent_plugins_test.go index f9450bfd8..e1a16f67c 100644 --- a/agent_plugins_test.go +++ b/agent_plugins_test.go @@ -615,6 +615,42 @@ func TestAgentPluginsPublishWithBuildInfo(t *testing.T) { assert.NotEmpty(t, module.Artifacts[0].Sha256, "artifact sha256 should be non-empty in build info") } +// TestAgentPluginsPublishWithProjectFlag verifies that --project= stores the +// build-info partials under the project-key-aware local directory (the build dir +// hash includes the project key), and that nothing is stored under the +// empty-project directory. +func TestAgentPluginsPublishWithProjectFlag(t *testing.T) { + initAgentPluginsTest(t) + defer cleanAgentPluginsTest() + + slug := "project-flag-plugin" + buildName := tests.AgentPluginsBuildName + "-project" + buildNumber := "1" + projectKey := "testprj" + t.Cleanup(func() { + _ = coreBuild.RemoveBuildDir(buildName, buildNumber, projectKey) + _ = coreBuild.RemoveBuildDir(buildName, buildNumber, "") + }) + + require.NoError(t, runAgentPluginsCmd(t, + "publish", createTestPlugin(t, slug, "1.0.0"), + "--repo="+tests.AgentPluginsLocalRepo, + "--build-name="+buildName, + "--build-number="+buildNumber, + "--project="+projectKey, + )) + + partials, err := coreBuild.ReadPartialBuildInfoFiles(buildName, buildNumber, projectKey) + require.NoError(t, err) + require.Len(t, partials, 1, "expected 1 build-info partial stored with project key %q", projectKey) + assert.Equal(t, slug, partials[0].ModuleId) + assert.NotEmpty(t, partials[0].Artifacts, "published zip should be recorded as a build-info artifact") + + partialsNoProject, err := coreBuild.ReadPartialBuildInfoFiles(buildName, buildNumber, "") + assert.NoError(t, err) + assert.Empty(t, partialsNoProject, "build info should NOT be stored under the empty project key directory") +} + // TestAgentPluginsNoBuildInfoWithoutFlags verifies that publishing without // --build-name and --build-number does not create a build info entry. func TestAgentPluginsNoBuildInfoWithoutFlags(t *testing.T) { diff --git a/agent_skills_test.go b/agent_skills_test.go index 6ea818d11..41647162e 100644 --- a/agent_skills_test.go +++ b/agent_skills_test.go @@ -1793,6 +1793,43 @@ func TestAgentSkillsPublishBuildInfo(t *testing.T) { assert.NotEmpty(t, props.Properties["build.timestamp"]) } +// TestAgentSkillsPublishWithProjectFlag verifies that --project= stores the +// build-info partials under the project-key-aware local directory (the build dir +// hash includes the project key), and that nothing is stored under the +// empty-project directory. +func TestAgentSkillsPublishWithProjectFlag(t *testing.T) { + initAgentSkillsTest(t) + defer cleanAgentSkillsTest() + + slug := "project-flag-skill" + buildName := tests.AgentSkillsBuildName + "-project" + buildNumber := "1" + projectKey := "testprj" + t.Cleanup(func() { + _ = coreBuild.RemoveBuildDir(buildName, buildNumber, projectKey) + _ = coreBuild.RemoveBuildDir(buildName, buildNumber, "") + }) + + require.NoError(t, runAgentSkillsCmd(t, + "publish", createTestSkill(t, slug, "1.0.0"), + "--repo="+tests.AgentSkillsLocalRepo, + "--skip-scan", + "--build-name="+buildName, + "--build-number="+buildNumber, + "--project="+projectKey, + )) + + partials, err := coreBuild.ReadPartialBuildInfoFiles(buildName, buildNumber, projectKey) + require.NoError(t, err) + require.Len(t, partials, 1, "expected 1 build-info partial stored with project key %q", projectKey) + assert.Equal(t, slug, partials[0].ModuleId) + assert.NotEmpty(t, partials[0].Artifacts, "published zip should be recorded as a build-info artifact") + + partialsNoProject, err := coreBuild.ReadPartialBuildInfoFiles(buildName, buildNumber, "") + assert.NoError(t, err) + assert.Empty(t, partialsNoProject, "build info should NOT be stored under the empty project key directory") +} + // TestAgentSkillsPublishModuleOverride verifies --module overrides the default // build-info module id (skill slug). func TestAgentSkillsPublishModuleOverride(t *testing.T) { diff --git a/go.mod b/go.mod index 0f8c48428..25ae3cfb5 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/jfrog/build-info-go v1.13.1-0.20260811071930-3b99d4a6c84b github.com/jfrog/gofrog v1.7.6 github.com/jfrog/jfrog-cli-application v1.0.2-0.20260723152309-34eeb81e2847 - github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260804124646-1a5e6a2d3caf + github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260810062257-afac3757dd37 github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260809090751-06d8b791eb24 github.com/jfrog/jfrog-cli-evidence v0.9.5 github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20260618062042-6053ab368cab diff --git a/go.sum b/go.sum index e0d0974e1..47a17b656 100644 --- a/go.sum +++ b/go.sum @@ -402,8 +402,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-application v1.0.2-0.20260723152309-34eeb81e2847 h1:wahxu7URLrhdHtI3CVH3aE1Y3eeubDin13t+QVJBeW8= github.com/jfrog/jfrog-cli-application v1.0.2-0.20260723152309-34eeb81e2847/go.mod h1:p8yLtbmCxxQucIbLZKnWu0F+EDtj6NLXbRQCEK/nb6o= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260804124646-1a5e6a2d3caf h1:HJob3Bsj6FtQ3nq72GGzBWXJ7ZXvUz6rKSGpYGAXwKI= -github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260804124646-1a5e6a2d3caf/go.mod h1:UkVDiTbSgtk+7N2ePOsPvjPsgO8r8rJtUchjcnAk08w= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260810062257-afac3757dd37 h1:YviOnKCh/OKV5dhPYp828KmighW5bZ2OKt78Xk4Fs3E= +github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260810062257-afac3757dd37/go.mod h1:UkVDiTbSgtk+7N2ePOsPvjPsgO8r8rJtUchjcnAk08w= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260809090751-06d8b791eb24 h1:boI4fGv/Sn+9z6sZOYRlpT45Y+nkYFL3nCK0MkQBV4w= github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260809090751-06d8b791eb24/go.mod h1:MygQx8pekgPCXyXnejIAVG9S4ImGcDFmcfRPUug/0d0= github.com/jfrog/jfrog-cli-evidence v0.9.5 h1:YzkoYZtqChStPOxEj1odF7satpv1YPl1Zb/IZ/wZ9kc=