From c81f9e52c04fda902ca3bd0cfd0fcb7dc3ec0ce0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 3 Jul 2024 20:49:04 +0300 Subject: [PATCH] ci: check style & lint Lua code --- .github/workflows/check.yml | 62 +++++++++++++++++++++++++++++++++++++ .luacheckrc | 10 ++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/check.yml create mode 100644 .luacheckrc diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..22dd33d --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,62 @@ +name: "Style & Lint" + +on: + workflow_dispatch: + pull_request: + push: + branches: ["main"] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + + concurrency: + group: ${{ github.workflow }}-${{ matrix.lua_version }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + + strategy: + matrix: + lua_version: [5.1] + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Lua setup" + uses: leafo/gh-actions-lua@v10 + with: + luaVersion: ${{ matrix.lua_version }} + + - name: "Install Luarocks" + uses: leafo/gh-actions-luarocks@v4 + + - name: "Install luacheck" + run: luarocks install luacheck 1.1.1 + + - name: "Lint" + run: luacheck lua/ + + style: + runs-on: ubuntu-latest + + concurrency: + group: ${{ github.workflow }}-${{ matrix.stylua_version }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + + strategy: + matrix: + stylua_version: [0.19.1] + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Check style via Stylua" + uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: ${{ matrix.stylua_version }} + args: --check lua diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..5a7b280 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,10 @@ +-- vim: ft=lua tw=80 + +-- Don't report unused self arguments of methods. +self = false + +ignore = { + "631", -- max_line_length +} + +globals = { "vim" }