improve release workflow
[yosql.git] / .github / workflows / benchmarks.yml
blob5e05e1411704e78c80fd10c6433b3de6677ed825
1 name: Run Benchmarks
2 on:
3   release:
4     types: [released]
5 env:
6   JAVA_VERSION: 17
7   JAVA_PACKAGE: jdk
8   JAVA_ARCH: x64
9   JAVA_DISTRO: temurin
10 jobs:
11   benchmarks:
12     name: Benchmarks
13     runs-on: ubuntu-latest
14     permissions:
15       contents: write
16     strategy:
17       matrix:
18         benchmark: [codegen, dao]
19     steps:
20       - id: checkout
21         name: Clone Git Repository
22         uses: actions/checkout@v4
23         with:
24           fetch-depth: 0
25       - id: last_release
26         name: Fetch last release info
27         run: echo "tag=$(gh release view --json tagName --jq '.tagName')" >> $GITHUB_OUTPUT
28         env:
29           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30       - id: java
31         name: Setup Java
32         uses: actions/setup-java@v4
33         with:
34           java-version: ${{ env.JAVA_VERSION }}
35           java-package: ${{ env.JAVA_PACKAGE }}
36           architecture: ${{ env.JAVA_ARCH }}
37           distribution: ${{ env.JAVA_DISTRO }}
38           cache: maven
39       - id: run-benchmark
40         name: Run Benchmark [${{ matrix.benchmark }}]
41         run: mvn --batch-mode --projects yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }} --also-make --activate-profiles benchmarks verify --define org.slf4j.simpleLogger.log.yosql=warn --define skipTests 2>&1 1> build.log
42       - id: copy-results
43         name: Copy ${{ matrix.benchmark }} Results
44         run: cp --force ./yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }}/target/benchmark/yosql-benchmarks-${{ matrix.benchmark }}.json ./yosql-website/content/benchmarks/results/yosql-benchmarks-${{ matrix.benchmark }}-${{ steps.last_release.outputs.tag }}.json
45       - id: replace-results
46         name: Replace CURRENT ${{ matrix.benchmark }} Results
47         run: cp --force ./yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }}/target/benchmark/yosql-benchmarks-${{ matrix.benchmark }}.json ./yosql-website/content/benchmarks/results/yosql-benchmarks-${{ matrix.benchmark }}-CURRENT.json
48       - id: push
49         name: Push Changes
50         uses: stefanzweifel/git-auto-commit-action@v5
51         with:
52           commit_message: Update benchmark data for ${{ steps.last_release.outputs.tag }}
53           file_pattern: yosql-website/*.json
54       - id: cpr
55         name: Create Pull Request
56         uses: peter-evans/create-pull-request@v5
57         with:
58           token: ${{ secrets.PAT }}
59           commit-message: Update benchmarks for latest release
60           committer: GitHub <noreply@github.com>
61           author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
62           title: Update benchmarks for latest release
63           body: ${{ steps.gwu.outputs.version-information }}
64           labels: |
65             Release :: Ignore
66             Benchmarks :: CodeGen
67             Benchmarks :: DAO
68             Priority :: Low
69             Type :: Task
70           assignees: sebhoss
71           draft: false
72           base: main
73           branch: update-benchmarks
74           delete-branch: true
75       - name: Enable Pull Request Automerge
76         if: steps.cpr.outputs.pull-request-operation == 'created'
77         run: gh pr merge --rebase --auto "${{ steps.cpr.outputs.pull-request-number }}"
78         with:
79           token: ${{ secrets.PAT }}