Skip to content

Commit

Permalink
Merge pull request #33 from ScaCap/chore/retry-failure
Browse files Browse the repository at this point in the history
* Fix failure to call GitHub API from time to time resulting in `ktlint: command not found` error
  * Issue is caused by rate limit exceeded: https://github.com/ScaCap/action-ktlint/actions/runs/3773090106/jobs/6414367317
  * Solution: use authenticated calls with `GITHUB_TOKEN`
* Bump `actions/cache` to v3
* Bump alpine to v3.17
  • Loading branch information
ghaiszaher authored Dec 29, 2022
2 parents 4eeb44d + c3bb97b commit 762c364
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag "reviewdog-ktlint:$(date +%s)"
run: docker build . --file Dockerfile --tag "reviewdog-ktlint:$(date +%s)"
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: runner / ktlint (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
github_token: ${{ secrets.github_token }}
Expand All @@ -19,7 +19,7 @@ jobs:
name: runner / ktlint (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
github_token: ${{ secrets.github_token }}
Expand All @@ -32,7 +32,7 @@ jobs:
name: runner / ktlint (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
github_token: ${{ secrets.github_token }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.14.7
FROM alpine:3.17.0

ENV REVIEWDOG_VERSION=v0.14.1

Expand Down
32 changes: 16 additions & 16 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ export RELATIVE=
export ANDROID=
export BASELINE=

if [ "$INPUT_KTLINT_VERSION" = "latest" ] ; then
curl -sSL https://api.github.com/repos/pinterest/ktlint/releases/latest \
| grep "browser_download_url.*ktlint\"" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -\
&& chmod a+x ktlint \
&& mv ktlint /usr/local/bin/
if [ "$INPUT_KTLINT_VERSION" = "latest" ]; then
curl -sSL https://api.github.com/repos/pinterest/ktlint/releases/latest --header "authorization: Bearer ${INPUT_GITHUB_TOKEN}" |
grep "browser_download_url.*ktlint\"" |
cut -d : -f 2,3 |
tr -d \" |
wget -qi - &&
chmod a+x ktlint &&
mv ktlint /usr/local/bin/
else
curl -sSLO https://github.com/pinterest/ktlint/releases/download/"${INPUT_KTLINT_VERSION}"/ktlint \
&& chmod a+x ktlint \
&& mv ktlint /usr/local/bin/
curl -sSLO https://github.com/pinterest/ktlint/releases/download/"${INPUT_KTLINT_VERSION}"/ktlint &&
chmod a+x ktlint &&
mv ktlint /usr/local/bin/
fi

if [ "$INPUT_RELATIVE" = true ] ; then
if [ "$INPUT_RELATIVE" = true ]; then
export RELATIVE=--relative
fi

if [ ! -z "$INPUT_BASELINE" ] ; then
if [ ! -z "$INPUT_BASELINE" ]; then
export BASELINE="--baseline=${INPUT_BASELINE}"
fi

if [ "$INPUT_ANDROID" = true ] ; then
if [ "$INPUT_ANDROID" = true ]; then
export ANDROID=--android
fi

Expand All @@ -38,8 +38,8 @@ export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

echo ktlint version: "$(ktlint --version)"

ktlint --reporter=checkstyle $RELATIVE $ANDROID $BASELINE $INPUT_FILE_GLOB \
| reviewdog -f=checkstyle \
ktlint --reporter=checkstyle $RELATIVE $ANDROID $BASELINE $INPUT_FILE_GLOB |
reviewdog -f=checkstyle \
-name="ktlint" \
-reporter="${INPUT_REPORTER}" \
-level="${INPUT_LEVEL}" \
Expand Down

0 comments on commit 762c364

Please sign in to comment.