Skip to content

Commit

Permalink
feat: add lua universe package and stylua command to fmt check
Browse files Browse the repository at this point in the history
Signed-off-by: teddylear <teddylear@protonmail.com>
  • Loading branch information
teddylear committed Apr 12, 2022
1 parent 9a832b7 commit 78ca8d6
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pkg/universe.dagger.io/x/teddylear@protonmail.com/lua/fmtCheck.cue
Original file line number Diff line number Diff line change
@@ -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"
},
]
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
setup() {
load '../../../../bats_helpers'

common_setup
}

@test "lua" {
dagger "do" -p ./fmtCheck.cue test
}

0 comments on commit 78ca8d6

Please sign in to comment.