From 517262dfdee1fa06d8c01be35ed5e7a53f23664c Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 1 Apr 2022 11:33:18 -0700 Subject: [PATCH] ci: lint shell Signed-off-by: Andrea Luzzardi --- ci/cue.mod/module.cue | 1 + ci/cue.mod/pkg | 1 + ci/main.cue | 6 ++++++ ci/pkg/shellcheck/shellcheck.cue | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 ci/cue.mod/module.cue create mode 120000 ci/cue.mod/pkg create mode 100644 ci/pkg/shellcheck/shellcheck.cue diff --git a/ci/cue.mod/module.cue b/ci/cue.mod/module.cue new file mode 100644 index 00000000..c511367d --- /dev/null +++ b/ci/cue.mod/module.cue @@ -0,0 +1 @@ +module: "github.com/dagger/dagger/ci" \ No newline at end of file diff --git a/ci/cue.mod/pkg b/ci/cue.mod/pkg new file mode 120000 index 00000000..b49d704a --- /dev/null +++ b/ci/cue.mod/pkg @@ -0,0 +1 @@ +../../pkg \ No newline at end of file diff --git a/ci/main.cue b/ci/main.cue index 2d1f0ea5..9f66dfab 100644 --- a/ci/main.cue +++ b/ci/main.cue @@ -8,6 +8,8 @@ import ( "universe.dagger.io/docker" "universe.dagger.io/go" "universe.dagger.io/go/golangci" + + "github.com/dagger/dagger/ci/pkg/shellcheck" ) dagger.#Plan & { @@ -90,6 +92,10 @@ dagger.#Plan & { version: "1.45" } + shell: shellcheck.#Lint & { + source: _source + } + cue: docker.#Build & { steps: [ alpine.#Build & { diff --git a/ci/pkg/shellcheck/shellcheck.cue b/ci/pkg/shellcheck/shellcheck.cue new file mode 100644 index 00000000..b11bf62c --- /dev/null +++ b/ci/pkg/shellcheck/shellcheck.cue @@ -0,0 +1,34 @@ +package shellcheck + +import ( + "dagger.io/dagger" + + "universe.dagger.io/docker" +) + +#Lint: { + // Source code + source: dagger.#FS + + // shellcheck version + version: *"0.8.0" | string + + _image: docker.#Pull & { + source: "koalaman/shellcheck-alpine:v\(version)" + } + + container: docker.#Run & { + input: _image.output + mounts: "source": { + dest: "/src" + contents: source + } + workdir: "/src" + command: { + name: "sh" + args: ["-c", #""" + shellcheck $(find . -type f \( -iname \*.bats -o -iname \*.bash -o -iname \*.sh \) -not -path "*/node_modules/*" -not -path "*/bats-*/*") + """#] + } + } +}