Skip to content

Commit

Permalink
add mocks check
Browse files Browse the repository at this point in the history
Signed-off-by: bupd <[email protected]>
  • Loading branch information
bupd committed Feb 10, 2025
1 parent 34b891f commit afbef5b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions .dagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (m *Harbor) registryBuilder(ctx context.Context) *dagger.File {
WithEnvVariable("BUILDTAGS", "include_oss include_gcs").
WithEnvVariable("GO111MODULE", "auto").
WithEnvVariable("CGO_ENABLED", "0").
WithWorkdir("/go/src/github.com/docker").
WithWorkdir("/go/src/github.com/docker").
WithExec([]string{"git", "clone", "-b", REGISTRY_SRC_TAG, DISTRIBUTION_SRC}).
WithWorkdir("distribution").
WithExec([]string{"git", "apply", "/harbor/.dagger/registry/redis.patch"}).
Expand Down Expand Up @@ -370,7 +370,7 @@ func (m *Harbor) buildBinary(ctx context.Context, platform Platform, pkg Package
}

func (m *Harbor) buildPortal(ctx context.Context, platform Platform, pkg Package) *dagger.Directory {
fmt.Println("🛠️ Building Harbor Core...")
fmt.Println("🛠️ Building Harbor Portal...")
os, arch, err := parsePlatform(string(platform))
if err != nil {
log.Fatalf("Error parsing platform: %v", err)
Expand Down Expand Up @@ -444,3 +444,22 @@ func (m *Harbor) lintAPIs(_ context.Context) *dagger.Directory {

return temp
}

// Check for outdated mocks
func (m *Harbor) mocksCheck(_ context.Context) *dagger.Directory {
// script to check if mocks are outdated
script := `
res=$(git status -s src/ | awk '{ printf("%s\n", $2) }' | egrep .*.go)
if [ -n "$res" ]; then
echo "Mocks of the interface are out of date..."
echo "$res"
exit 1
fi
`

return dag.Container().From("golang:latest").
WithMountedDirectory("/src", m.Source).
WithWorkdir("/src").
WithExec([]string{"sh", "-c", script}).
Directory("/src")
}
1 change: 1 addition & 0 deletions .dagger/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (m *Harbor) Lint(ctx context.Context) (string, error) {
func (m *Harbor) lint(ctx context.Context) *dagger.Container {
fmt.Println("👀 Running linter.")
m.lintAPIs(ctx)
m.mocksCheck(ctx)
m.Source = m.genAPIs(ctx)
linter := dag.Container().
From("golangci/golangci-lint:"+GOLANGCILINT_VERSION+"-alpine").
Expand Down

0 comments on commit afbef5b

Please sign in to comment.