add CI steps #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint and Format | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- 'src/**/*.lua' | |
- 'test/**/*.lua' | |
- '*.rockspec' | |
pull_request: | |
paths: | |
- 'src/**/*.lua' | |
- 'test/**/*.lua' | |
- '*.rockspec' | |
permissions: | |
contents: read | |
actions: write | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Lua | |
uses: leafo/gh-actions-lua@v10 | |
with: | |
luaVersion: "5.4" | |
- name: Set up LuaRocks | |
uses: leafo/gh-actions-luarocks@v4 | |
- name: Debug Lua Environment | |
run: | | |
lua -v | |
luarocks --version | |
luarocks list | |
luarocks show luacheck --check-lua-versions | |
luarocks show lua-format --check-lua-versions | |
- name: Install dependencies | |
run: | | |
luarocks install luacheck | |
luarocks install lua-format | |
- name: Lint with Luacheck | |
run: luacheck src test | |
- name: Format with lua-format | |
run: lua-format -i src/**/*.lua test/**/*.lua | |
format: | |
needs: lint | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Set up Lua | |
uses: leafo/gh-actions-lua@v10 | |
with: | |
luaVersion: "5.4" | |
- name: Set up LuaRocks | |
uses: leafo/gh-actions-luarocks@v4 | |
- name: Install dependencies | |
run: | | |
luarocks install lua-format | |
- name: Format Lua files | |
run: lua-format -i src/*.lua | |
- name: Fix Markdown lint issues | |
uses: DavidAnson/markdownlint-cli2-action@v13 | |
with: | |
fix: true | |
globs: "**/*.md" | |
- name: Commit formatting changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "style: format code and markdown files" | |
branch: ${{ github.head_ref }} |