From 78ca8d66c4cc901e65d06cc95a1c3e8c0b66dfea Mon Sep 17 00:00:00 2001 From: teddylear Date: Mon, 11 Apr 2022 20:22:23 -0400 Subject: [PATCH] feat: add lua universe package and stylua command to fmt check Signed-off-by: teddylear --- .../teddylear@protonmail.com/lua/fmtCheck.cue | 43 +++++++++++++++++++ .../lua/test/data/hello/example.lua | 7 +++ .../lua/test/fmtCheck.cue | 19 ++++++++ .../lua/test/test.bats | 9 ++++ 4 files changed, 78 insertions(+) create mode 100644 pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/fmtCheck.cue create mode 100644 pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/data/hello/example.lua create mode 100644 pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/fmtCheck.cue create mode 100644 pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/test.bats diff --git a/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/fmtCheck.cue b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/fmtCheck.cue new file mode 100644 index 00000000..19addf41 --- /dev/null +++ b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/fmtCheck.cue @@ -0,0 +1,43 @@ +package lua + +import ( + "dagger.io/dagger" + "universe.dagger.io/docker" +) + +// Checks lua format via Stylua +#StyluaCheck: { + // Files to Copy + source: dagger.#FS + + // Any extra formatting args + extraArgs: [...string] + + _run: docker.#Build & { + steps: [ + docker.#Pull & { + source: "rust:latest" + }, + + docker.#Run & { + command: { + name: "cargo" + args: ["install", "stylua"] + } + }, + + docker.#Copy & { + dest: "/tmp" + contents: source + }, + + docker.#Run & { + command: { + name: "stylua" + args: ["--check", "."] + extraArgs + } + workdir: "/tmp" + }, + ] + } +} diff --git a/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/data/hello/example.lua b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/data/hello/example.lua new file mode 100644 index 00000000..9105831d --- /dev/null +++ b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/data/hello/example.lua @@ -0,0 +1,7 @@ +local function hello(offset) + local foo = {} + for i = 1, 10 do + table.insert(foo, i + offset) + end + return another_thing +end diff --git a/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/fmtCheck.cue b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/fmtCheck.cue new file mode 100644 index 00000000..f9fe7774 --- /dev/null +++ b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/fmtCheck.cue @@ -0,0 +1,19 @@ +package lua + +import ( + "dagger.io/dagger" + "universe.dagger.io/x/teddylear@protonmail.com/lua" +) + +dagger.#Plan & { + client: filesystem: "./data/hello": read: contents: dagger.#FS + + actions: test: { + simple: { + fmtCheck: lua.#StyluaCheck & { + source: client.filesystem."./data/hello".read.contents + } + } + } +} + diff --git a/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/test.bats b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/test.bats new file mode 100644 index 00000000..6d4e6d38 --- /dev/null +++ b/pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/test/test.bats @@ -0,0 +1,9 @@ +setup() { + load '../../../../bats_helpers' + + common_setup +} + +@test "lua" { + dagger "do" -p ./fmtCheck.cue test +}