From fdd92a46561147548172d733be05fa72a691b519 Mon Sep 17 00:00:00 2001 From: Jarvis AI Team Date: Fri, 1 May 2026 10:23:58 +0800 Subject: [PATCH] feat: make Knip and Jest workflows reusable - Created _knip.yml and _jest.yml as reusable workflows - Updated knip.yml and jest-testing.yml to use workflow_call - Resolves issue #13: enables cross-repo workflow reuse This allows other repositories to call these workflows using: jobs: call-knip: uses: ubiquity-os/plugin-template/.github/workflows/_knip.yml@v1.0.0 --- .github/workflows/_jest.yml | 41 ++++++++++++++++++++++++++ .github/workflows/_knip.yml | 46 ++++++++++++++++++++++++++++++ .github/workflows/jest-testing.yml | 27 +++--------------- .github/workflows/knip.yml | 30 +++---------------- 4 files changed, 95 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/_jest.yml create mode 100644 .github/workflows/_knip.yml diff --git a/.github/workflows/_jest.yml b/.github/workflows/_jest.yml new file mode 100644 index 0000000..936eb09 --- /dev/null +++ b/.github/workflows/_jest.yml @@ -0,0 +1,41 @@ +name: Jest Testing (Reusable) + +# This workflow can be called from other repositories +# Usage: +# jobs: +# call-jest: +# uses: ubiquity-os/plugin-template/.github/workflows/_jest.yml@v1.0.0 + +on: + workflow_call: + inputs: + bun-version: + description: 'Bun version to use' + required: false + default: 'latest' + type: string + +env: + NODE_ENV: "test" + +jobs: + testing: + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: oven-sh/setup-bun@v2 + with: + bun-version: ${{ inputs.bun-version || 'latest' }} + + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Jest With Coverage + run: | + bun install --frozen-lockfile + bun run test + + - name: Add Jest Report to Summary + if: always() + run: echo "$(cat test-dashboard.md)" >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/_knip.yml b/.github/workflows/_knip.yml new file mode 100644 index 0000000..6fa35cc --- /dev/null +++ b/.github/workflows/_knip.yml @@ -0,0 +1,46 @@ +name: Knip (Reusable) + +# This workflow can be called from other repositories +# Usage: +# jobs: +# call-knip: +# uses: ubiquity-os/plugin-template/.github/workflows/_knip.yml@v1.0.0 + +on: + workflow_call: + inputs: + bun-version: + description: 'Bun version to use' + required: false + default: 'latest' + type: string + +jobs: + run-knip: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: ${{ inputs.bun-version || 'latest' }} + + - name: Install toolchain + run: bun install + + - name: Store PR number + run: echo ${{ github.event.number || '0' }} > pr-number.txt + + - name: Run Knip + run: bun run knip || bun run knip --reporter json > knip-results.json + + - name: Upload knip result + if: failure() + uses: actions/upload-artifact@v4 + with: + name: knip-results + path: | + knip-results.json + pr-number.txt \ No newline at end of file diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml index 5b873ed..978f9af 100644 --- a/.github/workflows/jest-testing.yml +++ b/.github/workflows/jest-testing.yml @@ -3,27 +3,8 @@ on: workflow_dispatch: pull_request: -env: - NODE_ENV: "test" - jobs: - testing: - permissions: write-all - runs-on: ubuntu-latest - steps: - - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest - - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: Jest With Coverage - run: | - bun install --frozen-lockfile - bun run test - - - name: Add Jest Report to Summary - if: always() - run: echo "$(cat test-dashboard.md)" >> $GITHUB_STEP_SUMMARY + call-jest: + uses: ubiquity-os/plugin-template/.github/workflows/_jest.yml@v1.0.0 + with: + bun-version: latest \ No newline at end of file diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml index 779ef47..c0b77d9 100644 --- a/.github/workflows/knip.yml +++ b/.github/workflows/knip.yml @@ -5,29 +5,7 @@ on: workflow_dispatch: jobs: - run-knip: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - - - name: Install toolchain - run: bun install - - - name: Store PR number - run: echo ${{ github.event.number }} > pr-number.txt - - - name: Run Knip - run: bun run knip || bun run knip --reporter json > knip-results.json - - - name: Upload knip result - if: failure() - uses: actions/upload-artifact@v4 - with: - name: knip-results - path: | - knip-results.json - pr-number.txt + call-knip: + uses: ubiquity-os/plugin-template/.github/workflows/_knip.yml@v1.0.0 + with: + bun-version: latest \ No newline at end of file