Skip to content

Commit

Permalink
Add CI pipeline configuration and supporting files
Browse files Browse the repository at this point in the history
* **CI Workflow**: Add `.github/workflows/ci.yml` to configure the CI pipeline with steps for code checkout, Stylua formatting check, and Lua-Language-Server static analysis.
* **Stylua Configuration**: Add `stylua.toml` to configure Stylua with indentation, line settings, and exclude `lib/cc-tweaked`.
* **Lua-Language-Server Configuration**: Update `.luarc.json` to include `lib/cc-tweaked` in the workspace library and disable diagnostics for library files.
* **Output Parsing Script**: Add `parse_lua_ls_output.lua` to parse Lua-Language-Server JSON output and format it for GitHub Actions UI.
  • Loading branch information
jiriks74 committed Oct 24, 2024
1 parent b1841c3 commit 09d8a57
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on: [push, pull_request]

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Stylua
run: |
sudo apt-get update
sudo apt-get install -y stylua
- name: Run Stylua
run: |
stylua --config-path .stylua.toml . --exclude lib/cc-tweaked
static-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Lua-Language-Server
run: |
sudo apt-get update
sudo apt-get install -y lua-language-server
- name: Run Lua-Language-Server
continue-on-error: true
run: |
lua-language-server --logpath . --check .
- name: Parse Lua-Language-Server Output
run: |
lua parse_lua_ls_output.lua ./check.json
3 changes: 2 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"workspace.library": [
"./lib/cc-tweaked/",
"./lib/basalt/Basalt"
]
],
"diagnostics.libraryFiles": "Disable"
}
41 changes: 41 additions & 0 deletions parse_lua_ls_output.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local json = require("json")

local function parse_lua_ls_output(file_path)
local output_file = io.open(file_path, "r")
if not output_file then
error("Failed to open " .. file_path)
end

local output_data = output_file:read("*a")
output_file:close()

local parsed_data = json.decode(output_data)
if not parsed_data then
error("Failed to parse JSON data")
end

local has_issues = false

for _, diagnostic in ipairs(parsed_data) do
print(string.format("File: %s", diagnostic.uri))
for _, issue in ipairs(diagnostic.diagnostics) do
print(string.format(" Line: %d, Column: %d", issue.range.start.line, issue.range.start.character))
print(string.format(" Message: %s", issue.message))
print()
has_issues = true
end
end

if has_issues then
os.exit(1)
else
os.exit(0)
end
end

local file_path = arg[1]
if not file_path then
error("No file path provided")
end

parse_lua_ls_output(file_path)
13 changes: 13 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stylua Configuration File

# Indent settings
indent_type = "Spaces"
indent_width = 2

# Line settings
column_width = 80

# Exclude files and directories
exclude = {
"lib/cc-tweaked/**"
}

0 comments on commit 09d8a57

Please sign in to comment.