feat: add lua universe package and stylua command to fmt check

Signed-off-by: teddylear <teddylear@protonmail.com>
This commit is contained in:
teddylear 2022-04-11 20:22:23 -04:00 committed by teddylear
parent 9a832b7119
commit 78ca8d66c4
4 changed files with 78 additions and 0 deletions

View File

@ -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"
},
]
}
}

View File

@ -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

View File

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

View File

@ -0,0 +1,9 @@
setup() {
load '../../../../bats_helpers'
common_setup
}
@test "lua" {
dagger "do" -p ./fmtCheck.cue test
}