Files
glint/internal/linter/samba_test.go
T
k3nny 88f20165db feat(cli)!: subcommand CLI, graph tree mode, local include resolution
BREAKING CHANGES:
- `glint <file>` removed; use `glint check <file>`
- `--graph <mode>` removed; use `glint graph [mode]`
- `--graph-out` renamed to `--out` on `glint graph`

feat(cli): ruff-style subcommands — `glint check` and `glint graph [mode]`
feat(graph): `glint graph tree` — terminal job tree with context annotations
feat(graph): context flags (--branch/--tag/--source/--var) on `glint graph`
feat(resolver): recursive local include resolution from disk
fix(resolver): extends unknown base emits warning instead of fatal error
fix(model): script/before_script/after_script accept block scalar string form
test(linter): Samba project CI fixtures as integration tests
chore(build): fix .gitignore to not exclude cmd/glint/ directory
docs: update CHANGELOG, README, ROADMAP for v0.2.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 00:27:28 +02:00

90 lines
2.3 KiB
Go

package linter_test
import (
"path/filepath"
"testing"
"git.k3nny.fr/glint/internal/fetcher"
"git.k3nny.fr/glint/internal/linter"
"git.k3nny.fr/glint/internal/model"
"git.k3nny.fr/glint/internal/resolver"
)
// TestSambaCI verifies that the Samba project's .gitlab-ci.yml (a real-world
// pipeline that is valid on GitLab) produces no Error findings.
// These files exercise local include resolution and multi-level extends chains.
func TestSambaCI(t *testing.T) {
entryPoint := "../../samba-testdata/.gitlab-ci.yml"
p, err := model.Parse(entryPoint)
if err != nil {
t.Fatalf("Parse: %v", err)
}
rootDir := filepath.Dir(filepath.Clean(entryPoint))
incWarnings, _ := resolver.ResolveIncludes(p, fetcher.GitLabConfig{}, rootDir)
for _, w := range incWarnings {
t.Logf("include warning: %s", w)
}
extWarnings, err := resolver.Resolve(p)
if err != nil {
t.Fatalf("Resolve: %v", err)
}
for _, w := range extWarnings {
t.Logf("extends warning: job %q extends unknown %q", w.Job, w.Base)
}
findings := linter.Lint(p)
for _, f := range findings {
if f.Severity == linter.Error {
t.Errorf("unexpected error finding on valid Samba CI: %s", f)
}
}
}
// TestSambaCIEntryFiles verifies all of the Samba entry-point files
// (files that can each act as the top-level CI file) lint without errors.
func TestSambaCIEntryFiles(t *testing.T) {
entryPoints := []struct {
name string
path string
}{
{"default", "../../samba-testdata/.gitlab-ci.yml"},
{"coverage", "../../samba-testdata/.gitlab-ci-coverage.yml"},
{"private", "../../samba-testdata/.gitlab-ci-private.yml"},
}
for _, tc := range entryPoints {
tc := tc
t.Run(tc.name, func(t *testing.T) {
p, err := model.Parse(tc.path)
if err != nil {
t.Fatalf("Parse: %v", err)
}
rootDir := filepath.Dir(filepath.Clean(tc.path))
incWarnings, _ := resolver.ResolveIncludes(p, fetcher.GitLabConfig{}, rootDir)
for _, w := range incWarnings {
t.Logf("include warning: %s", w)
}
extWarnings, err := resolver.Resolve(p)
if err != nil {
t.Fatalf("Resolve: %v", err)
}
for _, w := range extWarnings {
t.Logf("extends warning: job %q extends unknown %q", w.Job, w.Base)
}
findings := linter.Lint(p)
for _, f := range findings {
if f.Severity == linter.Error {
t.Errorf("unexpected error finding: %s", f)
}
}
})
}
}