Skip to content

Commit

Permalink
ci: don't fail if baseline is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
jlabedo committed Jun 3, 2023
1 parent 6220329 commit b6dc5e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/benchmark-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ jobs:
composer update --working-dir=packages/Laravel --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Download main branch benchmark data
id: cache-benchmark
uses: actions/cache@v3
with:
path: ./.phpbench
key: ${{ runner.os }}-benchmark-main

- name: Benchmarks
run: bin/run-benchmarks.php pr-stats.md
run: |
if [[ ${{ steps.cache-benchmark.outputs.cache-hit }} == 'true' ]]; then
bin/run-benchmarks.php pr-stats.md --ref=main
else
bin/run-benchmarks.php pr-stats.md
fi
env:
DATABASE_DSN: pgsql://ecotone:[email protected]:5432/ecotone
APP_DB_HOST: 127.0.0.1
Expand Down
12 changes: 9 additions & 3 deletions bin/run-benchmarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,25 @@
$commandInput = new ArgvInput(definition: new InputDefinition([
new InputArgument('output', InputArgument::OPTIONAL),
new InputOption('--baseline', null, InputOption::VALUE_NONE, 'generate baseline'),
new InputOption('--ref', null, InputOption::VALUE_OPTIONAL, 'baseline tag'),
]));
$outputToStream = $commandInput->getArgument('output');
$generateBaseline = $commandInput->getOption('baseline');
$refBaseline = $commandInput->getOption('ref');

$console = new ConsoleOutput();
$buffer = new BufferedOutput();
$buffer->writeln("# PR stats");
PhpBenchExtension::setDefaultOutput($buffer);
foreach ($profilesToBenchmark as $profile) {
$buffer->writeln("<details><summary>$profile benchmarks</summary>");
$input = $generateBaseline
? new StringInput("run --profile=$profile --report=aggregate --tag=main")
: new StringInput("run --profile=$profile --report=aggregate --ref=main");
$inputString = $generateBaseline
? "run --profile=$profile --report=aggregate --tag=main"
: "run --profile=$profile --report=aggregate";
if ($refBaseline) {
$inputString .= " --ref=$refBaseline";
}
$input = new StringInput($inputString);

$container = PhpBench::loadContainer($input);

Expand Down

0 comments on commit b6dc5e3

Please sign in to comment.