Skip to content

Commit

Permalink
Merge pull request #15 from mongolyy/feature/add-commit-suggestions
Browse files Browse the repository at this point in the history
Add code suggestions
  • Loading branch information
mongolyy authored Jan 17, 2024
2 parents f7863b9 + d2a4df3 commit bd2ee2b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 22 deletions.
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

0 comments on commit bd2ee2b

Please sign in to comment.