Skip to content

Commit

Permalink
add biome errorformat
Browse files Browse the repository at this point in the history
  • Loading branch information
mongolyy committed Dec 24, 2023
1 parent 06b0a5a commit 58879c1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 63 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ on:
branches:
- main
pull_request:
# TODO: replace `<linter-name>` with yours
jobs:
test-check:
name: runner / <linter-name> (github-check)
name: runner / Biome (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -16,11 +15,10 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
locale: "US"

test-pr-check:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-check)
name: runner / Biome (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -29,12 +27,11 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
locale: "US"
workdir: ./testdata/subdir/

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-review)
name: runner / Biome (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -44,7 +41,6 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
locale: "US"
filter_mode: file
fail_on_error: true
- name: check the exit code
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Folders to ignore
.vscode/
.vscode/
.idea/
47 changes: 13 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
# action-composite-template
# reviewdog-action-biome

<!-- TODO: replace reviewdog/action-composite-template with your repo name -->
[![Test](https://github.com/reviewdog/action-composite-template/workflows/Test/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3ATest)
[![reviewdog](https://github.com/reviewdog/action-composite-template/workflows/reviewdog/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3Areviewdog)
[![depup](https://github.com/reviewdog/action-composite-template/workflows/depup/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3Adepup)
[![release](https://github.com/reviewdog/action-composite-template/workflows/release/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-composite-template?logo=github&sort=semver)](https://github.com/reviewdog/action-composite-template/releases)
[![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr)
This action runs [Biome](https://biomejs.dev/) with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve code review experience.

![github-pr-review demo](https://user-images.githubusercontent.com/3797062/73162963-4b8e2b00-4132-11ea-9a3f-f9c6f624c79f.png)
![github-pr-check demo](https://user-images.githubusercontent.com/3797062/73163032-70829e00-4132-11ea-8481-f213a37db354.png)

<!-- TODO: outline your action here -->
This is a template repository for
[reviewdog](https://github.com/reviewdog/reviewdog) action with release
automation based on [action composition](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action).
Click `Use this template` button to create your reviewdog action :dog:!

If you want to create your own reviewdog action from scratch without using this
template, please check and copy release automation flow.
It's important to manage release workflow and sync reviewdog version for all
reviewdog actions.

This repo contains a sample action to run [misspell](https://github.com/client9/misspell).

## Input

<!-- TODO: replace `<linter-name>` with yours -->
```yaml
inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
description: |
Working directory relative to the root directory.
This is where the action will look for a package.json file which declares Biome as a dependency.
Please note that this is different from the directory where the action will run Biome, which is specified in the biome_flags input.
default: '.'
### Flags for reviewdog ###
tool_name:
description: 'Tool name to use for reviewdog reporter.'
default: '<linter-name>'
default: 'Biome'
level:
description: 'Report level for reviewdog [info,warning,error].'
default: 'error'
Expand All @@ -58,26 +39,24 @@ inputs:
reviewdog_flags:
description: 'Additional reviewdog flags.'
default: ''
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''
### Flags for Biome ###
biome_flags:
description: 'Flags and args for Biome command.'
default: '.'
```
## Usage
<!-- TODO: replace reviewdog/action-composite-template with your repo name -->
```yaml
name: reviewdog
on: [pull_request]
jobs:
# TODO: replace `linter_name` and `<linter-name>` with yours
linter_name:
name: runner / <linter-name>
name: runner / Biome
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-composite-template@v1
- uses: mongolyy/reviewdog-action-biome@v1
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-check,github-pr-review,github-pr-check].
Expand Down
25 changes: 13 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# TODO: replace `<linter-name>` and `<your-name>` with yours
name: 'Run <linter-name> with reviewdog'
description: '🐶 Run <linter-name> with reviewdog on pull requests to improve code review experience.'
author: '<your-name>'
name: 'Run Biome with reviewdog'
description: '🐶 Run Biome with reviewdog on pull requests to improve code review experience.'
author: 'mongolyy'
inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
description: |
Working directory relative to the root directory.
This is where the action will look for a package.json file which declares Biome as a dependency.
Please note that this is different from the directory where the action will run Biome, which is specified in the biome_flags input.
default: '.'
### Flags for reviewdog ###
tool_name:
description: 'Tool name to use for reviewdog reporter.'
default: '<linter-name>'
default: 'Biome'
level:
description: 'Report level for reviewdog [info,warning,error].'
default: 'error'
Expand All @@ -32,10 +34,10 @@ inputs:
reviewdog_flags:
description: 'Additional reviewdog flags.'
default: ''
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''
### Flags for Biome ###
biome_flags:
description: 'Flags and args for Biome command.'
default: '.'
runs:
using: 'composite'
steps:
Expand All @@ -55,10 +57,9 @@ runs:
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }}
INPUT_LOCALE: ${{ inputs.locale }}
INPUT_BIOME_FLAGS: ${{ inputs.biome_flags }}

# Ref: https://haya14busa.github.io/github-action-brandings/
# TODO: update branding if you want.
branding:
icon: 'check'
color: 'blue'
27 changes: 18 additions & 9 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

echo '::group::🐶 Installing misspell ... https://github.com/client9/misspell'
TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
wget -O - -q https://git.io/misspell | sh -s -- -b "${TEMP_PATH}"
echo '::endgroup::'
npx --no-install -c 'biome --version'
if [ $? -ne 0 ]; then

Check warning on line 11 in script.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. Raw Output: ./script.sh:11:6: info: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. (ShellCheck.SC2181)
echo '::group::🐶 Installing biome...'
npm install
echo '::endgroup::'
fi

echo "biome version:$(npx --noinstall -c 'biome --version')}"

echo '::group:: Running misspell with reviewdog 🐶 ...'
# shellcheck disable=SC2086
misspell -locale="${INPUT_LOCALE}" . |
reviewdog -efm="%f:%l:%c: %m" \
echo '::group:: Running biome with reviewdog 🐶 ...'
biome ci "${INPUT_BIOME_FLAGS}" |
reviewdog \
-efm="%E%f:%l:%c %m ━%r" \
-efm="%C" \
-efm="%Z × %m" \
-efm="%E%f %m ━%r" \
-efm="%C" \
-efm="%Z × %m" \
-efm="%-G%.%#" \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
Expand Down

0 comments on commit 58879c1

Please sign in to comment.