diff --git a/CHANGELOG.md b/CHANGELOG.md index 657f013..c7d8aab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v2 - 2022-07-06 + +- Migrate to Alpine tools.deps image +- Add an output group for files that will be linted + ## v1 - 2021-07-07 - Initial Implementation diff --git a/Dockerfile b/Dockerfile index 180809b..927ea8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,19 @@ -FROM nnichols/clojure-lint-action +FROM clojure:temurin-18-tools-deps-alpine ENV REVIEWDOG_VERSION=v0.12.0 RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} +RUN apk --no-cache add gcc ncurses-dev libc-dev readline-dev make \ + && cd /tmp \ + && wget https://github.com/hanslub42/rlwrap/releases/download/v0.43/rlwrap-0.43.tar.gz \ + && tar -xzvf rlwrap-0.43.tar.gz \ + && cd rlwrap-0.43 \ + && ./configure \ + && make install \ + && rm -rf rlwrap-0.43 \ + && apk del gcc ncurses-dev libc-dev readline-dev make + COPY lint.sh /lint.sh ENTRYPOINT ["bash", "/lint.sh"] diff --git a/README.md b/README.md index 8e3791d..67e13a0 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Default: `.` Optional. File patterns of target files. Same as `-name [pattern]` of `find` command. -Default: `*.clj,*.cljc,*.cljs,*.cljx` +Default: `*.clj*` (To capture `*.clj`, `*.cljs`, `*.cljc`, and `*.cljx`) ### `exclude` @@ -72,6 +72,8 @@ Default: `'{:output {:pattern "{{filename}}:{{row}}:{{col}}: {{message}}"}}'` ### [.github/workflows/reviewdog.yml](.github/workflows/reviewdog.yml) +To receive automatic Pull Request comments with linter results: + ```yml name: Lint Clojure on: [pull_request] @@ -80,12 +82,12 @@ jobs: name: runner / clj-kondo runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3.0.2 - name: clj-kondo - uses: nnichols/clojure-lint-action@v1 + uses: nnichols/clojure-lint-action@v2 with: github_token: ${{ secrets.github_token }} - reporter: github-pr-review # Change reporter. + reporter: github-pr-review ``` ## Licensing diff --git a/action.yml b/action.yml index c482538..88f7249 100644 --- a/action.yml +++ b/action.yml @@ -51,7 +51,7 @@ inputs: pattern: required: false description: "File patterns of target files. Same as `-name [pattern]` of `find` command." - default: '*.clj' + default: '*.clj*' exclude: required: false description: "Exclude patterns of target files. Same as `-not -path [exclude]` of `find` command." diff --git a/lint.sh b/lint.sh index 42880d0..913c529 100755 --- a/lint.sh +++ b/lint.sh @@ -1,12 +1,23 @@ #!/bin/bash -cd "${GITHUB_WORKSPACE}" || exit +cd "${GITHUB_WORKSPACE}" || exit 1 + +# https://github.com/reviewdog/reviewdog/issues/1158 +git config --global --add safe.directory "$GITHUB_WORKSPACE" || exit 1 export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" -clj-kondo --lint $(find "${INPUT_PATH}" -not -path "${INPUT_EXCLUDE}" -type f -name "${INPUT_PATTERN}") \ +sources=$(find "${INPUT_PATH}" -not -path "${INPUT_EXCLUDE}" -type f -name "${INPUT_PATTERN}") + +echo "::group::Files to lint" +echo "${sources}" +echo "::endgroup::" + +clj -Sdeps '{:deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}}' -M -m clj-kondo.main \ + --lint $(find "${INPUT_PATH}" -not -path "${INPUT_EXCLUDE}" -type f -name "${INPUT_PATTERN}") \ --config "${INPUT_CLJ_KONDO_CONFIG}" \ --config '{:output {:pattern "{{filename}}:{{row}}:{{col}}: {{message}}"}}' \ + --config '{:summary false}' \ | reviewdog \ -efm="%f:%l:%c: %m" \ -name="clj-kondo" \ @@ -14,4 +25,8 @@ clj-kondo --lint $(find "${INPUT_PATH}" -not -path "${INPUT_EXCLUDE}" -type f -n -filter-mode="${INPUT_FILTER_MODE}" \ -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ -level="${INPUT_LEVEL}" \ - ${INPUT_REVIEWDOG_FLAGS} + "${INPUT_REVIEWDOG_FLAGS}" + +exit_code=$? + +exit $exit_code