diff --git a/.github/workflows/plugins-benchmark-pr.yml b/.github/workflows/plugins-benchmark-pr.yml deleted file mode 100644 index 15a04c9..0000000 --- a/.github/workflows/plugins-benchmark-pr.yml +++ /dev/null @@ -1,148 +0,0 @@ -name: Benchmark PR - -on: - workflow_call: - inputs: - npm-script: - type: string - default: benchmark - required: false - pr-repo: - type: string - default: ${{ github.event.pull_request.head.repo.full_name }} - required: false - pr-sha: - type: string - default: ${{ github.event.pull_request.head.sha }} - required: false - pr-ref: - type: string - default: ${{ github.event.pull_request.head.ref }} - required: false - base-repo: - type: string - default: ${{ github.event.pull_request.base.repo.full_name }} - required: false - base-sha: - type: string - default: ${{ github.event.pull_request.base.sha }} - required: false - base-ref: - type: string - default: ${{ github.event.pull_request.base.ref }} - required: false - node-versions: - description: 'A JSON array that specifies the Node.js versions on which the job should run.' - required: false - default: '["20", "22", "24"]' - type: string - -jobs: - benchmark: - if: ${{ github.event.label.name == 'benchmark' }} - runs-on: ubuntu-latest - env: - NPM_SCRIPT: ${{ inputs.npm-script }} - permissions: - contents: read - outputs: - PR-BENCH-20: ${{ steps.benchmark-pr.outputs.BENCH_RESULT_20 }} - PR-BENCH-22: ${{ steps.benchmark-pr.outputs.BENCH_RESULT_22 }} - PR-BENCH-24: ${{ steps.benchmark-pr.outputs.BENCH_RESULT_24 }} - BASE-BENCH-20: ${{ steps.benchmark-base.outputs.BENCH_RESULT_20 }} - BASE-BENCH-22: ${{ steps.benchmark-base.outputs.BENCH_RESULT_22 }} - BASE-BENCH-24: ${{ steps.benchmark-base.outputs.BENCH_RESULT_24 }} - - strategy: - matrix: - node-version: ${{ fromJson(inputs.node-versions) }} - steps: - - name: Checkout ${{ inputs.pr-repo }}@${{ inputs.pr-ref }} - uses: actions/checkout@v5 - with: - persist-credentials: false - ref: ${{ inputs.pr-sha }} - repository: ${{ inputs.pr-repo }} - - - uses: actions/setup-node@v4 - with: - check-latest: true - node-version: ${{ matrix.node-version }} - - - name: Install ${{ inputs.pr-repo }}@${{ inputs.pr-ref }} - run: | - npm install --ignore-scripts - - - name: Run benchmark ${{ inputs.pr-repo }}@${{ inputs.pr-ref }} - id: benchmark-pr - env: - NODE_VERSION: ${{ matrix.node-version }} - run: | - echo "BENCH_RESULT_${NODE_VERSION}<> "$GITHUB_OUTPUT" - npm run --silent "$NPM_SCRIPT" >> "$GITHUB_OUTPUT" - echo 'EOF' >> "$GITHUB_OUTPUT" - - - name: Checkout ${{ inputs.base-repo }}@${{ inputs.base-ref }} - uses: actions/checkout@v5 - with: - persist-credentials: false - ref: ${{ inputs.base-sha }} - repository: ${{ inputs.base-repo }} - - - name: Install ${{ inputs.base-repo }}@${{ inputs.base-ref }} - run: | - npm install --ignore-scripts - - - name: Run benchmark ${{ inputs.base-repo }}@${{ inputs.base-ref }} - id: benchmark-base - env: - NODE_VERSION: ${{ matrix.node-version }} - run: | - echo "BENCH_RESULT_${NODE_VERSION}<> "$GITHUB_OUTPUT" - npm run --silent "$NPM_SCRIPT" >> "$GITHUB_OUTPUT" - echo 'EOF' >> "$GITHUB_OUTPUT" - - output-benchmark: - needs: benchmark - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - name: Comment PR - uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - message: | - **Node**: 20 - ${{ inputs.pr-repo }}@${{ inputs.pr-sha }} (${{ inputs.pr-ref }}): - ``` - ${{ needs.benchmark.outputs.PR-BENCH-20 }} - ``` - ${{ inputs.base-repo }}@${{ inputs.base-sha }} (${{ inputs.base-ref }}): - ``` - ${{ needs.benchmark.outputs.BASE-BENCH-20 }} - ``` - - --- - - **Node**: 22 - ${{ inputs.pr-repo }}@${{ inputs.pr-sha }} (${{ inputs.pr-ref }}): - ``` - ${{ needs.benchmark.outputs.PR-BENCH-22 }} - ``` - ${{ inputs.base-repo }}@${{ inputs.base-sha }} (${{ inputs.base-ref }}): - ``` - ${{ needs.benchmark.outputs.BASE-BENCH-22 }} - ``` - - --- - - **Node**: 24 - ${{ inputs.pr-repo }}@${{ inputs.pr-sha }} (${{ inputs.pr-ref }}): - ``` - ${{ needs.benchmark.outputs.PR-BENCH-24 }} - ``` - ${{ inputs.base-repo }}@${{ inputs.base-sha }} (${{ inputs.base-ref }}): - ``` - ${{ needs.benchmark.outputs.BASE-BENCH-24 }} - ``` diff --git a/README.md b/README.md index a877006..1378f03 100644 --- a/README.md +++ b/README.md @@ -88,51 +88,6 @@ jobs: | `lint` | false | boolean | `false` | Set to `true` to run the `lint` script in a repository's `package.json`. | | `node-versions` | false | string | `'["20", "22", "24"]'` | Provide A JSON array that specifies the Node.js versions on which the job should run. | -## Benchmark PR workflow - -The benchmark workflow expects `pull_request` or `pull_request_target` events. A common use for this workflow is to run benchmarks when a `benchmark` label is added to the PR. - -### Usage - -```yml -name: Benchmark PR - -on: - pull_request_target: - types: - - labeled - -jobs: - benchmark: - if: ${{ github.event.label.name == 'benchmark' }} - uses: fastify/workflows/.github/workflows/plugins-benchmark-pr.yml@v5 - with: - npm-script: bench - - remove-label: - if: "always()" - needs: benchmark - runs-on: ubuntu-latest - steps: - - name: Remove benchmark label - uses: octokit/request-action@v2.x - id: remove-label - with: - route: DELETE /repos/{repo}/issues/{issue_number}/labels/{name} - repo: ${{ github.event.pull_request.base.repo.full_name }} - issue_number: ${{ github.event.pull_request.number }} - name: benchmark - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -``` - -### Inputs -| Input Name | Required | Type | Default | Description | -| ---------------------------------- | ---------- | ------- | ----------- | ---------------------------------------------------------------------------------- | -| `npm-script` | false | string | `benchmark` | Provide the name of the npm script to run | -| `node-versions` | false | string | `'["20", "22", "24"]'` | Provide A JSON array that specifies the Node.js versions on which the job should run. | - - ## Acknowledgments Past sponsors: