ci: lint dagger using dagger
- `Makefile` now uses `dagger do lint` to lint - GHA uses dagger to lint Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
56
ci/cue/lint.cue
Normal file
56
ci/cue/lint.cue
Normal file
@@ -0,0 +1,56 @@
|
||||
package cue
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
|
||||
"universe.dagger.io/alpine"
|
||||
"universe.dagger.io/docker"
|
||||
"universe.dagger.io/bash"
|
||||
)
|
||||
|
||||
#Lint: {
|
||||
source: dagger.#FS
|
||||
|
||||
docker.#Build & {
|
||||
steps: [
|
||||
alpine.#Build & {
|
||||
packages: bash: _
|
||||
packages: curl: _
|
||||
packages: git: _
|
||||
},
|
||||
|
||||
docker.#Copy & {
|
||||
contents: source
|
||||
"source": "go.mod"
|
||||
dest: "go.mod"
|
||||
},
|
||||
|
||||
// Install CUE
|
||||
bash.#Run & {
|
||||
script: contents: #"""
|
||||
export CUE_VERSION="$(grep cue ./go.mod | cut -d' ' -f2 | head -1 | sed -E 's/\.[[:digit:]]\.[[:alnum:]]+-[[:alnum:]]+$//')"
|
||||
export CUE_TARBALL="cue_${CUE_VERSION}_linux_amd64.tar.gz"
|
||||
echo "Installing cue version $CUE_VERSION"
|
||||
curl -L "https://github.com/cue-lang/cue/releases/download/${CUE_VERSION}/${CUE_TARBALL}" | tar zxf - -C /usr/local/bin
|
||||
cue version
|
||||
"""#
|
||||
},
|
||||
|
||||
// CACHE: copy only *.cue files
|
||||
docker.#Copy & {
|
||||
contents: source
|
||||
include: ["*.cue"]
|
||||
dest: "/cue"
|
||||
},
|
||||
|
||||
// LINT
|
||||
bash.#Run & {
|
||||
workdir: "/cue"
|
||||
script: contents: #"""
|
||||
find . -name '*.cue' -not -path '*/cue.mod/*' -print | time xargs -t -n 1 -P 8 cue fmt -s
|
||||
test -z "$(git status -s . | grep -e "^ M" | grep "\.cue" | cut -d ' ' -f3 | tee /dev/stderr)"
|
||||
"""#
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
@@ -22,7 +22,7 @@ import (
|
||||
source: "golangci/golangci-lint:v\(version)"
|
||||
}
|
||||
|
||||
container: go.#Container & {
|
||||
go.#Container & {
|
||||
"source": source
|
||||
input: _image.output
|
||||
command: {
|
||||
|
@@ -20,7 +20,7 @@ import (
|
||||
source: "tmknom/markdownlint:\(version)"
|
||||
}
|
||||
|
||||
container: docker.#Run & {
|
||||
docker.#Run & {
|
||||
input: _image.output
|
||||
mounts: "source": {
|
||||
dest: "/src"
|
||||
|
@@ -17,7 +17,7 @@ import (
|
||||
source: "koalaman/shellcheck-alpine:v\(version)"
|
||||
}
|
||||
|
||||
container: docker.#Run & {
|
||||
docker.#Run & {
|
||||
input: _image.output
|
||||
mounts: "source": {
|
||||
dest: "/src"
|
||||
|
Reference in New Issue
Block a user