Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- "*.lua"
- ".stylua.toml"
- ".luacheckrc"
- ".pre-commit-config.yaml"
- "lux.toml"
- "lux.lock"
- ".github/workflows/static-analysis.yml"
Expand All @@ -19,32 +20,45 @@ on:
- "*.lua"
- ".stylua.toml"
- ".luacheckrc"
- ".pre-commit-config.yaml"
- "lux.toml"
- "lux.lock"
- ".github/workflows/static-analysis.yml"
- ".github/workflows/lux.yml"

jobs:
luacheck:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Luacheck
uses: lunarmodules/luacheck@v1.2.0
- name: Install Lux
uses: lumen-oss/gh-actions-lux@v1
with:
version: 0.46.0
# lux's auto-installed static Lua can't dlopen C modules
# (`lfs.so: undefined symbol: lua_gettop`), which `lx lint`
# needs via luacheck → luafilesystem. A distro Lua links
# liblua dynamically, so luafilesystem loads fine when lux
# detects and uses the system interpreter instead.
- name: Install system Lua 5.1
run: sudo apt-get update && sudo apt-get install -y lua5.1 liblua5.1-0-dev
- name: Lint with lux
run: lx --lua-version 5.1 lint

stylua:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Stylua
uses: JohnnyMorganz/stylua-action@v5
- name: Install Lux
uses: lumen-oss/gh-actions-lux@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes
# CLI arguments
args: --check .
version: 0.46.0
- name: Check formatting with lux
run: |
lx --lua-version 5.1 fmt
git diff --exit-code

lua-language-server:
runs-on: ubuntu-latest
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ repos:

- repo: local
hooks:
- id: stylua_check
name: Stylua Check
entry: stylua
- id: lux_fmt
name: Lux Fmt
entry: lx --lua-version 5.1 fmt
language: system
pass_filenames: true
pass_filenames: false
types_or: [lua]
stages: [pre-commit]

- id: luacheck
name: Luacheck
entry: luacheck
- id: lux_lint
name: Lux Lint
entry: lx --lua-version 5.1 lint
language: system
pass_filenames: true
pass_filenames: false
types_or: [lua]
stages: [pre-commit]

Expand Down
22 changes: 17 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ You will need:
- Java JDK 17 or 21
- The following tools available in your terminal:
- pre-commit (<https://pre-commit.com/#install>)
- `stylua`
- `luacheck`
- `make`
- `git`
- `lx` (<https://lux.lumen-labs.org/>) — for package
management (`lux.toml` is the single source of truth
for the luarocks package)
for the luarocks package), formatting (`lx fmt`)
and linting (`lx lint`)
- `make`
- `git`

> On Linux, `lx lint` needs a dynamically-linked Lua 5.1,
> otherwise luacheck's `luafilesystem` module fails to load
> (`lfs.so: undefined symbol: lua_gettop`):
>
> ```bash
> sudo apt-get install lua5.1 liblua5.1-0-dev
> ```
>
> macOS works out of the box.

#### First build

Expand Down Expand Up @@ -108,6 +117,9 @@ make lux-sync
# Build the project
make lux-build

# Format via lux (stylua)
make lux-fmt

# Lint via lux (luacheck)
make lux-lint

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean test test-fail-fast test-e2e lux-sync lux-build lux-lint lux-test
.PHONY: clean test test-fail-fast test-e2e lux-sync lux-build lux-fmt lux-lint lux-test

all: hooks test

Expand Down Expand Up @@ -67,6 +67,9 @@ lux-sync:
lux-build:
lx --lua-version 5.1 build

lux-fmt:
lx --lua-version 5.1 fmt

lux-lint:
lx --lua-version 5.1 lint

Expand Down
Loading