From bf05ba8eda2665b3836251a1fca2be491ce1b794 Mon Sep 17 00:00:00 2001 From: Tomo <68489118+Tomodachi94@users.noreply.github.com> Date: Sat, 10 Dec 2022 12:15:11 -0800 Subject: [PATCH] Add automatic linting with GitHub Actions --- .cc-tweaked.selene.yaml | 90 +++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yaml | 41 +++++++++++++++++ .selene.toml | 5 +++ 3 files changed, 136 insertions(+) create mode 100644 .cc-tweaked.selene.yaml create mode 100644 .github/workflows/lint.yaml create mode 100644 .selene.toml diff --git a/.cc-tweaked.selene.yaml b/.cc-tweaked.selene.yaml new file mode 100644 index 0000000..acad704 --- /dev/null +++ b/.cc-tweaked.selene.yaml @@ -0,0 +1,90 @@ +--- +base: lua52 + +globals: + package.cpath: + removed: true + collectgarbage: + removed: true + _HOST: + property: read-only + _CC_DEFAULT_SETTINGS: + property: read-only + _CC_DISABLE_LUA51_FEATURES: + property: read-only + sleep: + property: read-only + args: + - type: number + required: true + write: + property: read-only + args: + - type: string + required: true + printError: + property: read-only + args: + - type: "..." + required: true + read: + property: read-only + args: + - type: string + required: false + - type: table + required: false + - type: function + required: false + - type: string + required: false + colors: + property: read-only + colours: + property: read-only + commands: + property: read-only + disk: + property: read-only + fs: + property: read-only + gps: + property: read-only + help: + property: read-only + http: + property: read-only + io: + property: read-only + keys: + property: read-only + multishell: + property: read-only + os: + property: read-only + paintutils: + property: read-only + parallel: + property: read-only + peripheral: + property: read-only + pocket: + property: read-only + rednet: + property: read-only + redstone: + property: read-only + settings: + property: read-only + shell: + property: read-only + term: + property: read-only + textutils: + property: read-only + turtle: + property: read-only + vector: + property: read-only + window: + property: read-only diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..41123d6 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,41 @@ +name: Linting + +on: + push: + paths: ["**.lua", ".github/workflows/lint.yaml"] + pull_request: + paths: ["**.lua", ".github/workflows/lint.yaml"] + workflow_dispatch: + +jobs: + lint-selene: + name: Lint Lua with Selene + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: NTBBloodbath/selene-action@v1.0.0 + with: + # Github secret token + token: ${{ secrets.GITHUB_TOKEN }} + # selene arguments + args: . --config .selene.toml + # selene version + version: 0.23.1 + + # Multiple linters never hurt :) + lint-illuaminate: + name: Lint Lua with Illuaminate + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Lint Lua code + run: | + test -d bin || mkdir bin + test -f bin/illuaminate || wget -q -Obin/illuaminate https://squiddev.cc/illuaminate/linux-x86-64/illuaminate + chmod +x bin/illuaminate + bin/illuaminate lint diff --git a/.selene.toml b/.selene.toml new file mode 100644 index 0000000..5239867 --- /dev/null +++ b/.selene.toml @@ -0,0 +1,5 @@ +std = ".cc-tweaked.selene" +exclude = ["./unicorn/semver.lua"] + +[lints] +incorrect_standard_library_use = "allow" # Workaround for https://github.com/Kampfkarren/selene/issues/467