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 +}