Skip to content

Commit 5697c8c

Browse files
committed
Create workflow for linting and unit test execution
1 parent 6d172eb commit 5697c8c

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

.docker/alpine/Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM alpine:3.19
2+
3+
ARG LUA_VERSION=5.2
4+
ARG LUA_MODULES="luaffi lunit luacheck luacov luacov-html"
5+
ARG LUA_ROCKS_SERVER="https://luarocks.org/dev"
6+
7+
RUN apk add --no-cache \
8+
bash \
9+
luajit \
10+
lua${LUA_VERSION} \
11+
lua${LUA_VERSION}-bit32 \
12+
\
13+
&& apk add --no-cache --virtual .build-deps \
14+
build-base \
15+
git \
16+
openssl-dev \
17+
lua${LUA_VERSION}-dev \
18+
luarocks${LUA_VERSION} \
19+
\
20+
&& ln -s /usr/bin/lua${LUA_VERSION} /usr/local/bin/lua \
21+
\
22+
&& for rock in ${LUA_MODULES}; do \
23+
luarocks-${LUA_VERSION} install --server=${LUA_ROCKS_SERVER} ${rock}; \
24+
done \
25+
\
26+
&& apk del .build-deps
27+
28+
ADD https://github.com/philips/lualint/raw/master/lualint /bin/lualint
29+
RUN chmod +x /bin/lualint \
30+
&& \
31+
ln -s /usr/bin/luac${LUA_VERSION} /usr/bin/luac \
32+
&& \
33+
ln -s /usr/local/share/lua/5.2 /usr/local/share/lua/5.1
34+
35+
RUN mkdir -p /github/workspace
36+
VOLUME ["/github/workspace"]
37+
38+
WORKDIR "/github/workspace"

.github/workflows/test.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Linting and Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
check:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Check out the repo
11+
uses: actions/checkout@v4
12+
13+
- name: Build the Docker image
14+
run: docker build .docker/alpine/ --tag ${{ github.repository }}-test:lua-5.2
15+
16+
- name: Run linter
17+
uses: addnab/docker-run-action@v3
18+
with:
19+
image: ${{ github.repository }}-test:lua-5.2
20+
options: -v ${{ github.workspace }}:/github/workspace
21+
run: |
22+
echo "Static luacheck ljsocket.lua"
23+
luacheck --config .luacheckrc \
24+
ljsocket.lua
25+
echo "Linting ljsocket.lua"
26+
lualint -s ljsocket.lua
27+
28+
- name: Bytecode verification
29+
uses: addnab/docker-run-action@v3
30+
with:
31+
image: ${{ github.repository }}-test:lua-5.2
32+
options: -v ${{ github.workspace }}:/github/workspace
33+
run: |
34+
echo "Checking JIT bytecode for ljsocket.lua"
35+
luajit -bl ljsocket.lua /dev/null
36+
echo "Checking bytecode for ljsocket.lua"
37+
luac -p ljsocket.lua
38+
39+
- name: Run unit tests
40+
uses: addnab/docker-run-action@v3
41+
with:
42+
image: ${{ github.repository }}-test:lua-5.2
43+
options: -v ${{ github.workspace }}:/github/workspace
44+
run: |
45+
lunit -i `which luajit` $(find test -name "*_test.lua")
46+
luacov ljsocket.lua

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea
2+
/luacov.report.out
3+
/luacov.stats.out

.luacheckrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Only allow symbols available in all Lua versions
2+
std = "min"
3+
4+
-- Get rid of "unused argument self"-warnings
5+
self = false
6+
7+
-- Include standard globals
8+
globals = {
9+
"bit",
10+
"unpack",
11+
"jit"
12+
}
13+
14+
-- Ignure unused arguments
15+
unused_args = false
16+
17+
-- Ignore too long lines
18+
max_line_length = false

0 commit comments

Comments
 (0)