Unboxed ISQSXP #257
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
| name: benchmarks | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build-images: | |
| name: Images | |
| runs-on: ubuntu-latest | |
| outputs: | |
| test-matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Info | |
| shell: bash | |
| run: | | |
| echo "Github SHA: ${{ github.event.pull_request.head.sha || github.sha }}" | |
| echo "Log:" | |
| git log -1 | |
| echo "Submodules:" | |
| git submodule status | |
| - name: Compute hashes | |
| id: vars | |
| shell: bash | |
| # We cannot use github.sha because for pull_request events the github.sha | |
| # will point at a temporary merge commit, basically what would be the result of merging the PR. | |
| # Such commit does not exists in the origin. Therefore we have to parse the log to | |
| # get the merge commits (if they exist) | |
| run: | | |
| rsh_commit=$(git submodule status | sed -n 's/^[ +-]*\([0-9a-f]\{40\}\) .*external\/rsh.*/\1/p') | |
| rcp_commit=$(git rev-parse HEAD) | |
| echo "rsh_commit: $rsh_commit" | |
| echo "rcp_commit: $rcp_commit" | |
| echo "rsh_commit=$rsh_commit" >> "$GITHUB_OUTPUT" | |
| echo "rcp_commit=$rcp_commit" >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build prl-rpg/rcp-base | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile.rcp-base | |
| tags: | | |
| ghcr.io/prl-prg/rcp-base:latest | |
| ghcr.io/prl-prg/rcp-base | |
| push: true | |
| platforms: linux/amd64 | |
| cache-from: type=gha,scope=rcp-base | |
| cache-to: type=gha,mode=max,scope=rcp-base | |
| - name: Build prl-prg/rcp-rsh | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile.rcp-rsh | |
| build-args: | | |
| RSH_COMMIT=${{ steps.vars.outputs.rsh_commit }} | |
| tags: ghcr.io/prl-prg/rcp-rsh:${{ steps.vars.outputs.rsh_commit }} | |
| push: true | |
| platforms: linux/amd64 | |
| cache-from: type=gha,scope=rcp-rsh | |
| cache-to: type=gha,mode=max,scope=rcp-rsh | |
| - name: Build prl-prg/rcp | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile.rcp | |
| build-args: | | |
| RSH_COMMIT=${{ steps.vars.outputs.rsh_commit }} | |
| RCP_COMMIT=${{ steps.vars.outputs.rcp_commit }} | |
| tags: ghcr.io/prl-prg/rcp:${{ github.sha }} | |
| push: true | |
| platforms: linux/amd64 | |
| cache-from: type=gha,scope=rcp | |
| cache-to: type=gha,mode=max,scope=rcp | |
| - name: Discover test subdirectories | |
| id: set-matrix | |
| shell: bash | |
| run: | | |
| json=$(find rcp/tests -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort | jq -R . | jq -sc '{"test": .}') | |
| echo "Discovered tests: $json" | |
| echo "matrix=$json" >> "$GITHUB_OUTPUT" | |
| test: | |
| name: Test (${{ matrix.test }}) | |
| runs-on: ubuntu-latest | |
| needs: build-images | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.build-images.outputs.test-matrix) }} | |
| permissions: | |
| contents: read | |
| packages: read | |
| env: | |
| TEST_DOCKER_CONTAINER: test-${{ matrix.test }} | |
| steps: | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run ${{ matrix.test }} test | |
| shell: bash | |
| run: | | |
| docker run \ | |
| --name $TEST_DOCKER_CONTAINER \ | |
| ghcr.io/prl-prg/rcp:${{ github.sha }} \ | |
| bash -c "make -C /rcp/rcp/tests/${{ matrix.test }} test" | |
| - name: Cleanup | |
| if: always() | |
| run: docker rm -f $TEST_DOCKER_CONTAINER || true | |
| run-benchmarks: | |
| name: Benchmarks | |
| runs-on: self-hosted | |
| needs: test | |
| strategy: | |
| max-parallel: 1 | |
| matrix: | |
| bench_type: [bc, rcp] | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| BENCH_DOCKER_CONTAINER: bench-run | |
| BENCH_RESULT_NAME: benchmark-results | |
| # note: github workflow does not support variable expansion | |
| BENCH_OUT_DIR: /rcp/rcp/benchmark-results/${{ matrix.bench_type }} | |
| BENCH_ITER: 15 | |
| steps: | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Execute benchmarks | |
| shell: bash | |
| run: | | |
| docker run \ | |
| --name $BENCH_DOCKER_CONTAINER \ | |
| ghcr.io/prl-prg/rcp:${{ github.sha }} \ | |
| make benchmark \ | |
| BENCH_OPTS="--${{ matrix.bench_type }}" \ | |
| BENCH_OUT_DIR="$BENCH_OUT_DIR" \ | |
| BENCH_ITER="$BENCH_ITER" \ | |
| ${{ matrix.bench_type == 'bc' && 'R_HOME=/R-vanilla' || '' }} | |
| - name: Copy results | |
| run: | | |
| rm -fr $BENCH_RESULT_NAME | |
| docker cp $BENCH_DOCKER_CONTAINER:$BENCH_OUT_DIR $BENCH_RESULT_NAME | |
| - name: Cleanup | |
| if: always() | |
| run: docker rm -f $BENCH_DOCKER_CONTAINER || true | |
| - name: Archive results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmarks-${{ matrix.bench_type }} | |
| path: ${{ env.BENCH_RESULT_NAME }} |