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
on:
push:
pull_request:
workflow_dispatch:
push:
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash
run:
shell: bash
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install tooling
uses: ok-nick/setup-aftman@v0.4.2
with:
cache: true
- name: Install tooling
uses: ok-nick/setup-aftman@v0.4.2
with:
cache: true
- name: Check formatting
run: stylua -c -v .
- name: Check formatting
run: stylua -c -v .
lint:
needs: ["fmt"]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
lint:
needs: ["fmt"]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: wally install
- name: Install dependencies
run: wally install
- name: Install tooling
uses: ok-nick/setup-aftman@v0.4.2
with:
cache: true
- name: Install tooling
uses: ok-nick/setup-aftman@v0.4.2
with:
cache: true
- name: Analyze
run: luau-lsp analyze --ignore="Packages/**" --settings=".vscode/settings.json" lib/ examples/ mod.luau
- name: Analyze
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"
darklua = "seaofvoices/darklua@0.13.0"
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,
}
local function _constructor<T>(fn: (Signal<()>, Signal<T, Status>) -> (), args: { any })
local function _constructor<T>(fn: (Signal<()>, Signal<T, Status>) -> ())
return setmetatable(
{
_thread = coroutine.create(fn),
@ -115,7 +115,7 @@ function Future.new<T>(fn: (...any) -> T, args: { any })
local ret = fn(table.unpack(args))
retEvt:Fire(ret, "ready")
end, args)
end)
end
--[=[
@ -132,9 +132,9 @@ function Future.try<T>(fn: (...any) -> T, args: { any })
spawnEvt:Fire()
local ok, ret = pcall(fn, table.unpack(args))
local result: Result<T, string> = if ok then Ok(ret) else Err(ret)
retEvt:Fire(result, "ready")
end, args)
local res: Result<T, string> = if ok then Ok(ret) else Err(ret)
retEvt:Fire(res, "ready")
end)
end
--[=[

View file

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

2
selene.toml Normal file
View file

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