Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code suggestions #15

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

This action runs [Biome](https://biomejs.dev/) with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve code review experience.

![sample-pr-review](./assets/readme/sample-pr-review.png)
![sample-pr-review](assets/readme/sample-pr-review.png)
![sample-commit-suggestion](assets/readme/sample-commit-suggestion.png)

## Input

Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ runs:
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }}
INPUT_BIOME_FLAGS: ${{ inputs.biome_flags }}
- if: ${{ inputs.reporter == 'github-pr-review' && always() }}
uses: reviewdog/action-suggester@v1
with:
github_token: ${{ inputs.github_token }}
tool_name: ${{ inputs.tool_name }}
level: ${{ inputs.level }}
filter_mode: ${{ inputs.filter_mode }}
fail_on_error: ${{ inputs.fail_on_error }}
reviewdog_flags: ${{ inputs.reviewdog_flags }}

# Ref: https://haya14busa.github.io/github-action-brandings/
branding:
Expand Down
Binary file added assets/readme/sample-commit-suggestion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 46 additions & 21 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,52 @@ fi
echo "Biome $("$(npm root)"/.bin/biome --version)"

echo '::group:: Running Biome with reviewdog 🐶 ...'
# shellcheck disable=SC2016,SC2086
"$(npm root)"/.bin/biome ci --max-diagnostics=30 ${INPUT_BIOME_FLAGS} 2>&1 1>/dev/null |
sed 's/ *$//' |
sed -z 's/\n\n\([^\n]*│[^\n]*\)/\n\n ```\n\1/g' |
sed -z 's/│\n\n/│\n ```\n/g' |
reviewdog \
-efm="%-G%f ci ━%#" \
-efm="%-G%f lint ━%#" \
-efm="%-Gci ━%#" \
-efm="%E%f:%l:%c %.%#" \
-efm="%E%f %.%#" \
-efm="%C" \
-efm="%C × %m" \
-efm="%C %m" \
-efm="%-G%.%#" \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
if [ "$INPUT_REPORTER" = "github-pr-review" ]; then
# shellcheck disable=SC2086
"$(npm root)"/.bin/biome check --apply ${INPUT_BIOME_FLAGS} 2>&1 1>/dev/null |
sed 's/ *$//' |
sed -z 's/\n\n\([^\n]*│[^\n]*\)/\n\n ```\n\1/g' |
sed -z 's/│\n\n/│\n ```\n/g' |
reviewdog \
-efm="%-G%f ci ━%#" \
-efm="%-G%f lint ━%#" \
-efm="%-Gci ━%#" \
-efm="%E%f:%l:%c %.%#" \
-efm="%E%f %.%#" \
-efm="%C" \
-efm="%C × %m" \
-efm="%C %m" \
-efm="%-G%.%#" \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
else
# shellcheck disable=SC2086
"$(npm root)"/.bin/biome ci --max-diagnostics=30 ${INPUT_BIOME_FLAGS} 2>&1 1>/dev/null |
sed 's/ *$//' |
sed -z 's/\n\n\([^\n]*│[^\n]*\)/\n\n ```\n\1/g' |
sed -z 's/│\n\n/│\n ```\n/g' |
reviewdog \
-efm="%-G%f ci ━%#" \
-efm="%-G%f lint ━%#" \
-efm="%-Gci ━%#" \
-efm="%E%f:%l:%c %.%#" \
-efm="%E%f %.%#" \
-efm="%C" \
-efm="%C × %m" \
-efm="%C %m" \
-efm="%-G%.%#" \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
fi

exit_code=$?
echo '::endgroup::'
exit $exit_code
Loading