Skip to content
Merged
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
14 changes: 7 additions & 7 deletions tests/checks/ci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func TestCICheckFailsWhenRequiredAssetsAreMissing(t *testing.T) {

func TestCICheckPassesWhenRequiredAssetsExist(t *testing.T) {
dir := t.TempDir()
writeFile(t, filepath.Join(dir, ".github", "workflows", "ci.yml"), "name: ci\njobs:\n test:\n steps:\n - uses: actions/checkout@v4\n - run: go test ./...\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "cd.yml"), "name: cd\njobs:\n release-please:\n steps:\n - uses: googleapis/release-please-action@v5\n - run: echo RELEASE_PLEASE_TOKEN\n - run: echo uses: ./.github/workflows/release.yml\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "release.yml"), "name: release\njobs:\n build-release:\n steps:\n - uses: goreleaser/goreleaser-action@v7\n - run: echo sync-homebrew-formula\n - run: echo Formula/codeguard.rb\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "ci.yml"), "name: ci\njobs:\n test:\n steps:\n - uses: actions/checkout@8f3c2b1a4d5e6f7890abc1234567890abc123456\n - run: go test ./...\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "cd.yml"), "name: cd\njobs:\n release-please:\n steps:\n - uses: googleapis/release-please-action@8f3c2b1a4d5e6f7890abc1234567890abc123456\n - run: echo RELEASE_PLEASE_TOKEN\n - run: echo uses: ./.github/workflows/release.yml\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "release.yml"), "name: release\njobs:\n build-release:\n steps:\n - uses: goreleaser/goreleaser-action@8f3c2b1a4d5e6f7890abc1234567890abc123456\n - run: echo sync-homebrew-formula\n - run: echo Formula/codeguard.rb\n")
writeFile(t, filepath.Join(dir, ".goreleaser.yaml"), "version: 2\n")
writeFile(t, filepath.Join(dir, ".github", "release-please-config.json"), "{}\n")
writeFile(t, filepath.Join(dir, ".release-please-manifest.json"), "{\n \".\": \"0.1.0\"\n}\n")
Expand Down Expand Up @@ -211,9 +211,9 @@ func ciRuleMessages(report codeguard.Report, ruleID string) []string {

func TestCICheckAllowsEmptyReleaseFileOverride(t *testing.T) {
dir := t.TempDir()
writeFile(t, filepath.Join(dir, ".github", "workflows", "ci.yml"), "name: ci\njobs:\n test:\n steps:\n - uses: actions/checkout@v4\n - run: make codeguard-ci\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "cd.yml"), "name: cd\njobs:\n release-please:\n steps:\n - uses: googleapis/release-please-action@v5\n - run: echo RELEASE_PLEASE_TOKEN\n - run: echo uses: ./.github/workflows/release.yml\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "release.yml"), "name: release\njobs:\n build-release:\n steps:\n - uses: goreleaser/goreleaser-action@v7\n - run: echo sync-homebrew-formula\n - run: echo Formula/codeguard.rb\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "ci.yml"), "name: ci\njobs:\n test:\n steps:\n - uses: actions/checkout@8f3c2b1a4d5e6f7890abc1234567890abc123456\n - run: make codeguard-ci\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "cd.yml"), "name: cd\njobs:\n release-please:\n steps:\n - uses: googleapis/release-please-action@8f3c2b1a4d5e6f7890abc1234567890abc123456\n - run: echo RELEASE_PLEASE_TOKEN\n - run: echo uses: ./.github/workflows/release.yml\n")
writeFile(t, filepath.Join(dir, ".github", "workflows", "release.yml"), "name: release\njobs:\n build-release:\n steps:\n - uses: goreleaser/goreleaser-action@8f3c2b1a4d5e6f7890abc1234567890abc123456\n - run: echo sync-homebrew-formula\n - run: echo Formula/codeguard.rb\n")
writeFile(t, filepath.Join(dir, "Makefile"), "codeguard-ci:\n\tgo test ./...\n")
writeFile(t, filepath.Join(dir, "scripts", "commit.sh"), "#!/usr/bin/env bash\n")

Expand All @@ -234,7 +234,7 @@ func TestCICheckAllowsEmptyReleaseFileOverride(t *testing.T) {
RequiredContains: []string{"googleapis/release-please-action", "uses: ./.github/workflows/release.yml", "RELEASE_PLEASE_TOKEN"},
}, {
Path: ".github/workflows/release.yml",
RequiredContains: []string{"goreleaser/goreleaser-action@v7", "sync-homebrew-formula", "Formula/codeguard.rb"},
RequiredContains: []string{"goreleaser/goreleaser-action@8f3c2b1a4d5e6f7890abc1234567890abc123456", "sync-homebrew-formula", "Formula/codeguard.rb"},
}}

report, err := codeguard.Run(context.Background(), cfg)
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestRunScanFolderWithoutConfigUsesDefaultProfile(t *testing.T) {
writeScanTestFile(t, filepath.Join(dir, "sub", "Makefile"), "test:\n\tgo test ./...\n")
writeScanTestFile(t, filepath.Join(dir, "sub", "README.md"), "# Configless scan\n\nRun `make test`.\n")
writeScanTestFile(t, filepath.Join(dir, "sub", "AGENTS.md"), "# Agent Notes\n\n## Build & test\n- `make test` runs the unit suite.\n")
writeScanTestFile(t, filepath.Join(dir, "sub", ".github", "workflows", "ci.yml"), "name: ci\non: [push]\njobs:\n test:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - run: go test ./...\n")
writeScanTestFile(t, filepath.Join(dir, "sub", ".github", "workflows", "ci.yml"), "name: ci\non: [push]\njobs:\n test:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@8f3c2b1a4d5e6f7890abc1234567890abc123456\n - run: go test ./...\n")

var stdout, stderr bytes.Buffer
code := cli.Run([]string{"scan", "-folder", "sub", "-profile", "startup"}, strings.NewReader(""), &stdout, &stderr)
Expand Down
Loading