chore(actions) + refactor(lint): include linting in workflow

Also fixes various lint warnings/errors by selene.
This commit is contained in:
Erica Marigold 2024-04-26 11:30:49 +05:30
parent 107406d50f
commit dcbc2208c3
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1
5 changed files with 46 additions and 36 deletions

View file

@ -1,43 +1,46 @@
name: CI name: CI
on: on:
push: push:
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
defaults: defaults:
run: run:
shell: bash shell: bash
jobs: jobs:
fmt: fmt:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install tooling - name: Install tooling
uses: ok-nick/setup-aftman@v0.4.2 uses: ok-nick/setup-aftman@v0.4.2
with: with:
cache: true cache: true
- name: Check formatting - name: Check formatting
run: stylua -c -v . run: stylua -c -v .
lint: lint:
needs: ["fmt"] needs: ["fmt"]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
run: wally install run: wally install
- name: Install tooling - name: Install tooling
uses: ok-nick/setup-aftman@v0.4.2 uses: ok-nick/setup-aftman@v0.4.2
with: with:
cache: true cache: true
- name: Analyze - name: Analyze
run: luau-lsp analyze --ignore="Packages/**" --settings=".vscode/settings.json" lib/ examples/ mod.luau run: luau-lsp analyze --ignore="Packages/**" --settings=".vscode/settings.json" lib/ examples/ mod.luau
- name: lint
run: selene .

View file

@ -4,3 +4,4 @@ stylua = "JohnnyMorganz/StyLua@0.20.0"
luau-lsp = "JohnnyMorganz/luau-lsp@1.27.0" luau-lsp = "JohnnyMorganz/luau-lsp@1.27.0"
darklua = "seaofvoices/darklua@0.13.0" darklua = "seaofvoices/darklua@0.13.0"
wally = "UpliftGames/wally@0.3.2" wally = "UpliftGames/wally@0.3.2"
selene = "Kampfkarren/selene@0.26.1"

View file

@ -80,7 +80,7 @@ export type Future<T> = typeof(Future) & {
_status: Status, _status: Status,
} }
local function _constructor<T>(fn: (Signal<()>, Signal<T, Status>) -> (), args: { any }) local function _constructor<T>(fn: (Signal<()>, Signal<T, Status>) -> ())
return setmetatable( return setmetatable(
{ {
_thread = coroutine.create(fn), _thread = coroutine.create(fn),
@ -115,7 +115,7 @@ function Future.new<T>(fn: (...any) -> T, args: { any })
local ret = fn(table.unpack(args)) local ret = fn(table.unpack(args))
retEvt:Fire(ret, "ready") retEvt:Fire(ret, "ready")
end, args) end)
end end
--[=[ --[=[
@ -132,9 +132,9 @@ function Future.try<T>(fn: (...any) -> T, args: { any })
spawnEvt:Fire() spawnEvt:Fire()
local ok, ret = pcall(fn, table.unpack(args)) local ok, ret = pcall(fn, table.unpack(args))
local result: Result<T, string> = if ok then Ok(ret) else Err(ret) local res: Result<T, string> = if ok then Ok(ret) else Err(ret)
retEvt:Fire(result, "ready") retEvt:Fire(res, "ready")
end, args) end)
end end
--[=[ --[=[

View file

@ -453,7 +453,8 @@ function Result.inspectErr<T, E>(self: Result<T, E>, op: (val: E) -> ()): Result
end end
-- TODO: Iterator traits -- TODO: Iterator traits
function Result.iter(): never -- selene: allow(unused_variable)
function Result.iter<T, E>(self: Result<T, E>): never
return error("Unimplemented: `Result:iter()`") return error("Unimplemented: `Result:iter()`")
end end
@ -540,6 +541,7 @@ function Result.unwrap<T, E>(self: Result<T, E>): T | never
end end
-- TODO: default values for types -- TODO: default values for types
-- selene: allow(unused_variable)
function Result.unwrapOrDefault<T, E>(self: Result<T, E>): never function Result.unwrapOrDefault<T, E>(self: Result<T, E>): never
return error("Unimplemented: `Result:unwrapOrDefault()`") return error("Unimplemented: `Result:unwrapOrDefault()`")
end end
@ -596,9 +598,11 @@ function Result.unwrapErr<T, E>(self: Result<T, E>): E | never
end end
-- TODO: How the fuck do I implement this? -- TODO: How the fuck do I implement this?
-- selene: allow(unused_variable)
function Result.intoOk<T, E>(self: Result<T, E>): never function Result.intoOk<T, E>(self: Result<T, E>): never
return error("Unimplemented: `Result:intoOk()`") return error("Unimplemented: `Result:intoOk()`")
end end
-- selene: allow(unused_variable)
function Result.intoErr<T, E>(self: Result<T, E>): never function Result.intoErr<T, E>(self: Result<T, E>): never
return error("Unimplemented: `Result:intoErr()`") return error("Unimplemented: `Result:intoErr()`")
end end

2
selene.toml Normal file
View file

@ -0,0 +1,2 @@
std = "luau"
exclude = ["Packages/*"]