Github Actions provides the ability to use human-readable runner names, and Currents displays these in the dashboard, allowing you to see which runner executed each spec file.
This creates jobs that looks like this in Github Actions:
The final step is to visualize this in the Currents dashboard, which can be done by passing the runner name into the CURRENTS_MACHINE_ID environment variable:
The machineId will now be visible in the Currents dashboard for each spec file, making it possible to identify which machine or job executed a specific spec file.
Here is a complete example of a Github Action yaml file with this setup:
It is also possible to add a dynamic number of named runners by including an extra job in the workflow:
generate-matrix:runs-on:ubuntu-latestoutputs:matrix:${{ steps.set-matrix.outputs.matrix }}steps: - name:Set number of shardsid:set-shardsrun:echo "SHARDS=5" >> $GITHUB_ENV - name:Generate matrixid:set-matrixrun:| SHARDS=${SHARDS:-2} # Default to 2 if not set MATRIX="{\"include\":[" for i in $(seq 1 $SHARDS); do if [ $i -gt 1 ]; then MATRIX="$MATRIX,"; fi MATRIX="$MATRIX{\"runner_name\":\"MyRunner $i\",\"shard\":\"$i/$SHARDS\"}" done MATRIX="$MATRIX]}" echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
It is only needed to update run: echo "SHARDS=5" >> $GITHUB_ENV into the shards number is required.
A complete example can be found here:
dynamic-runners-workflow.yaml
name:Playwright Testson:push:branches: [main,master]pull_request:branches: [main,master]jobs:generate-matrix:runs-on:ubuntu-latestoutputs:matrix:${{ steps.set-matrix.outputs.matrix }}steps: - name:Set number of shardsid:set-shardsrun:echo "SHARDS=5" >> $GITHUB_ENV - name:Generate matrixid:set-matrixrun:| SHARDS=${SHARDS:-2} # Default to 2 if not set MATRIX="{\"include\":[" for i in $(seq 1 $SHARDS); do if [ $i -gt 1 ]; then MATRIX="$MATRIX,"; fi MATRIX="$MATRIX{\"runner_name\":\"MyRunner $i\",\"shard\":\"$i/$SHARDS\"}" done MATRIX="$MATRIX]}" echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"playwright-tests:needs:generate-matrixtimeout-minutes:60runs-on:ubuntu-lateststrategy:fail-fast:falsematrix:${{ fromJson(needs.generate-matrix.outputs.matrix) }}steps: - name:Log matrixrun:| echo "Running on ${{ matrix.runner_name }} with shard ${{ matrix.shard }}" - uses:actions/checkout@v3 - uses:actions/setup-node@v3with:node-version:18 - name:Install Playwright browsersrun:npx playwright install --with-deps - name:Install dependenciesrun:npm install - name:Run Playwright testsenv:CURRENTS_MACHINE_ID:${{ matrix.runner_name }} run: npx pwc --key ${{secrets.CURRENTS_RECORD_KEY}} --project-id ${{secrets.CURRENTS_PROJECT_ID}} --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}} --shard ${{ matrix.shard }}