Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/repos/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions internal/repos/ref_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 5 additions & 1 deletion internal/repos/remote_scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ 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
}{
{"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
Expand Down
8 changes: 7 additions & 1 deletion internal/scaffold/installfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions internal/scaffold/scaffold_gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading