Skip to content

Commit f1632f7

Browse files
github-actions: add initial linter workflow
1 parent fbc5afa commit f1632f7

File tree

2 files changed

+162
-1
lines changed

2 files changed

+162
-1
lines changed

.github/workflows/lint.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Lint
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "master" branch
8+
push:
9+
branches: [ "master" ]
10+
pull_request:
11+
branches: [ "master" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
Build_LuaLS:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
outputs:
24+
luals_version: ${{ steps.get-luaLS-version.outputs.version }}
25+
26+
# Steps represent a sequence of tasks that will be executed as part of the job
27+
steps:
28+
- name: Get LuaLS version
29+
id: get-luaLS-version
30+
run: |
31+
version=$(curl https://api.github.com/repos/LuaLS/lua-language-server/releases/latest | jq -r '.tag_name')
32+
echo $version
33+
echo "version=$version" >> $GITHUB_OUTPUT
34+
shell: bash
35+
36+
- name: Cache Lua Language Server
37+
uses: actions/cache@v4
38+
id: cache
39+
with:
40+
key: ${{ steps.get-luaLS-version.outputs.version }}
41+
path: ./luals
42+
43+
- uses: actions/checkout@v4
44+
if: steps.cache.outputs.cache-hit != 'true'
45+
with:
46+
repository: LuaLS/lua-language-server
47+
ref: ${{ steps.get-luaLS-version.outputs.version }}
48+
path: ./luals
49+
50+
# Runs a single command using the runners shell
51+
- name: Install Lua Language Server
52+
if: steps.cache.outputs.cache-hit != 'true'
53+
working-directory: ./luals
54+
run: |
55+
echo Running Lua Language Server build script
56+
sudo apt-get update
57+
sudo apt-get -y install ninja-build
58+
./make.sh
59+
60+
Lint_LuaJit:
61+
needs: Build_LuaLS
62+
runs-on: ubuntu-latest
63+
steps:
64+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
65+
- uses: actions/checkout@v4
66+
with:
67+
path: ./file-browser
68+
- name: Cache Lua Language Server
69+
uses: actions/cache@v4
70+
id: cache
71+
with:
72+
key: ${{ needs.Build_LuaLS.outputs.luals_version }}
73+
path: ./luals
74+
- name: Run LuaLS
75+
run: |
76+
jq '."runtime.version" = "LuaJIT"' ./file-browser/.luarc.json > ./file-browser/.luarc.json
77+
./luals/bin/lua-language-server --check ./file-browser --logpath ./log/luajit
78+
79+
- uses: actions/upload-artifact@v4
80+
with:
81+
name: LuaJIT Lint Report
82+
path: ./log/luajit/check.json
83+
84+
- name: Test output
85+
shell: bash
86+
run: |
87+
FILE="./log/luajit/check.json"
88+
if [ "$(jq 'length' "$FILE")" -gt 0 ]; then
89+
jq '.' "$FILE" >&2
90+
exit 1
91+
fi
92+
93+
Lint_Lua51:
94+
needs: Build_LuaLS
95+
runs-on: ubuntu-latest
96+
steps:
97+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
98+
- uses: actions/checkout@v4
99+
with:
100+
path: ./file-browser
101+
- name: Cache Lua Language Server
102+
uses: actions/cache@v4
103+
id: cache
104+
with:
105+
key: ${{ needs.Build_LuaLS.outputs.luals_version }}
106+
path: ./luals
107+
- name: Run LuaLS
108+
run: |
109+
jq '."runtime.version" = "Lua 5.1"' ./file-browser/.luarc.json > ./file-browser/.luarc.json
110+
./luals/bin/lua-language-server --check ./file-browser --logpath ./log/5.1
111+
112+
- uses: actions/upload-artifact@v4
113+
with:
114+
name: Lua 5.1 Lint Report
115+
path: ./log/5.1/check.json
116+
117+
- name: Test output
118+
shell: bash
119+
run: |
120+
FILE="./log/5.1/check.json"
121+
if [ "$(jq 'length' "$FILE")" -gt 0 ]; then
122+
jq '.' "$FILE" >&2
123+
exit 1
124+
fi
125+
126+
Lint_Lua52:
127+
needs: Build_LuaLS
128+
runs-on: ubuntu-latest
129+
steps:
130+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
131+
- uses: actions/checkout@v4
132+
with:
133+
path: ./file-browser
134+
- name: Cache Lua Language Server
135+
uses: actions/cache@v4
136+
id: cache
137+
with:
138+
key: ${{ needs.Build_LuaLS.outputs.luals_version }}
139+
path: ./luals
140+
- name: Run LuaLS
141+
run: |
142+
jq '."runtime.version" = "Lua 5.2"' ./file-browser/.luarc.json > ./file-browser/.luarc.json
143+
./luals/bin/lua-language-server --check ./file-browser --logpath ./log/lua5.2
144+
145+
- uses: actions/upload-artifact@v4
146+
with:
147+
name: Lua 5.2 Lint Report
148+
path: ./log/lua5.2/check.json
149+
150+
- name: Test output
151+
shell: bash
152+
run: |
153+
FILE="./log/lua5.2/check.json"
154+
if [ "$(jq 'length' "$FILE")" -gt 0 ]; then
155+
jq '.' "$FILE" >&2
156+
exit 1
157+
fi

.luarc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
22
"runtime.version": "LuaJIT",
3+
"runtime.path": [
4+
"?.lua",
5+
"?/init.lua",
6+
"../../script-modules/?.lua"
7+
],
38
"diagnostics.workspaceDelay": 1000,
49
"diagnostics.groupFileStatus": {
510
"await": "Any",
611
"luadoc": "Any",
7-
// "strong": "Any",
812
"type-check": "Any",
913
"unbalanced": "Any"
1014
},

0 commit comments

Comments
 (0)