Skip to content

Commit 4c24508

Browse files
committed
Add a CI linter test for static code checks
1 parent 1c107fe commit 4c24508

5 files changed

Lines changed: 94 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,55 @@ on:
66
branches: [ dev ]
77
workflow_dispatch:
88
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
container: ghcr.io/musholic/lastepochplanner-tests:latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Download LuaLS Addons
17+
run: |
18+
git clone --depth 1 https://github.com/LuaLS/LLS-Addons.git .lls-addons
19+
cd .lls-addons
20+
git submodule update --init --depth 1 addons/busted
21+
git submodule update --init --depth 1 addons/luassert
22+
git submodule update --init --depth 1 addons/luafilesystem
23+
24+
- name: Patch .luarc.json for CI + clean up
25+
run: |
26+
sed -i 's|${addons}|.lls-addons/addons|g' .luarc.json
27+
# Delete the Lua 5.3 specific file so it doesn't break LuaJIT parsing
28+
rm -f runtime/lua/sha1/lua53_ops.lua
29+
# Delete the ModCache which slows down type checking
30+
rm -f src/Data/ModCache.lua
31+
- name: Type Check Code Base
32+
run: lua-language-server --check . --check_format=json --logpath=.
33+
- name: Annotate GitHub PR from check.json
34+
if: always()
35+
run: |
36+
LOG_FILE="check.json"
37+
if [ -f "$LOG_FILE" ]; then
38+
cat $LOG_FILE | jq -r --arg ws "$GITHUB_WORKSPACE" '
39+
to_entries[] |
40+
# 1. Strip "file://..." prefix and convert to relative path
41+
(.key | sub("file://"; "") | ltrimstr($ws) | ltrimstr("/")) as $file |
42+
43+
# 2. Iterate over issues
44+
.value[] |
45+
# 3. Map LSP severity (1:Error, 2:Warning) to GH format
46+
(if .severity == 1 then "error" else "warning" end) as $sev |
47+
48+
# 4. Convert 0-indexed LSP (line 55, char 0) to 1-indexed GH (line 56, col 1)
49+
# GitHub requires line and col. Optional: endLine, endColumn
50+
"::\($sev) file=\($file),line=\(.range.start.line + 1),col=\(.range.start.character + 1),endLine=\(.range.end.line + 1),endColumn=\(.range.end.character + 1)::\($file): \(.message) (code: \(.code))"
51+
'
52+
else
53+
echo "::warning::check.json not found, skipping annotations."
54+
fi
955
run_tests:
1056
runs-on: ubuntu-latest
11-
container: ghcr.io/pathofbuildingcommunity/pathofbuilding-tests:latest
57+
container: ghcr.io/musholic/lastepochplanner-tests:latest
1258
steps:
1359
- name: Checkout
1460
uses: actions/checkout@v4
@@ -19,7 +65,7 @@ jobs:
1965
run: cd src; luacov-coveralls --repo-token=${{ secrets.github_token }} -e TestData -e Data -e runtime
2066
check_modcache:
2167
runs-on: ubuntu-latest
22-
container: ghcr.io/pathofbuildingcommunity/pathofbuilding-tests:latest
68+
container: ghcr.io/musholic/lastepochplanner-tests:latest
2369
steps:
2470
- name: Install git dependency
2571
run: apk add git

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ src/Export/ggpk/*.dll
3333
src/TreeData/**/*.scm
3434
src/TreeData/**/*.txt
3535
src/TreeData/**/*.bat
36-
36+
3737
# PoB Trader
3838
*_currency_values.json
3939

.luarc.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"runtime": {
3+
"version": "LuaJIT"
4+
},
5+
"workspace": {
6+
"library": [
7+
"runtime/lua",
8+
"${addons}/busted/module/library",
9+
"${addons}/luassert/module/library",
10+
"${addons}/luafilesystem/module/library"
11+
],
12+
"ignoreDir": ["runtime", "src/Export"]
13+
},
14+
"diagnostics": {
15+
"globals": ["UpdateProgress"],
16+
"severity": {
17+
"need-check-nil": "Information",
18+
"param-type-mismatch": "Information",
19+
"undefined-field": "Information",
20+
"undefined-doc-class": "Information",
21+
"undefined-doc-name": "Information",
22+
"missing-return": "Information",
23+
"inject-field": "Information",
24+
"assign-type-mismatch": "Information",
25+
"cast-local-type": "Information"
26+
},
27+
"disable": ["lowercase-global"]
28+
},
29+
"hint": {
30+
"enable": true
31+
},
32+
"Lua.format.defaultConfig": {
33+
"indent_style": "tab",
34+
"indent_size": "4"
35+
},
36+
"workspace.checkThirdParty": false
37+
}

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.18 AS base
1+
FROM alpine:3.22 AS base
22
# Common dependencies
33
RUN apk add --no-cache cmake readline-dev build-base tar
44

@@ -18,13 +18,16 @@ RUN git clone https://github.com/LuaJIT/LuaJIT && cd LuaJIT && git checkout 871d
1818
RUN cd LuaJIT && make
1919

2020
FROM buildbase AS emmyluadebugger
21-
RUN git clone --depth 1 --branch 1.7.1 https://github.com/EmmyLua/EmmyLuaDebugger
21+
RUN git clone --depth 1 --branch 1.8.7 https://github.com/EmmyLua/EmmyLuaDebugger
2222
RUN cd EmmyLuaDebugger && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ../ && make
2323

2424
FROM base
2525
# Luarocks packages dependencies
2626
RUN apk add --no-cache curl unzip openssl
2727

28+
# Install other dependencies useful for the CI
29+
RUN apk add --no-cache libxml2-utils git lua-language-server jq
30+
2831
RUN --mount=type=cache,from=buildBase,source=/opt,target=/opt make -C /opt/lua-5.1.5/ install
2932
RUN --mount=type=cache,from=luarocks,source=/opt,target=/opt make -C /opt/luarocks-3.7.0/ install
3033

src/globals.meta.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---@meta
2+
3+
lfs = require("lfs")

0 commit comments

Comments
 (0)