+
Skip to content
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
18 changes: 6 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ jobs:
github_token: ${{ secrets.github_token }}
workdir: ./testdata
reporter: github-check
level: error
filter_mode: nofilter
fail_on_error: true
biome_flags: ok
biome_flags: ok/
- id: action-failure-test
name: action-failure-test
uses: ./
Expand All @@ -29,10 +28,9 @@ jobs:
github_token: ${{ secrets.github_token }}
workdir: ./testdata
reporter: github-check
level: info
filter_mode: nofilter
fail_on_error: true
biome_flags: error
biome_flags: error/
- name: check-failure
if: steps.action-failure-test.outcome == 'success'
run: exit 1
Expand All @@ -50,10 +48,9 @@ jobs:
github_token: ${{ secrets.github_token }}
workdir: ./testdata
reporter: github-pr-check
level: error
filter_mode: nofilter
fail_on_error: true
biome_flags: ok
biome_flags: ok/
- id: action-failure-test
name: action-failure-test
uses: ./
Expand All @@ -62,10 +59,9 @@ jobs:
github_token: ${{ secrets.github_token }}
workdir: ./testdata
reporter: github-pr-check
level: info
filter_mode: nofilter
fail_on_error: true
biome_flags: error
biome_flags: error/
- name: check-failure
if: steps.action-failure-test.outcome == 'success'
run: exit 1
Expand All @@ -83,10 +79,9 @@ jobs:
github_token: ${{ secrets.github_token }}
workdir: ./testdata
reporter: github-pr-review
level: error
filter_mode: nofilter
fail_on_error: true
biome_flags: ok
biome_flags: ok/
- id: action-failure-test
name: action-failure-test
uses: ./
Expand All @@ -95,10 +90,9 @@ jobs:
github_token: ${{ secrets.github_token }}
workdir: ./testdata
reporter: github-pr-review
level: info
filter_mode: nofilter
fail_on_error: true
biome_flags: error
biome_flags: error/
- name: check-failure
if: steps.action-failure-test.outcome == 'success'
run: exit 1
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,48 @@ This action runs [Biome](https://biomejs.dev/) with [reviewdog](https://github.c
inputs:
github_token:
description: 'GITHUB_TOKEN'
required: true
default: '${{ github.token }}'
workdir:
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.
required: false
default: '.'
### Flags for reviewdog ###
tool_name:
description: 'Tool name to use for reviewdog reporter.'
required: false
default: 'Biome'
level:
description: 'Report level for reviewdog [info,warning,error].'
required: false
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-check,github-pr-review,github-pr-check].'
default: 'github-check'
required: false
default: 'github-pr-review'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
required: false
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false].
Default is `false`.
required: false
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags.'
required: false
default: ''
### Flags for Biome ###
biome_flags:
description: 'Flags and args for Biome command.'
required: false
default: '.'
```

Expand All @@ -51,19 +60,42 @@ inputs:
name: reviewdog
on: [pull_request]
jobs:
linter_name:
biome:
name: runner / Biome
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: mongolyy/reviewdog-action-biome@v1
- uses: mongolyy/reviewdog-action-biome@v0
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
```

You can also set up node and Biome manually:

```yaml
name: reviewdog
on: [pull_request]
jobs:
biome:
name: runner / Biome
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20"
- run: yarn install
- uses: reviewdog/action-biome@v0
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-check,github-pr-review,github-pr-check].
reporter: github-pr-review
# Change reporter level if you need.
# GitHub Status Check won't become failure with warning.
level: warning
```

## Development
Expand Down
13 changes: 11 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,48 @@ author: 'mongolyy'
inputs:
github_token:
description: 'GITHUB_TOKEN'
required: true
default: '${{ github.token }}'
workdir:
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.
required: false
default: '.'
### Flags for reviewdog ###
tool_name:
description: 'Tool name to use for reviewdog reporter.'
required: false
default: 'Biome'
level:
description: 'Report level for reviewdog [info,warning,error].'
required: false
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-check,github-pr-review,github-pr-check].'
default: 'github-check'
required: false
default: 'github-pr-review'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
required: false
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false].
Default is `false`.
required: false
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags.'
required: false
default: ''
### Flags for Biome ###
biome_flags:
description: 'Flags and args for Biome command.'
required: false
default: '.'
runs:
using: 'composite'
Expand All @@ -61,5 +70,5 @@ runs:

# Ref: https://haya14busa.github.io/github-action-brandings/
branding:
icon: 'check'
icon: 'alert-octagon'
color: 'blue'
12 changes: 7 additions & 5 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ fi
echo "Biome $("$(npm root)"/.bin/biome --version)"

echo '::group:: Running Biome with reviewdog 🐶 ...'
"$(npm root)"/.bin/biome ci "${INPUT_BIOME_FLAGS}" 2>&1 |
# shellcheck disable=SC2086
"$(npm root)"/.bin/biome ci ${INPUT_BIOME_FLAGS} 2>&1 1>/dev/null |
reviewdog \
-efm="%C" \
-efm="%-Gci ━%#" \
-efm="%E%f:%l:%c %.%#━" \
-efm="%E%f:%l:%c %.%#" \
-efm="%C" \
-efm="%Z × %m" \
-efm="%E%f %m %.%#━" \
-efm="%E%f %.%#" \
-efm="%C" \
-efm="%Z × %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}"
${INPUT_REVIEWDOG_FLAGS}
exit_code=$?
echo '::endgroup::'
exit $exit_code
12 changes: 12 additions & 0 deletions testdata/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
5 changes: 0 additions & 5 deletions testdata/error/format.css

This file was deleted.

3 changes: 0 additions & 3 deletions testdata/error/lint.css

This file was deleted.

4 changes: 0 additions & 4 deletions testdata/error/lint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
[a a, ++b, ] = test;
[a, c, ...rest,] = test;
[a = , = "test"] = test;
[[a b] [c]]= test;
[a: b] = c
11 changes: 0 additions & 11 deletions testdata/ok/format.css

This file was deleted.

1 change: 0 additions & 1 deletion testdata/ok/lint.css

This file was deleted.

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载