Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mongolyy committed Dec 25, 2023
1 parent 58879c1 commit dcde085
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 24 deletions.
48 changes: 37 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,65 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
- id: action-success-test
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: error
workdir: ./testdata
biome_flags: ok
- id: action-failure-test
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
workdir: ./testdata
biome_flags: error

test-pr-check:
if: github.event_name == 'pull_request'
name: runner / Biome (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
- id: action-success-test
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
workdir: ./testdata/subdir/
level: error
workdir: ./testdata
biome_flags: ok
- id: action-failure-test
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: info
workdir: ./testdata
biome_flags: error

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / Biome (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
continue-on-error: true
- id: action-success-test
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
filter_mode: file
fail_on_error: true
- name: check the exit code
if: ${{ !success() }}
run: echo 'The previous step should fail' && exit 1
workdir: ./testdata
biome_flags: ok
- id: action-failure-test
uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: info
workdir: ./testdata
biome_flags: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Folders to ignore
.vscode/
.idea/
node_modules/
16 changes: 10 additions & 6 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

npx --no-install -c 'biome --version'
if [ $? -ne 0 ]; then
echo '::group::🐶 Installing biome...'
if [ ! -f "$(npm root)"/.bin/biome ]; then
echo '::group::🐶 Installing Biome...'
npm install
echo '::endgroup::'
fi

echo "biome version:$(npx --noinstall -c 'biome --version')}"
if [ ! -f "$(npm root)"/.bin/biome ]; then
echo "❌ Unable to locate or install Biome. Did you provide a workdir which contains a valid package.json?"
exit 1
fi

echo "Biome $("$(npm root)"/.bin/biome --version)"

echo '::group:: Running biome with reviewdog 🐶 ...'
biome ci "${INPUT_BIOME_FLAGS}" |
echo '::group:: Running Biome with reviewdog 🐶 ...'
"$(npm root)"/.bin/biome ci "${INPUT_BIOME_FLAGS}" |
reviewdog \
-efm="%E%f:%l:%c %m ━%r" \
-efm="%C" \
Expand Down
5 changes: 5 additions & 0 deletions testdata/error/format.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
html {}

div { color: white;}

div { color: white; background-color: red;}
5 changes: 5 additions & 0 deletions testdata/error/format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let a = [,];
let b = [,,];
let c = [,,1,];
let d = [,,1,1];
let e = [2,2,1,3];
3 changes: 3 additions & 0 deletions testdata/error/lint.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@font-face foo {}
@font-face foo;
@font-face ;
5 changes: 5 additions & 0 deletions testdata/error/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[a a, ++b, ] = test;
[a, c, ...rest,] = test;
[a = , = "test"] = test;
[[a b] [c]]= test;
[a: b] = c
11 changes: 11 additions & 0 deletions testdata/ok/format.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html {
}

div {
color: white;
}

div {
color: white;
background-color: red;
}
5 changes: 5 additions & 0 deletions testdata/ok/format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let a = [,];
let b = [, ,];
let c = [, , 1];
let d = [, , 1, 1];
let e = [2, 2, 1, 3];
1 change: 1 addition & 0 deletions testdata/ok/lint.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@font-face {}
4 changes: 4 additions & 0 deletions testdata/ok/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[foo, bar] = baz;
[,,,b,,c,] = baz;
[a = "test", a.b, call().b] = baz;
[((a))] = baz;
137 changes: 137 additions & 0 deletions testdata/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions testdata/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "testdata",
"version": "1.0.0",
"description": "Test data for the reviewdog-action-biome",
"author": "mongolyy",
"license": "MIT",
"devDependencies": {
"@biomejs/biome": "^1.4.1"
}
}
2 changes: 0 additions & 2 deletions testdata/subdir/text.md

This file was deleted.

5 changes: 0 additions & 5 deletions testdata/text.md

This file was deleted.

0 comments on commit dcde085

Please sign in to comment.