ci: simplify code and reduce boiler plate + fixed caching
Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
parent
555966d040
commit
029a0d270f
45
ci/main.cue
45
ci/main.cue
@ -25,7 +25,10 @@ dagger.#Plan & {
|
||||
|
||||
directories: {
|
||||
// dagger repository
|
||||
source: path: "../"
|
||||
source: {
|
||||
path: "../"
|
||||
exclude: ["./ci"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,25 +38,33 @@ dagger.#Plan & {
|
||||
}
|
||||
|
||||
actions: {
|
||||
_goModCache: "go mod cache": {
|
||||
dest: "/gomodcache"
|
||||
_mountGoCache: {
|
||||
mounts: "go mod cache": {
|
||||
dest: "/root/.gocache"
|
||||
contents: dagger.#CacheDir & {
|
||||
id: "go mod cache"
|
||||
}
|
||||
}
|
||||
env: GOMODCACHE: mounts["go mod cache"].dest
|
||||
}
|
||||
|
||||
_baseImages: #Images
|
||||
|
||||
_sourceCode: "dagger source code": {
|
||||
_mountSourceCode: {
|
||||
mounts: "dagger source code": {
|
||||
contents: inputs.directories.source.contents
|
||||
dest: "/usr/src/dagger"
|
||||
}
|
||||
workdir: mounts["dagger source code"].dest
|
||||
}
|
||||
|
||||
_baseImages: #Images
|
||||
|
||||
build: bash.#Run & {
|
||||
_mountSourceCode
|
||||
_mountGoCache
|
||||
|
||||
input: _baseImages.goBuilder
|
||||
|
||||
env: {
|
||||
GOMODCACHE: mounts["go mod cache"].dest
|
||||
GOOS: strings.ToLower(inputs.params.os)
|
||||
GOARCH: strings.ToLower(inputs.params.arch)
|
||||
// Makes sure the linter completes before starting the build
|
||||
@ -69,27 +80,21 @@ dagger.#Plan & {
|
||||
./cmd/dagger/
|
||||
"""#
|
||||
|
||||
workdir: mounts["dagger source code"].dest
|
||||
mounts: {
|
||||
_sourceCode
|
||||
_goModCache
|
||||
}
|
||||
|
||||
export: directories: "/build": _
|
||||
}
|
||||
|
||||
goLint: bash.#Run & {
|
||||
_mountSourceCode
|
||||
_mountGoCache
|
||||
|
||||
input: _baseImages.goLinter
|
||||
|
||||
script: contents: "golangci-lint run -v --timeout 5m"
|
||||
workdir: mounts["dagger source code"].dest
|
||||
mounts: {
|
||||
_sourceCode
|
||||
_goModCache
|
||||
}
|
||||
}
|
||||
|
||||
cueLint: bash.#Run & {
|
||||
_mountSourceCode
|
||||
|
||||
input: _baseImages.cue
|
||||
|
||||
script: contents: #"""
|
||||
@ -98,10 +103,6 @@ dagger.#Plan & {
|
||||
# Check that all formatted files where committed
|
||||
test -z $(git status -s . | grep -e '^ M' | grep .cue | cut -d ' ' -f3)
|
||||
"""#
|
||||
workdir: mounts["dagger source code"].dest
|
||||
mounts: {
|
||||
_sourceCode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user