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
57
ci/main.cue
57
ci/main.cue
@ -25,7 +25,10 @@ dagger.#Plan & {
|
|||||||
|
|
||||||
directories: {
|
directories: {
|
||||||
// dagger repository
|
// dagger repository
|
||||||
source: path: "../"
|
source: {
|
||||||
|
path: "../"
|
||||||
|
exclude: ["./ci"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,27 +38,35 @@ dagger.#Plan & {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
_goModCache: "go mod cache": {
|
_mountGoCache: {
|
||||||
dest: "/gomodcache"
|
mounts: "go mod cache": {
|
||||||
contents: dagger.#CacheDir & {
|
dest: "/root/.gocache"
|
||||||
id: "go mod cache"
|
contents: dagger.#CacheDir & {
|
||||||
|
id: "go mod cache"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
env: GOMODCACHE: mounts["go mod cache"].dest
|
||||||
|
}
|
||||||
|
|
||||||
|
_mountSourceCode: {
|
||||||
|
mounts: "dagger source code": {
|
||||||
|
contents: inputs.directories.source.contents
|
||||||
|
dest: "/usr/src/dagger"
|
||||||
|
}
|
||||||
|
workdir: mounts["dagger source code"].dest
|
||||||
}
|
}
|
||||||
|
|
||||||
_baseImages: #Images
|
_baseImages: #Images
|
||||||
|
|
||||||
_sourceCode: "dagger source code": {
|
|
||||||
contents: inputs.directories.source.contents
|
|
||||||
dest: "/usr/src/dagger"
|
|
||||||
}
|
|
||||||
|
|
||||||
build: bash.#Run & {
|
build: bash.#Run & {
|
||||||
|
_mountSourceCode
|
||||||
|
_mountGoCache
|
||||||
|
|
||||||
input: _baseImages.goBuilder
|
input: _baseImages.goBuilder
|
||||||
|
|
||||||
env: {
|
env: {
|
||||||
GOMODCACHE: mounts["go mod cache"].dest
|
GOOS: strings.ToLower(inputs.params.os)
|
||||||
GOOS: strings.ToLower(inputs.params.os)
|
GOARCH: strings.ToLower(inputs.params.arch)
|
||||||
GOARCH: strings.ToLower(inputs.params.arch)
|
|
||||||
// Makes sure the linter completes before starting the build
|
// Makes sure the linter completes before starting the build
|
||||||
"__depends": "\(goLint.exit)"
|
"__depends": "\(goLint.exit)"
|
||||||
}
|
}
|
||||||
@ -69,27 +80,21 @@ dagger.#Plan & {
|
|||||||
./cmd/dagger/
|
./cmd/dagger/
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
workdir: mounts["dagger source code"].dest
|
|
||||||
mounts: {
|
|
||||||
_sourceCode
|
|
||||||
_goModCache
|
|
||||||
}
|
|
||||||
|
|
||||||
export: directories: "/build": _
|
export: directories: "/build": _
|
||||||
}
|
}
|
||||||
|
|
||||||
goLint: bash.#Run & {
|
goLint: bash.#Run & {
|
||||||
|
_mountSourceCode
|
||||||
|
_mountGoCache
|
||||||
|
|
||||||
input: _baseImages.goLinter
|
input: _baseImages.goLinter
|
||||||
|
|
||||||
script: contents: "golangci-lint run -v --timeout 5m"
|
script: contents: "golangci-lint run -v --timeout 5m"
|
||||||
workdir: mounts["dagger source code"].dest
|
|
||||||
mounts: {
|
|
||||||
_sourceCode
|
|
||||||
_goModCache
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cueLint: bash.#Run & {
|
cueLint: bash.#Run & {
|
||||||
|
_mountSourceCode
|
||||||
|
|
||||||
input: _baseImages.cue
|
input: _baseImages.cue
|
||||||
|
|
||||||
script: contents: #"""
|
script: contents: #"""
|
||||||
@ -98,10 +103,6 @@ dagger.#Plan & {
|
|||||||
# Check that all formatted files where committed
|
# Check that all formatted files where committed
|
||||||
test -z $(git status -s . | grep -e '^ M' | grep .cue | cut -d ' ' -f3)
|
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