ci: implemented go lint
Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
parent
679bb30148
commit
f17c470feb
11
ci/base.cue
11
ci/base.cue
@ -5,6 +5,7 @@ import (
|
||||
)
|
||||
|
||||
let GoVersion = "1.17"
|
||||
let GolangCILintVersion = "1.44.0"
|
||||
|
||||
// Base container images used for the CI
|
||||
images: {
|
||||
@ -31,4 +32,14 @@ images: {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// base image for the Go linter
|
||||
// https://golangci-lint.run/usage/install/#docker
|
||||
goLinter: docker.#Build & {
|
||||
steps: [
|
||||
docker.#Pull & {
|
||||
source: "index.docker.io/golangci/golangci-lint:v\(GolangCILintVersion)"
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
24
ci/main.cue
24
ci/main.cue
@ -3,9 +3,7 @@ package main
|
||||
import (
|
||||
"strings"
|
||||
|
||||
// "dagger.io/dagger"
|
||||
"dagger.io/dagger/engine"
|
||||
|
||||
"universe.dagger.io/bash"
|
||||
)
|
||||
|
||||
@ -35,6 +33,12 @@ engine.#Plan & {
|
||||
id: "go mod cache"
|
||||
}
|
||||
|
||||
source: "dagger source code": {
|
||||
contents: inputs.directories.source.contents
|
||||
dest: "/usr/src/dagger"
|
||||
}
|
||||
|
||||
// FIXME: build only if the linter passed
|
||||
build: bash.#Run & {
|
||||
input: images.goBuilder.output
|
||||
|
||||
@ -54,10 +58,7 @@ engine.#Plan & {
|
||||
"""#
|
||||
|
||||
mounts: {
|
||||
"dagger source code": {
|
||||
contents: inputs.directories.source.contents
|
||||
dest: "/usr/src/dagger"
|
||||
}
|
||||
source
|
||||
|
||||
"go mod cache": {
|
||||
dest: "/gomodcache"
|
||||
@ -68,5 +69,16 @@ engine.#Plan & {
|
||||
workdir: mounts["dagger source code"].dest
|
||||
export: directories: "/build": _
|
||||
}
|
||||
|
||||
goLint: bash.#Run & {
|
||||
input: images.goLinter.output
|
||||
|
||||
// FIXME: the source volume is too slow, taking >3m on docker for mac (vs < 2sec on the host machine)
|
||||
script: contents: "golangci-lint run -v --timeout 5m"
|
||||
workdir: mounts["dagger source code"].dest
|
||||
mounts: {
|
||||
source
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user