From da2d7af87ef5b0e10121265c81ac44b5d87c6358 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <38923768+imrishabh18@users.noreply.github.com> Date: Sat, 25 Jan 2025 20:37:10 +0530 Subject: [PATCH 1/3] Update bun-formatcheck.yml --- .github/workflows/bun-formatcheck.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bun-formatcheck.yml b/.github/workflows/bun-formatcheck.yml index 1e5facd..811dfef 100644 --- a/.github/workflows/bun-formatcheck.yml +++ b/.github/workflows/bun-formatcheck.yml @@ -35,15 +35,15 @@ jobs: run: echo "BIOME_VERSION=$(node -p "require('./package.json').devDependencies['@biomejs/biome']")" >> $GITHUB_OUTPUT - name: Install @biomejs/biome - run: npm install @biomejs/biome@${{ steps.get-biome-version.outputs.BIOME_VERSION }} + run: bun add @biomejs/biome@${{ steps.get-biome-version.outputs.BIOME_VERSION }} - name: Run Formatter and autofix if: steps.check_fork.outputs.is_fork == 'false' - run: npx @biomejs/biome format . --write + run: bunx @biomejs/biome format . --write - name: Format Check (cannot autofix against forks) if: steps.check_fork.outputs.is_fork == 'true' - run: npx @biomejs/biome format . + run: bunx @biomejs/biome format . - name: Restore lock files if: steps.check_fork.outputs.is_fork == 'false' From 10a8ddcfcf9fc8ff761d667249d0a6e1bb643673 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta <38923768+imrishabh18@users.noreply.github.com> Date: Sat, 25 Jan 2025 20:38:24 +0530 Subject: [PATCH 2/3] Update bun-formatcheck.yml --- .github/workflows/bun-formatcheck.yml | 67 ++++++--------------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/.github/workflows/bun-formatcheck.yml b/.github/workflows/bun-formatcheck.yml index 811dfef..2d36363 100644 --- a/.github/workflows/bun-formatcheck.yml +++ b/.github/workflows/bun-formatcheck.yml @@ -1,63 +1,26 @@ -name: Format PR +# Created using @tscircuit/plop (npm install -g @tscircuit/plop) +name: Format Check on: + push: + branches: [main] pull_request: - types: [opened, synchronize, reopened, ready_for_review] + branches: [main] jobs: - format: - name: Format code + format-check: runs-on: ubuntu-latest - if: github.event.pull_request.draft == false steps: - - name: Determine if fork - id: check_fork - run: | - if [ "${{ github.event.pull_request.head.repo.full_name }}" = "${{ github.repository }}" ]; then - echo "is_fork=false" >> $GITHUB_OUTPUT - else - echo "is_fork=true" >> $GITHUB_OUTPUT - fi + - uses: actions/checkout@v3 - - name: Checkout code - uses: actions/checkout@v3 - with: - token: ${{ steps.check_fork.outputs.is_fork == 'true' && secrets.GITHUB_TOKEN || secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }} + - name: Setup bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '20' + - name: Install dependencies + run: bun install - - name: Get @biomejs/biome version - id: get-biome-version - run: echo "BIOME_VERSION=$(node -p "require('./package.json').devDependencies['@biomejs/biome']")" >> $GITHUB_OUTPUT - - - name: Install @biomejs/biome - run: bun add @biomejs/biome@${{ steps.get-biome-version.outputs.BIOME_VERSION }} - - - name: Run Formatter and autofix - if: steps.check_fork.outputs.is_fork == 'false' - run: bunx @biomejs/biome format . --write - - - name: Format Check (cannot autofix against forks) - if: steps.check_fork.outputs.is_fork == 'true' - run: bunx @biomejs/biome format . - - - name: Restore lock files - if: steps.check_fork.outputs.is_fork == 'false' - run: | - git checkout -- *lock.json || true - git checkout -- *.lock || true - git checkout -- *.lockb || true - - - name: Commit changes - if: steps.check_fork.outputs.is_fork == 'false' - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "formatbot: Automatically format code" - branch: ${{ github.head_ref }} - commit_user_name: tscircuitbot - commit_user_email: tscircuitbot@users.noreply.github.com - commit_author: tscircuitbot + - name: Run format check + run: bun run format:check From a33838e6d6c61f016f4a253294b03dca6b0db173 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta Date: Sat, 25 Jan 2025 20:40:42 +0530 Subject: [PATCH 3/3] format check --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 030ca00..e02e570 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "scripts": { "build": "tsup ./lib/index.ts --format esm --dts", "test": "bun test", - "format": "biome format . --write" + "format": "biome format . --write", + "format:check": "biome check --write" }, "type": "module", "devDependencies": {