Check Lua Code #24
This file contains hidden or 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
| on: | |
| push: | |
| paths: | |
| - '**.lua' # Run if pushed commits include a change to a Lua (.lua) file. | |
| - 'extension.xml' # Run if pushed commits include a change to extension.xml. | |
| - '.stylua' # Run if pushed commits include a change to .stylua. | |
| - '.github/workflows/lua.yml' # Run if pushed commits change this workflow. | |
| pull_request: | |
| paths: | |
| - '**.lua' # Run if pull request includes a change to a Lua (.lua) file. | |
| - 'extension.xml' # Run if pull request includes a change to extension.xml. | |
| - '.stylua' # Run if pushed commits include a change to .stylua. | |
| schedule: | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: | |
| name: Check Lua Code | |
| jobs: | |
| stylua: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - uses: JohnnyMorganz/stylua-action@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| version: latest | |
| args: --config-path .stylua.toml --check . | |
| luacheck: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout default branch | |
| uses: actions/checkout@v4 | |
| # Determine extension name | |
| - name: Get Extension Name from XML | |
| id: getnamefromxml | |
| uses: mavrosxristoforos/get-xml-info@2.0 | |
| with: | |
| xml-file: 'extension.xml' | |
| xpath: '//properties//name' | |
| - name: Format Extension Name | |
| id: removenameprefix | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.getnamefromxml.outputs.info }} | |
| regex: '[A-Za-z]+:\s+' | |
| replacement: '' | |
| - id: removenametabs | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removenameprefix.outputs.value }} | |
| regex: " " | |
| replacement: '' | |
| - id: removeapostrophes | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removenametabs.outputs.value }} | |
| regex: "'" | |
| replacement: '' | |
| - id: removenamepunctuation | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removeapostrophes.outputs.value }} | |
| regex: '[^\w\s].*' | |
| replacement: '' | |
| - id: removenamespaces | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removenamepunctuation.outputs.value }} | |
| regex: '\s' | |
| replacement: '' | |
| - id: namelowercase | |
| uses: ASzc/change-string-case-action@v6 | |
| with: | |
| string: ${{ steps.removenamespaces.outputs.value }} | |
| # Determine extension author | |
| - name: Get Author Name from XML | |
| id: getauthorfromxml | |
| uses: mavrosxristoforos/get-xml-info@2.0 | |
| with: | |
| xml-file: 'extension.xml' | |
| xpath: '//properties//author' | |
| - name: Format author name | |
| id: removeauthorprefix | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.getauthorfromxml.outputs.info }} | |
| regex: '[A-Za-z]+:\s' | |
| replacement: '' | |
| - id: removeauthortabs | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removeauthorprefix.outputs.value }} | |
| regex: " " | |
| replacement: '' | |
| - id: removeauthorapostrophes | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removeauthortabs.outputs.value }} | |
| regex: "'" | |
| replacement: '' | |
| - id: removeauthorpunctuation | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removeauthorapostrophes.outputs.value }} | |
| regex: '[^\w\s].*' | |
| replacement: '' | |
| - id: removeauthorspaces | |
| uses: bmos/regex-property-action@v1 | |
| with: | |
| value: ${{ steps.removeauthorpunctuation.outputs.value }} | |
| regex: '\s' | |
| replacement: '' | |
| - id: authorlowercase | |
| uses: ASzc/change-string-case-action@v6 | |
| with: | |
| string: ${{ steps.removeauthorspaces.outputs.value }} | |
| - name: Install Lua/LuaJIT | |
| uses: leafo/gh-actions-lua@v10 | |
| with: | |
| luaVersion: 5.1 | |
| - id: cache-luacheck | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.config/luacheck | |
| key: luacheck | |
| # Process extension code | |
| - name: Running luacheck | |
| uses: nebularg/actions-luacheck@v1 | |
| with: | |
| files: '.' | |
| config: https://raw.githubusercontent.com/FG-Unofficial-Developers-Guild/FG-luacheck/main/.luacheckrc | |
| args: '--no-color --std +${{ steps.namelowercase.outputs.lowercase }}${{ steps.authorlowercase.outputs.lowercase }} --exclude-files .install/*' | |
| annotate: 'warning' |