diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f8421f..74f63d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,11 +10,22 @@ 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' @@ -22,12 +33,22 @@ jobs: 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' @@ -35,14 +56,19 @@ jobs: 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 diff --git a/.gitignore b/.gitignore index bfbf135..223480a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # Folders to ignore .vscode/ .idea/ +node_modules/ diff --git a/script.sh b/script.sh index 2287cf7..8463747 100755 --- a/script.sh +++ b/script.sh @@ -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" \ diff --git a/testdata/error/format.css b/testdata/error/format.css new file mode 100644 index 0000000..cee98d0 --- /dev/null +++ b/testdata/error/format.css @@ -0,0 +1,5 @@ +html {} + +div { color: white;} + +div { color: white; background-color: red;} diff --git a/testdata/error/format.js b/testdata/error/format.js new file mode 100644 index 0000000..1d8d5cb --- /dev/null +++ b/testdata/error/format.js @@ -0,0 +1,5 @@ +let a = [,]; +let b = [,,]; +let c = [,,1,]; +let d = [,,1,1]; +let e = [2,2,1,3]; diff --git a/testdata/error/lint.css b/testdata/error/lint.css new file mode 100644 index 0000000..25ef0cd --- /dev/null +++ b/testdata/error/lint.css @@ -0,0 +1,3 @@ +@font-face foo {} +@font-face foo; +@font-face ; diff --git a/testdata/error/lint.js b/testdata/error/lint.js new file mode 100644 index 0000000..94f74a8 --- /dev/null +++ b/testdata/error/lint.js @@ -0,0 +1,5 @@ +[a a, ++b, ] = test; +[a, c, ...rest,] = test; +[a = , = "test"] = test; +[[a b] [c]]= test; +[a: b] = c diff --git a/testdata/ok/format.css b/testdata/ok/format.css new file mode 100644 index 0000000..aec135d --- /dev/null +++ b/testdata/ok/format.css @@ -0,0 +1,11 @@ +html { +} + +div { + color: white; +} + +div { + color: white; + background-color: red; +} diff --git a/testdata/ok/format.js b/testdata/ok/format.js new file mode 100644 index 0000000..04629da --- /dev/null +++ b/testdata/ok/format.js @@ -0,0 +1,5 @@ +let a = [,]; +let b = [, ,]; +let c = [, , 1]; +let d = [, , 1, 1]; +let e = [2, 2, 1, 3]; diff --git a/testdata/ok/lint.css b/testdata/ok/lint.css new file mode 100644 index 0000000..31d36c7 --- /dev/null +++ b/testdata/ok/lint.css @@ -0,0 +1 @@ +@font-face {} diff --git a/testdata/ok/lint.js b/testdata/ok/lint.js new file mode 100644 index 0000000..458c13e --- /dev/null +++ b/testdata/ok/lint.js @@ -0,0 +1,4 @@ +[foo, bar] = baz; +[,,,b,,c,] = baz; +[a = "test", a.b, call().b] = baz; +[((a))] = baz; diff --git a/testdata/package-lock.json b/testdata/package-lock.json new file mode 100644 index 0000000..7055b17 --- /dev/null +++ b/testdata/package-lock.json @@ -0,0 +1,137 @@ +{ + "name": "testdata", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "testdata", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "@biomejs/biome": "1.4.1" + } + }, + "node_modules/@biomejs/biome": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.4.1.tgz", + "integrity": "sha512-JccVAwPbhi37pdxbAGmaOBjUTKEwEjWAhl7rKkVVuXHo4MLASXJ5HR8BTgrImi4/7rTBsGz1tgVD1Kwv1CHGRg==", + "dev": true, + "hasInstallScript": true, + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.4.1", + "@biomejs/cli-darwin-x64": "1.4.1", + "@biomejs/cli-linux-arm64": "1.4.1", + "@biomejs/cli-linux-x64": "1.4.1", + "@biomejs/cli-win32-arm64": "1.4.1", + "@biomejs/cli-win32-x64": "1.4.1" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.4.1.tgz", + "integrity": "sha512-PZWy2Idndqux38p6AXSDQM2ldRAWi32bvb7bMbTN0ALzpWYMYnxd71ornatumSSJYoNhKmxzDLq+jct7nZJ79w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.4.1.tgz", + "integrity": "sha512-soj3BWhnsM1M2JlzR09cibUzG1owJqetwj/Oo7yg0foijo9lNH9XWXZfJBYDKgW/6Fomn+CC2EcUS+hisQzt9g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.4.1.tgz", + "integrity": "sha512-YIZqfJUg4F+fPsBTXxgD7EU2E5OAYbmYSl/snf4PevwfQCWE/omOFZv+NnIQmjYj9I7ParDgcJvanoA3/kO0JQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.4.1.tgz", + "integrity": "sha512-9YOZw3qBd/KUj63A6Hn2zZgzGb2nbESM0qNmeMXgmqinVKM//uc4OgY5TuKITuGjMSvcVxxd4dX1IzYjV9qvNQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.4.1.tgz", + "integrity": "sha512-nWQbvkNKxYn/kCQ0yVF8kCaS3VzaGvtFSmItXiMknU4521LDjJ7tNWH12Gol+pIslrCbd4E1LhJa0a3ThRsBVg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.4.1.tgz", + "integrity": "sha512-88fR2CQxQ4YLs2BUDuywWYQpUKgU3A3sTezANFc/4LGKQFFLV2yX+F7QAdZVkMHfA+RD9Xg178HomM/6mnTNPA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.*" + } + } + } +} diff --git a/testdata/package.json b/testdata/package.json new file mode 100644 index 0000000..9060332 --- /dev/null +++ b/testdata/package.json @@ -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" + } +} diff --git a/testdata/subdir/text.md b/testdata/subdir/text.md deleted file mode 100644 index 5b33346..0000000 --- a/testdata/subdir/text.md +++ /dev/null @@ -1,2 +0,0 @@ -Determinisitic result is important! - diff --git a/testdata/text.md b/testdata/text.md deleted file mode 100644 index 5025db8..0000000 --- a/testdata/text.md +++ /dev/null @@ -1,5 +0,0 @@ -Determinisitic result is important. - -colour # <= Check -locale - -langauge