name: Benchmark on: pull_request: branches: [master] push: branches: [master] workflow_dispatch: # Cancel in-flight benchmark runs for the same PR/branch so only the latest commit is benchmarked. concurrency: group: benchmark-${{ github.ref }} cancel-in-progress: true jobs: benchmark: name: Run CIBenchmark runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: "21" distribution: temurin - name: Set up Gradle uses: gradle/actions/setup-gradle@v4 - name: Run CIBenchmark run: > ./gradlew :opendc-experiments:opendc-experiments-base:jmh -PjmhIncludes=.*CIBenchmark.* - name: Upload benchmark results uses: actions/upload-artifact@v4 with: name: benchmark-results path: opendc-experiments/opendc-experiments-base/build/results/jmh/results.json retention-days: 7 # Store the PR number so the comment workflow (which runs with write permissions) # knows which PR to comment on. Only needed for pull_request runs. - name: Save PR number if: github.event_name == 'pull_request' run: echo "${{ github.event.pull_request.number }}" > pr-number.txt - name: Upload PR number if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 with: name: pr-number path: pr-number.txt retention-days: 1 # ── Master push: store results in the benchmark-data GitHub Release ─────────── store-results: name: Store benchmark results if: github.event_name == 'push' needs: benchmark runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 - name: Download current results uses: actions/download-artifact@v4 with: name: benchmark-results path: current-results - name: Download existing benchmark history run: | gh release download benchmark-data \ --repo atlarge-research/opendc \ --pattern benchmark-history.json \ --output existing-history.json 2>/dev/null \ || echo "[]" > existing-history.json env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Update history run: | python3 .github/scripts/update_history.py \ current-results/results.json \ existing-history.json \ updated-history.json \ "${{ github.sha }}" - name: Upload to release run: | gh release upload benchmark-data updated-history.json#benchmark-history.json \ --repo atlarge-research/opendc \ --clobber 2>/dev/null \ || gh release create benchmark-data \ --repo atlarge-research/opendc \ --title "Benchmark Data" \ --notes "Permanent storage for benchmark history. Managed automatically by CI." \ updated-history.json#benchmark-history.json env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}