Add profile loading and process execution
This commit is contained in:
@@ -108,7 +108,7 @@ func checkImportDirections(packages []listedPackage) error {
|
||||
var violations []string
|
||||
|
||||
for _, pkg := range packages {
|
||||
if !strings.HasPrefix(pkg.ImportPath, modulePath+"/internal/") {
|
||||
if !isInternalPackage(pkg.ImportPath) {
|
||||
continue
|
||||
}
|
||||
for _, imported := range pkg.Imports {
|
||||
@@ -149,6 +149,11 @@ func checkImportDirections(packages []listedPackage) error {
|
||||
return errors.New(strings.Join(violations, "\n"))
|
||||
}
|
||||
|
||||
func isInternalPackage(path string) bool {
|
||||
return strings.HasPrefix(path, modulePath+"/internal/") ||
|
||||
strings.HasPrefix(path, modulePath+"/") && strings.Contains(strings.TrimPrefix(path, modulePath), "/internal/")
|
||||
}
|
||||
|
||||
func forbiddenRuntimeDependency(path string) bool {
|
||||
for _, part := range strings.Split(strings.ToLower(path), "/") {
|
||||
switch part {
|
||||
|
||||
@@ -110,10 +110,14 @@ func TestActualRepositoryBoundaries(t *testing.T) {
|
||||
func TestInternalPackagesCannotImportPublicFacades(t *testing.T) {
|
||||
packages := []listedPackage{
|
||||
{ImportPath: modulePath + "/internal/operations", Imports: []string{modulePath}},
|
||||
{ImportPath: modulePath + "/cmd/releasekit/internal/cli", Imports: []string{modulePath + "/buildinfo"}},
|
||||
{ImportPath: modulePath},
|
||||
{ImportPath: modulePath + "/buildinfo"},
|
||||
}
|
||||
err := checkImportDirections(packages)
|
||||
if err == nil || !strings.Contains(err.Error(), "internal package "+modulePath+"/internal/operations imports public or command package "+modulePath) {
|
||||
if err == nil ||
|
||||
!strings.Contains(err.Error(), "internal package "+modulePath+"/internal/operations imports public or command package "+modulePath) ||
|
||||
!strings.Contains(err.Error(), "internal package "+modulePath+"/cmd/releasekit/internal/cli imports public or command package "+modulePath+"/buildinfo") {
|
||||
t.Fatalf("checkImportDirections() error = %v, want internal-to-facade violation", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user