Merge pull request #2138 from teddylear/lua-package

Creating lua package for fmt
This commit is contained in:
Helder Correia 2022-04-12 22:29:37 +00:00 committed by GitHub
commit b2e87b8ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}