ci: fixed performance issues, converted more fields to hidden
Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
parent
8e2f3eb21d
commit
2a9cf1ce7c
@ -37,11 +37,7 @@ let GolangCILintVersion = "1.44.0"
|
|||||||
// base image for the Go linter
|
// base image for the Go linter
|
||||||
// https://golangci-lint.run/usage/install/#docker
|
// https://golangci-lint.run/usage/install/#docker
|
||||||
goLinter: _goLinter.output
|
goLinter: _goLinter.output
|
||||||
_goLinter: docker.#Build & {
|
_goLinter: docker.#Pull & {
|
||||||
steps: [
|
source: "index.docker.io/golangci/golangci-lint:v\(GolangCILintVersion)"
|
||||||
docker.#Pull & {
|
|
||||||
source: "index.docker.io/golangci/golangci-lint:v\(GolangCILintVersion)"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
ci/main.cue
37
ci/main.cue
@ -8,13 +8,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
engine.#Plan & {
|
engine.#Plan & {
|
||||||
|
|
||||||
|
// FIXME: Ideally we would want to automatically set the platform's arch identical to the host
|
||||||
|
// to avoid the performance hit caused by qemu (linter goes from <3s to >3m when arch is x86)
|
||||||
|
platform: "linux/aarch64"
|
||||||
|
|
||||||
inputs: {
|
inputs: {
|
||||||
params: {
|
params: {
|
||||||
// FIXME: until we support a better way
|
// FIXME: until we support a better way
|
||||||
os: string | *"darwin"
|
os: string | *"darwin"
|
||||||
arch: string | *"amd64"
|
arch: string | *"amd64"
|
||||||
|
|
||||||
// FIXME: implement condition actions using params
|
// FIXME: implement condition actions using params until we have a
|
||||||
|
// better way to select specific actions
|
||||||
}
|
}
|
||||||
|
|
||||||
directories: {
|
directories: {
|
||||||
@ -29,20 +35,23 @@ engine.#Plan & {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
goModCache: engine.#CacheDir & {
|
_goModCache: "go mod cache": {
|
||||||
id: "go mod cache"
|
dest: "/gomodcache"
|
||||||
|
contents: engine.#CacheDir & {
|
||||||
|
id: "go mod cache"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baseImages: #Images
|
_baseImages: #Images
|
||||||
|
|
||||||
source: "dagger source code": {
|
_source: "dagger source code": {
|
||||||
contents: inputs.directories.source.contents
|
contents: inputs.directories.source.contents
|
||||||
dest: "/usr/src/dagger"
|
dest: "/usr/src/dagger"
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: build only if the linter passed
|
// FIXME: build only if the linter passed
|
||||||
build: bash.#Run & {
|
build: bash.#Run & {
|
||||||
input: baseImages.goBuilder
|
input: _baseImages.goBuilder
|
||||||
|
|
||||||
env: {
|
env: {
|
||||||
GOMODCACHE: mounts["go mod cache"].dest
|
GOMODCACHE: mounts["go mod cache"].dest
|
||||||
@ -59,27 +68,23 @@ engine.#Plan & {
|
|||||||
./cmd/dagger/
|
./cmd/dagger/
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
|
workdir: mounts["dagger source code"].dest
|
||||||
mounts: {
|
mounts: {
|
||||||
source
|
_source
|
||||||
|
_goModCache
|
||||||
"go mod cache": {
|
|
||||||
dest: "/gomodcache"
|
|
||||||
contents: goModCache
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
workdir: mounts["dagger source code"].dest
|
|
||||||
export: directories: "/build": _
|
export: directories: "/build": _
|
||||||
}
|
}
|
||||||
|
|
||||||
goLint: bash.#Run & {
|
goLint: bash.#Run & {
|
||||||
input: baseImages.goLinter
|
input: _baseImages.goLinter
|
||||||
|
|
||||||
// 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"
|
script: contents: "golangci-lint run -v --timeout 5m"
|
||||||
workdir: mounts["dagger source code"].dest
|
workdir: mounts["dagger source code"].dest
|
||||||
mounts: {
|
mounts: {
|
||||||
source
|
_source
|
||||||
|
_goModCache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user