diff --git a/CODEOWNERS b/.github/CODEOWNERS similarity index 100% rename from CODEOWNERS rename to .github/CODEOWNERS diff --git a/tools/pipeline/internal/pkg/changed/checkers.go b/tools/pipeline/internal/pkg/changed/checkers.go index f6c1e9fa9d..50351de4ae 100644 --- a/tools/pipeline/internal/pkg/changed/checkers.go +++ b/tools/pipeline/internal/pkg/changed/checkers.go @@ -23,6 +23,7 @@ var DefaultFileGroupCheckers = []FileGroupCheck{ FileGroupCheckerDocs, FileGroupCheckerEnos, FileGroupCheckerEnterprise, + FileGroupCheckerGithub, FileGroupCheckerGoToolchain, FileGroupCheckerPipeline, FileGroupCheckerProto, @@ -204,6 +205,15 @@ func FileGroupCheckerEnterprise(ctx context.Context, file *File) FileGroups { return nil } +// FileGroupCheckerGithub is a file group checker that groups Github files +func FileGroupCheckerGithub(ctx context.Context, file *File) FileGroups { + if hasBaseDir(file.Name(), ".github") { + return FileGroups{FileGroupGithub} + } + + return nil +} + // FileGroupCheckerGoToolchain is a file group checker that groups based on the file modifying the // Go toolchain or dependencies. func FileGroupCheckerGoToolchain(ctx context.Context, file *File) FileGroups { @@ -227,10 +237,11 @@ func FileGroupCheckerPipeline(ctx context.Context, file *File) FileGroups { switch { case hasBaseDir(name, ".build"), - hasBaseDir(name, ".github"), + hasBaseDir(name, filepath.Join(".github", "workflows")), + hasBaseDir(name, filepath.Join(".github", "actions")), + hasBaseDir(name, filepath.Join(".github", "scripts")), hasBaseDir(name, "scripts"), hasBaseDir(name, filepath.Join("tools", "pipeline")), - name == "CODEOWNERS", name == "Dockerfile", name == "Makefile": return FileGroups{FileGroupPipeline} diff --git a/tools/pipeline/internal/pkg/changed/checkers_test.go b/tools/pipeline/internal/pkg/changed/checkers_test.go index 2eb75d142f..de6a59fd56 100644 --- a/tools/pipeline/internal/pkg/changed/checkers_test.go +++ b/tools/pipeline/internal/pkg/changed/checkers_test.go @@ -16,11 +16,13 @@ func TestFileGroupDefaultCheckers(t *testing.T) { for filename, groups := range map[string]FileGroups{ ".build/entrypoint.sh": {FileGroupPipeline}, - ".github/actions/changed-files/actions.yml": {FileGroupPipeline}, - ".github/workflows/build.yml": {FileGroupPipeline}, - ".github/workflows/build-artifacts-ce.yml": {FileGroupCommunity, FileGroupPipeline}, - ".github/workflows/build-artifacts-ent.yml": {FileGroupEnterprise, FileGroupPipeline}, - ".github/workflows/backport-ce-ent.yml": {FileGroupCommunity, FileGroupPipeline}, + ".github/actions/changed-files/actions.yml": {FileGroupGithub, FileGroupPipeline}, + ".github/workflows/build.yml": {FileGroupGithub, FileGroupPipeline}, + ".github/workflows/build-artifacts-ce.yml": {FileGroupCommunity, FileGroupGithub, FileGroupPipeline}, + ".github/workflows/build-artifacts-ent.yml": {FileGroupEnterprise, FileGroupGithub, FileGroupPipeline}, + ".github/workflows/backport-ce-ent.yml": {FileGroupCommunity, FileGroupGithub, FileGroupPipeline}, + ".github/scripts/pr_comment.sh": {FileGroupGithub, FileGroupPipeline}, + ".github/CODEOWNERS": {FileGroupGithub}, ".go-version": {FileGroupGoToolchain}, ".release/ibm-pao/eboms/5900-BJ8.essentials.csv": {FileGroupEnterprise}, "audit/backend_ce.go": {FileGroupGoApp, FileGroupCommunity}, @@ -62,7 +64,6 @@ func TestFileGroupDefaultCheckers(t *testing.T) { "vault_ent/requires_ent.go": {FileGroupGoApp, FileGroupEnterprise}, "website/content/api-docs/index.mdx": {FileGroupDocs}, "CHANGELOG.md": {FileGroupChangelog}, - "CODEOWNERS": {FileGroupPipeline}, "Dockerfile": {FileGroupPipeline}, "Makefile": {FileGroupPipeline}, "README.md": {FileGroupDocs}, diff --git a/tools/pipeline/internal/pkg/changed/file.go b/tools/pipeline/internal/pkg/changed/file.go index d6ca529a30..dc41902f7d 100644 --- a/tools/pipeline/internal/pkg/changed/file.go +++ b/tools/pipeline/internal/pkg/changed/file.go @@ -1,6 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 +// Package changed is a package for inspecting and categorizing changed files into groups package changed import ( @@ -20,7 +21,7 @@ type ( Files []*File // FileGroup is group name describing a class of file the changed file belongs to FileGroup string - // FileGroup is a set of groups a changed file belongs to. Use FileGroups.Add() instead of append() + // FileGroups is a set of groups a changed file belongs to. Use FileGroups.Add() instead of append() // to ensure uniqueness and ordering FileGroups []FileGroup ) @@ -32,6 +33,7 @@ const ( FileGroupDocs FileGroup = "docs" FileGroupEnos FileGroup = "enos" FileGroupEnterprise FileGroup = "enterprise" + FileGroupGithub FileGroup = "github" FileGroupGoApp FileGroup = "app" FileGroupGoToolchain FileGroup = "gotoolchain" FileGroupPipeline FileGroup = "pipeline"