Skip to content

Commit

Permalink
github-actions: add initial linter workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
CogentRedTester committed Jan 27, 2025
1 parent fbc5afa commit 95dc16e
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 1 deletion.
157 changes: 157 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# This is a basic workflow to help you get started with Actions

name: Lint

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
Build_LuaLS:
# The type of runner that the job will run on
runs-on: ubuntu-latest

outputs:
luals_version: ${{ steps.get-luaLS-version.outputs.version }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Get LuaLS version
id: get-luaLS-version
run: |
version=$(curl https://api.github.com/repos/LuaLS/lua-language-server/releases/latest | jq -r '.tag_name')
echo $version
echo "version=$version" >> $GITHUB_OUTPUT
shell: bash

- name: Cache Lua Language Server
uses: actions/cache@v4
id: cache
with:
key: ${{ steps.get-luaLS-version.outputs.version }}
path: ./luals

- uses: actions/checkout@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
repository: LuaLS/lua-language-server
ref: ${{ steps.get-luaLS-version.outputs.version }}
path: ./luals

# Runs a single command using the runners shell
- name: Install Lua Language Server
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ./luals
run: |
echo Running Lua Language Server build script
sudo apt-get update
sudo apt-get -y install ninja-build
./make.sh
Lint_LuaJit:
needs: Build_LuaLS
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
path: ./file-browser
- name: Cache Lua Language Server
uses: actions/cache@v4
id: cache
with:
key: ${{ needs.Build_LuaLS.outputs.luals_version }}
path: ./luals
- name: Run LuaLS
run: |
./luals/bin/lua-language-server --check ./file-browser --logpath ./log/luajit --configpath <<< $(jq '."runtime.version" = "LuaJIT"' ./file-browser/.luarc.json )
cat ./log/check.json
- uses: actions/upload-artifact@v4
with:
name: LuaJIT Lint Report
path: ./log/luajit/check.json

- name: Test output
shell: bash
run: |
FILE="./log/check.json"
if [ "$(jq 'length' "$FILE")" -gt 0 ]; then
jq '.' "$FILE" >&2
exit 1
fi
Lint_Lua51:
needs: Build_LuaLS
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
path: ./file-browser
- name: Cache Lua Language Server
uses: actions/cache@v4
id: cache
with:
key: ${{ needs.Build_LuaLS.outputs.luals_version }}
path: ./luals
- name: Run LuaLS
run: |
./luals/bin/lua-language-server --check ./file-browser --logpath ./log/5.1 --configpath <<< $(jq '."runtime.version" = "Lua 5.1"' ./file-browser/.luarc.json )
cat ./log/check.json
- uses: actions/upload-artifact@v4
with:
name: Lua 5.1 Lint Report
path: ./log/5.1/check.json

- name: Test output
shell: bash
run: |
FILE="./log/check.json"
if [ "$(jq 'length' "$FILE")" -gt 0 ]; then
jq '.' "$FILE" >&2
exit 1
fi
Lint_Lua52:
needs: Build_LuaLS
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
path: ./file-browser
- name: Cache Lua Language Server
uses: actions/cache@v4
id: cache
with:
key: ${{ needs.Build_LuaLS.outputs.luals_version }}
path: ./luals
- name: Run LuaLS
run: |
./luals/bin/lua-language-server --check ./file-browser --logpath ./log/lua5.2 --configpath <<< $(jq '."runtime.version" = "Lua 5.2"' ./file-browser/.luarc.json )
cat ./log/check.json
- uses: actions/upload-artifact@v4
with:
name: Lua 5.2 Lint Report
path: ./log/lua5.2/check.json

- name: Test output
shell: bash
run: |
FILE="./log/check.json"
if [ "$(jq 'length' "$FILE")" -gt 0 ]; then
jq '.' "$FILE" >&2
exit 1
fi
6 changes: 5 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"runtime.version": "LuaJIT",
"runtime.path": [
"?.lua",
"?/init.lua",
"../../script-modules/?.lua"
],
"diagnostics.workspaceDelay": 1000,
"diagnostics.groupFileStatus": {
"await": "Any",
"luadoc": "Any",
// "strong": "Any",
"type-check": "Any",
"unbalanced": "Any"
},
Expand Down

0 comments on commit 95dc16e

Please sign in to comment.