Skip to content

Generated transformers instead of a generated middleware #1083

Generated transformers instead of a generated middleware

Generated transformers instead of a generated middleware #1083

Workflow file for this run

# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Benchmark"
on:
pull_request:
jobs:
phpbench:
name: "Benchmark"
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.5"
operating-system:
- "ubuntu-latest"
steps:
- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
- name: "Checkout base"
uses: actions/checkout@v7
with:
ref: ${{ github.base_ref }}
- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}
- name: "phpbench on base"
run: "vendor/bin/phpbench run tests/Benchmark --progress=none --tag=base"
- name: "Checkout"
uses: actions/checkout@v7
with:
clean: false
- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}
- name: "phpbench diff"
id: bench
continue-on-error: true
run: "vendor/bin/phpbench run tests/Benchmark --progress=none --report=diff --ref=base > bench.txt"
- uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
// the diff report prints one section per benchmark class: a title line, a console table, a blank line.
// The console table becomes a markdown table by dropping the outer borders and turning the border
// below the header into the separator row.
const sections = fs.readFileSync('bench.txt', 'utf8').trim().split(/\n\s*\n/).map((section) => {
const [title, , header, separator, ...rows] = section.trim().split('\n');
const table = [header, separator.replace(/\+/g, '|'), ...rows.filter((row) => !row.startsWith('+'))];
return `### ${title.replace(/Bench$/, '')}\n\n${table.join('\n')}`;
}).join('\n\n');
const failed = ${{ steps.bench.outcome == 'failure' }};
const commentBody = `Hello :wave:
Here are the most recent benchmark results, compared against \`${{ github.base_ref }}\`. Time is the mode over the iterations in the \`its\` column, with the relative standard deviation in brackets.
${sections}
${failed ? ':warning: At least one benchmark got slower than the tolerance in phpbench.json allows.' : ''}
This comment gets updated every time a new commit comes in.`;
// Get the existing comments.
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
})
// Find any comment already made by the bot.
const botComment = comments.find(comment => comment.user.id === 41898282)
if (!context.payload.pull_request.head.repo.full_name.startsWith('patchlevel/')) {
console.log('Not attempting to write comment on PR from fork');
} else {
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
body: commentBody
})
}
}
- name: "Fail on regression"
if: steps.bench.outcome == 'failure'
run: "exit 1"