From 57f9e264e15112897ecd48be5dce04e5fb3d5a72 Mon Sep 17 00:00:00 2001 From: fullsend-code <278716306+fullsend-ai-coder[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2026 13:28:37 +0000 Subject: [PATCH] fix(#6602): skip .gitlab-ci.yml during GitLab scaffold install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CollectGitLabPerRepoInstallFiles and the remote scaffold path (scaffoldGitLabPaths) unconditionally included .gitlab-ci.yml in the install payload. This overwrote a consumer's existing CI pipeline configuration when running fullsend repos install on a repo that already had CI set up. Skip .gitlab-ci.yml from install output, matching the existing .gitignore skip pattern. The fullsend-owned sub-files under .gitlab/ci/ (dispatch, agent, poll) are still installed unconditionally. Adopters add the corresponding include: directives to their own .gitlab-ci.yml. The upgrade path (collectGitLabUpgradeTemplates) already skipped .gitlab-ci.yml for the same reason — this aligns the install path. Closes #6602 --- internal/repos/install_test.go | 7 ++++++- internal/repos/ref_ops.go | 5 +++-- internal/repos/remote_scaffold.go | 6 +++++- internal/scaffold/installfiles.go | 8 +++++++- internal/scaffold/scaffold_gitlab_test.go | 19 +++++++++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/internal/repos/install_test.go b/internal/repos/install_test.go index d062947fe8..4b7f2fbdb5 100644 --- a/internal/repos/install_test.go +++ b/internal/repos/install_test.go @@ -1108,7 +1108,6 @@ func TestBuildScaffoldFiles_GitLab(t *testing.T) { paths[f.Path] = true } for _, expected := range []string{ - ".gitlab-ci.yml", ".gitlab/ci/fullsend-agent.yml", ".gitlab/ci/fullsend-dispatch.yml", ".gitlab/ci/fullsend-poll.yml", @@ -1118,6 +1117,12 @@ func TestBuildScaffoldFiles_GitLab(t *testing.T) { t.Errorf("missing expected scaffold file %q", expected) } } + // Root .gitlab-ci.yml must NOT be in install output — installing it + // would overwrite a consumer's existing CI pipeline configuration (#6602). + if paths[".gitlab-ci.yml"] { + t.Error(".gitlab-ci.yml must not be included in GitLab install output — " + + "it would overwrite existing CI config (#6602)") + } } func TestInstall_GitHub_NoInferenceProject_SkipsSecrets(t *testing.T) { diff --git a/internal/repos/ref_ops.go b/internal/repos/ref_ops.go index f687bf8df7..77048489e0 100644 --- a/internal/repos/ref_ops.go +++ b/internal/repos/ref_ops.go @@ -80,8 +80,9 @@ func collectGitLabUpgradeTemplates(runnerTags []string, targetRef string) ([]for var files []forge.TreeFile for _, f := range installFiles { // Skip the dispatch file — upgrade handles it via replaceShimRef. - // Skip the root pipeline file — users may have customized it - // (e.g. adding workflow:rules for push events). + // Skip the root pipeline file — CollectGitLabPerRepoInstallFiles + // already excludes it (#6602), but keep the guard for defense + // in depth. if f.Path == ".gitlab/ci/fullsend-dispatch.yml" || f.Path == ".gitlab-ci.yml" { continue } diff --git a/internal/repos/remote_scaffold.go b/internal/repos/remote_scaffold.go index 50d17c7bcc..57a32ffe1a 100644 --- a/internal/repos/remote_scaffold.go +++ b/internal/repos/remote_scaffold.go @@ -12,6 +12,11 @@ import ( // Remote scaffold template paths within the fullsend-ai/fullsend repo. const scaffoldGitHubShimPath = "internal/scaffold/fullsend-repo/templates/shim-per-repo.yaml" +// scaffoldGitLabPaths lists the GitLab scaffold files fetched from the +// remote fullsend-ai/fullsend repo for pinned-ref installs. The root +// .gitlab-ci.yml is excluded because installing it would overwrite a +// consumer's existing CI pipeline configuration (#6602). The sub-files +// under .gitlab/ci/ are fullsend-owned and installed unconditionally. var scaffoldGitLabPaths = []struct { repoPath string outPath string @@ -19,7 +24,6 @@ var scaffoldGitLabPaths = []struct { {"internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/fullsend-dispatch.yml", ".gitlab/ci/fullsend-dispatch.yml"}, {"internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/fullsend-agent.yml", ".gitlab/ci/fullsend-agent.yml"}, {"internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/fullsend-poll.yml", ".gitlab/ci/fullsend-poll.yml"}, - {"internal/scaffold/fullsend-repo-gitlab/.gitlab-ci.yml", ".gitlab-ci.yml"}, } // FetchRemoteScaffold fetches scaffold templates from fullsend-ai/fullsend diff --git a/internal/scaffold/installfiles.go b/internal/scaffold/installfiles.go index 669d73c248..1947bd165f 100644 --- a/internal/scaffold/installfiles.go +++ b/internal/scaffold/installfiles.go @@ -106,6 +106,12 @@ func CollectPerRepoInstallFiles(vendored bool, upstreamRef, upstreamTag string) // callers generate a config with roles and forge field instead. // The embedded root .gitignore is also excluded: installing it would // overwrite a consumer's existing ignore file with a one-line fragment. +// The embedded root .gitlab-ci.yml is also excluded: installing it would +// overwrite a consumer's existing CI pipeline configuration. The scaffold +// sub-files (.gitlab/ci/fullsend-*.yml) are fullsend-owned and installed +// unconditionally; adopters add the corresponding include: directives to +// their own .gitlab-ci.yml. The upgrade path (collectGitLabUpgradeTemplates) +// already skips .gitlab-ci.yml for the same reason. // The embed still ships for docs/tests; adopters (and the guide) add // output/ themselves. When --output-dir sits inside --target-repo // (GitLab layout), fullsend run omits that top-level directory from the @@ -119,7 +125,7 @@ func CollectGitLabPerRepoInstallFiles(runnerTags []string, upstreamRef, upstream fullsendVersion := ResolveFullsendVersion(upstreamRef, upstreamTag) var files InstallFiles err := WalkGitLabPerRepo(func(path string, content []byte) error { - if path == ".fullsend/config.yaml" || path == ".gitignore" { + if path == ".fullsend/config.yaml" || path == ".gitignore" || path == ".gitlab-ci.yml" { return nil } rendered := strings.ReplaceAll(string(content), "__RUNNER_TAGS__", tagYAML) diff --git a/internal/scaffold/scaffold_gitlab_test.go b/internal/scaffold/scaffold_gitlab_test.go index 39ad3f1d76..d27d72b1eb 100644 --- a/internal/scaffold/scaffold_gitlab_test.go +++ b/internal/scaffold/scaffold_gitlab_test.go @@ -48,6 +48,25 @@ func TestCollectGitLabPerRepoInstallFiles_SkipsGitignore(t *testing.T) { } } +func TestCollectGitLabPerRepoInstallFiles_SkipsRootPipeline(t *testing.T) { + files, err := CollectGitLabPerRepoInstallFiles(nil, "", "") + require.NoError(t, err) + for _, f := range files { + assert.NotEqual(t, ".gitlab-ci.yml", f.Path, + "install must not overwrite consumer .gitlab-ci.yml — "+ + "sub-files under .gitlab/ci/ are fullsend-owned; "+ + "adopters add include: directives themselves (#6602)") + } + // Sub-files must still be present. + paths := make([]string, len(files)) + for i, f := range files { + paths[i] = f.Path + } + assert.Contains(t, paths, ".gitlab/ci/fullsend-dispatch.yml") + assert.Contains(t, paths, ".gitlab/ci/fullsend-agent.yml") + assert.Contains(t, paths, ".gitlab/ci/fullsend-poll.yml") +} + func TestGitLabPerRepoFileNotFound(t *testing.T) { _, err := GitLabPerRepoFile("nonexistent-file.yml") assert.Error(t, err)