Skip to content

Commit

Permalink
fix(dagger): provide the .golangci.yaml via +defaultPath annotation. …
Browse files Browse the repository at this point in the history
…No need to copy it anymore.
  • Loading branch information
jochumdev committed Sep 5, 2024
1 parent fd8f68a commit 35e47da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 262 deletions.
258 changes: 0 additions & 258 deletions .github/.golangci.yaml

This file was deleted.

11 changes: 7 additions & 4 deletions .github/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ func (m *GoOrb) Modules(ctx context.Context, root *dagger.Directory) ([]string,
}

// Lints all modules starting from `root` with golangci-lint
func (m *GoOrb) Lint(ctx context.Context, root *dagger.Directory) (*AllResult, error) {
func (m *GoOrb) Lint(
ctx context.Context,
root *dagger.Directory,
// +defaultPath="/.golangci.yaml"
golangciConfig *dagger.File,
) (*AllResult, error) {
lintWorker := func(ctx context.Context, wg *sync.WaitGroup, input <-chan string, res chan<- *WorkerResult, root *dagger.Directory) {
defer wg.Done()
for dir := range input {
Expand All @@ -121,8 +126,6 @@ func (m *GoOrb) Lint(ctx context.Context, root *dagger.Directory) (*AllResult, e
default:
}

config := dag.CurrentModule().Source().File(".golangci.yaml")

out, err := dag.Container().From("golangci/golangci-lint").
WithMountedCache("/go/pkg/mod",
dag.CacheVolume("go-mod"),
Expand All @@ -141,7 +144,7 @@ func (m *GoOrb) Lint(ctx context.Context, root *dagger.Directory) (*AllResult, e
WithMountedCache("/root/.cache/golangci-lint", dag.CacheVolume("golangci-lint")).
WithDirectory("/work/src", root.Directory(dir)).
WithWorkdir("/work/src").
WithMountedFile("/work/config", config).
WithMountedFile("/work/config", golangciConfig).
WithExec([]string{"golangci-lint", "run", "--config", "/work/config"}).
Stdout(ctx)

Expand Down

0 comments on commit 35e47da

Please sign in to comment.