Skip to content

Commit

Permalink
Update Docker Image to Alpine (#3)
Browse files Browse the repository at this point in the history
* Output files which will be linted as a group

* Move to alpine image

* Workaround for git v2.35.2 issue

* Install rlwrap so clojure-tools works appropriately

* Send multiple --lint args

* Redact timing information

* Log results of linting

* Fix param passing

* Simplify

* Simplify

* Update documentation
  • Loading branch information
nnichols authored Jul 7, 2022
1 parent 24c52d8 commit 8ab2dd3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
21 changes: 18 additions & 3 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
#!/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" \
-reporter="${INPUT_REPORTER}" \
-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

0 comments on commit 8ab2dd3

Please sign in to comment.