Benchmark #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow benchmarks the library API using a previously successful build. | |
| # | |
| # It is triggered manually and requires the user to input the workflow run ID of the build. | |
| name: Benchmark | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| run_id: | |
| description: "Workflow run ID of a successful build" | |
| required: true | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| steps: | |
| - name: Get workflow run info | |
| id: get_run_info | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data: run } = await github.rest.actions.getWorkflowRun({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: ${{ github.event.inputs.run_id }} | |
| }); | |
| core.setOutput('commit_sha', run.head_sha); | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ steps.get_run_info.outputs.commit_sha }} | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: "zulu" | |
| - name: Download JARs from specified run | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: jars | |
| run-id: ${{ github.event.inputs.run_id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| path: jars/ | |
| - name: Get version from POM | |
| id: get_version | |
| run: | | |
| VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -f utilities/pom.xml) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Get short SHA | |
| id: get_short_sha | |
| run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Install artifacts | |
| run: | | |
| VERSION="${{ steps.get_version.outputs.version }}" | |
| # Install parent POM. | |
| mvn install:install-file \ | |
| -Dfile=pom.xml \ | |
| -DpomFile=pom.xml \ | |
| -DgroupId=au.csiro.pathling \ | |
| -DartifactId=pathling \ | |
| -Dversion=$VERSION \ | |
| -Dpackaging=pom | |
| # Install modules in dependency order. | |
| for MODULE in utilities encoders terminology fhirpath library-api library-runtime; do | |
| # Install main JAR. | |
| mvn install:install-file \ | |
| -Dfile=jars/$MODULE/target/$MODULE-$VERSION.jar \ | |
| -DpomFile=$MODULE/pom.xml \ | |
| -DgroupId=au.csiro.pathling \ | |
| -DartifactId=$MODULE \ | |
| -Dversion=$VERSION \ | |
| -Dpackaging=jar | |
| # Install sources JAR. | |
| mvn install:install-file \ | |
| -Dfile=jars/$MODULE/target/$MODULE-$VERSION-sources.jar \ | |
| -DpomFile=$MODULE/pom.xml \ | |
| -DgroupId=au.csiro.pathling \ | |
| -DartifactId=$MODULE \ | |
| -Dversion=$VERSION \ | |
| -Dpackaging=jar \ | |
| -Dclassifier=sources | |
| done | |
| - name: Build benchmark JAR | |
| run: mvn --batch-mode package -pl benchmark | |
| - name: Run benchmark | |
| run: | | |
| java -Xshare:off -Xmx8g -ea -Duser.timezone=UTC \ | |
| --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ | |
| --add-opens=java.base/java.net=ALL-UNNAMED \ | |
| -jar benchmark/target/benchmark-${{ steps.get_version.outputs.version }}.jar \ | |
| -rf json -rff benchmark-${{ steps.get_short_sha.outputs.short_sha }}.json | |
| - name: Save results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results-${{ steps.get_short_sha.outputs.short_sha }} | |
| path: benchmark-*.json |