Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bun support #481

Merged
merged 7 commits into from
Feb 10, 2025
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
31 changes: 28 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

test-pr-check-npm:
if: github.event_name == 'pull_request'
name: runner / textlint (github-pr-check)
name: runner / textlint (github-pr-check, npm)
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -46,7 +46,7 @@ jobs:

test-pr-check-yarn:
if: github.event_name == 'pull_request'
name: runner / textlint (github-pr-check)
name: runner / textlint (github-pr-check, yarn)
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -67,7 +67,7 @@ jobs:

test-pr-check-pnpm:
if: github.event_name == 'pull_request'
name: runner / textlint (github-pr-check)
name: runner / textlint (github-pr-check, pnpm)
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -90,6 +90,31 @@ jobs:
reporter: github-pr-check
textlint_flags: "doc/**"

test-pr-check-bun:
if: github.event_name == 'pull_request'
name: runner / textlint (github-pr-check, bun)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 20
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: textlint-github-check
uses: ./
with:
github_token: ${{ secrets.github_token }}
package_manager: bun
reporter: github-pr-check
textlint_flags: "doc/**"

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / textlint (github-pr-review)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ textlint arguments (i.e. target dir:`doc/*`)

### `package_manager`

Optional. Package manager used in the repository [npm,yarn,pnpm]
Optional. Package manager used in the repository [npm,yarn,pnpm,bun]
Default is `npm`.

## Customizes
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ inputs:
description: 'Tool name to use for reviewdog reporter'
default: 'textlint'
package_manager:
description: 'Package manager used in the repository'
description: 'Package manager used in the repository [npm,yarn,pnpm,bun]'
default: 'npm'
runs:
using: 'composite'
Expand Down
12 changes: 9 additions & 3 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/review
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1
echo '::endgroup::'

PACKAGE_EXECUTER=npx

echo '::group:: Installing textlint ... https://github.com/textlint/textlint'
if [ -x "./node_modules/.bin/textlint" ]; then
echo 'already installed'
Expand All @@ -23,14 +25,18 @@ elif [[ "${INPUT_PACKAGE_MANAGER}" == "yarn" ]]; then
elif [[ "${INPUT_PACKAGE_MANAGER}" == "pnpm" ]]; then
echo 'pnpm install start'
pnpm install
elif [[ "${INPUT_PACKAGE_MANAGER}" == "bun" ]]; then
echo 'bun install start'
bun install
PACKAGE_EXECUTER=bunx
else
echo 'The specified package manager is not supported.'
echo '::endgroup::'
exit 1
fi

if [ -x "./node_modules/.bin/textlint" ]; then
npx textlint --version
$PACKAGE_EXECUTER textlint --version
else
echo 'This repository was not configured for textlint, process done.'
exit 1
Expand All @@ -47,7 +53,7 @@ reviewdog_exit_val="0"
reviewdog_exit_val2="0"

# shellcheck disable=SC2086
textlint_check_output=$(npx textlint -f checkstyle ${INPUT_TEXTLINT_FLAGS} 2>&1) \
textlint_check_output=$(${PACKAGE_EXECUTER} textlint -f checkstyle ${INPUT_TEXTLINT_FLAGS} 2>&1) \
|| textlint_exit_val="$?"

# shellcheck disable=SC2086
Expand All @@ -64,7 +70,7 @@ echo '::endgroup::'
if [[ "${INPUT_REPORTER}" == "github-pr-review" ]]; then
echo '::group:: Running textlint fixing report 🐶 ...'
# fix
npx textlint --fix ${INPUT_TEXTLINT_FLAGS:-.} || true
$PACKAGE_EXECUTER textlint --fix ${INPUT_TEXTLINT_FLAGS:-.} || true

TMPFILE=$(mktemp)
git diff > "${TMPFILE}"
Expand Down