From 26fa949c129ff5538601886cd49035c0f34e5ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20=C3=85kesson?= <66364872+pataxis@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:11:34 +0100 Subject: [PATCH] lint: Update to super-linter/super-linter The linter has been blue badged. --- .github/workflows/linter.yml | 2 +- LINT.md | 44 ++++++++++++------------------------ 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index f89091ec..c8a80a20 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 0 - run: cat .github/super-linter.env >> "$GITHUB_ENV" - name: Lint Code Base - uses: github/super-linter/slim@v5 + uses: super-linter/super-linter/slim@v5 env: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/LINT.md b/LINT.md index 7edf9f2c..030ae1d0 100644 --- a/LINT.md +++ b/LINT.md @@ -7,8 +7,9 @@ get a pull request approved. When you create a pull request, a set of linters will run syntax and format checks on different file types in GitHub actions by making use of a tool called -[super-linter](https://github.com/github/super-linter). If any of the linters -gives an error, this will be shown in the action connected to the pull request. +[super-linter](https://github.com/super-linter/super-linter). If any of the +linters gives an error, this will be shown in the action connected to the pull +request. In order to fasten up development, it's possible to run linters as part of your local development environment. @@ -18,7 +19,7 @@ local development environment. Since super-linter is using a Docker image in GitHub Actions, users of other editors may run it locally to lint the codebase. For complete instructions and guidance, see super-linter page for [running -locally](https://github.com/github/super-linter/blob/main/docs/run-linter-locally.md). +locally](https://github.com/super-linter/super-linter/blob/main/docs/run-linter-locally.md). ### VS Code @@ -36,22 +37,26 @@ docker run --rm \ -v $PWD:/tmp/lint \ -e RUN_LOCAL=true \ --env-file ".github/super-linter.env" \ - ghcr.io/github/super-linter:slim-v5 + ghcr.io/super-linter/super-linter:slim-v5 ``` For more details which linters that run and the settings, see the file `.github/super-linter.env`. To only test one specific linter, e.g. lint Markdown, see the variable name in -`.github/super-linter.env` that in this case is `VALIDATE_MARKDOWN=true`. Then -run the single linter with this command: +`.github/super-linter.env` that in this case is `VALIDATE_MARKDOWN=true`. Note +that you also need to specify the linter configuration file if there is one. +In this case `MARKDOWN_CONFIG_FILE=.markdownlint` together with the location +via `LINTER_RULES_PATH=/`. Then run the single linter with this command: ```sh docker run --rm \ -v $PWD:/tmp/lint \ + -e LINTER_RULES_PATH=/ \ -e RUN_LOCAL=true \ -e VALIDATE_MARKDOWN=true \ - ghcr.io/github/super-linter:slim-v5 + -e MARKDOWN_CONFIG_FILE=.markdownlint.yml \ + ghcr.io/super-linter/super-linter:slim-v5 ``` ## Run super-linter interactively @@ -66,7 +71,7 @@ docker run --rm \ -v $PWD:/tmp/lint \ -w /tmp/lint \ --entrypoint /bin/bash \ - -it github/super-linter:slim-v5 + -it ghcr.io/super-linter/super-linter:slim-v5 ``` Then from the container terminal, the following commands can lint the codebase @@ -134,7 +139,7 @@ docker run --rm \ -v $PWD:/tmp/lint \ -w /tmp/lint \ --entrypoint /bin/bash \ - -it github/super-linter:slim-v5 + -it ghcr.io/super-linter/super-linter:slim-v5 # Auto-format C and C++ files (second line change all) clang-format -i @@ -143,24 +148,3 @@ clang-format -i $(find . -regex '.*\.\(c\|cpp\|h\|cc\|C\|CPP\|c++\|cp\)$') # Fix Markdown file errors markdownlint -f ``` - -## Troubleshooting - -### fatal: not a git repository - -You may see output like this repeated in many lines. - -```sh -fatal: not a git repository (or any of the parent directories): .git -``` - -A [fix](https://github.com/super-linter/super-linter/pull/4348) has been merged -and released in **super-linter/super-linter** `v5.2.1` but this repo use -**github/super-linter** which hasn't got this release. - -The error message can be ignored. A workaround is to add this option to the -Docker command: - -```sh - -w /tmp/lint -```