Skip to content

Commit 06799dd

Browse files
committed
feat(playwright): add build artifact support and configurable sharding
1 parent 02dcf68 commit 06799dd

1 file changed

Lines changed: 74 additions & 1 deletion

File tree

.github/workflows/_checks-playwright.yaml

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,26 @@ on:
118118
description: "Disable sharding and run all tests in a single job. Useful for tests that require isolation."
119119
type: boolean
120120
default: false
121+
shard_count:
122+
description: "Number of shards to split tests into (default: 2). Ignored if disable_sharding is true."
123+
type: number
124+
default: 2
121125
artifact_suffix:
122126
description: "Suffix to append to artifact names for uniqueness (e.g., 'dind-1'). Useful when calling workflow multiple times."
123127
type: string
124128
default: ""
129+
build_artifact_name:
130+
description: "Name of the build artifact to download. If provided, skips build and uses the artifact instead."
131+
type: string
132+
default: ""
133+
build_artifact_path:
134+
description: "Path where to extract the build artifact. Defaults to working_directory. Use 'apps' for monorepo artifacts uploaded from apps/ directory."
135+
type: string
136+
default: ""
137+
post_artifact_command:
138+
description: "Command to run after downloading artifact (e.g., 'chmod +x path/to/binary'). Runs in working_directory."
139+
type: string
140+
default: ""
125141
secrets:
126142
env_local:
127143
description: "Env local file to set environment variables (one export per line)"
@@ -140,13 +156,38 @@ on:
140156
required: false
141157

142158
jobs:
159+
setup:
160+
name: Setup Matrix
161+
runs-on: ${{ inputs.runner }}
162+
outputs:
163+
matrix: ${{ steps.set-matrix.outputs.matrix }}
164+
steps:
165+
- name: Generate shard matrix
166+
id: set-matrix
167+
run: |
168+
if [ "${{ inputs.disable_sharding }}" == "true" ]; then
169+
echo 'matrix=[{"position":"single","playwrightShard":""}]' >> $GITHUB_OUTPUT
170+
else
171+
SHARD_COUNT=${{ inputs.shard_count }}
172+
MATRIX="["
173+
for i in $(seq 1 $SHARD_COUNT); do
174+
if [ $i -gt 1 ]; then
175+
MATRIX="$MATRIX,"
176+
fi
177+
MATRIX="$MATRIX{\"position\":\"shard$i\",\"playwrightShard\":\"$i/$SHARD_COUNT\"}"
178+
done
179+
MATRIX="$MATRIX]"
180+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
181+
fi
182+
143183
playwright:
144184
name: Playwright ${{ inputs.disable_sharding && 'Tests' || 'Shard' }}
185+
needs: setup
145186
runs-on: ${{ inputs.runner }}
146187
strategy:
147188
fail-fast: false
148189
matrix:
149-
include: ${{ inputs.disable_sharding && fromJson('[{"position":"single","playwrightShard":""}]') || fromJson('[{"position":"shard1","playwrightShard":"1/2"},{"position":"shard2","playwrightShard":"2/2"}]') }}
190+
include: ${{ fromJson(needs.setup.outputs.matrix) }}
150191
container:
151192
image: ${{ inputs.base_image }}
152193
env:
@@ -390,7 +431,39 @@ jobs:
390431
working-directory: ${{ inputs.working_directory }}
391432
run: ${{ steps.pm.outputs.pm }} ${{ inputs.env_init_command }}
392433

434+
- name: Download build artifact
435+
if: inputs.build_artifact_name != ''
436+
uses: actions/download-artifact@v4
437+
with:
438+
name: ${{ inputs.build_artifact_name }}
439+
path: ${{ inputs.build_artifact_path != '' && format('{0}/{1}', inputs.working_directory, inputs.build_artifact_path) || inputs.working_directory }}
440+
441+
- name: Verify downloaded artifact
442+
if: inputs.build_artifact_name != ''
443+
working-directory: ${{ inputs.working_directory }}
444+
run: |
445+
echo "=== Verifying artifact download ==="
446+
ARTIFACT_PATH="${{ inputs.build_artifact_path }}"
447+
if [ -n "$ARTIFACT_PATH" ]; then
448+
echo "Artifact downloaded to: ./$ARTIFACT_PATH"
449+
echo "Directory structure:"
450+
ls -la "./$ARTIFACT_PATH" || echo "ERROR: Artifact path not found"
451+
echo ""
452+
echo "Full tree (depth 3):"
453+
find "./$ARTIFACT_PATH" -maxdepth 3 -type d 2>/dev/null | head -30 || true
454+
else
455+
echo "Artifact downloaded to: ."
456+
echo "Directory structure:"
457+
ls -la "." | head -20
458+
fi
459+
460+
- name: Run post-artifact command
461+
if: inputs.build_artifact_name != '' && inputs.post_artifact_command != ''
462+
working-directory: ${{ inputs.working_directory }}
463+
run: ${{ inputs.post_artifact_command }}
464+
393465
- name: Run build
466+
if: inputs.build_artifact_name == ''
394467
working-directory: ${{ inputs.working_directory }}
395468
run: ${{ steps.pm.outputs.pm }} ${{ inputs.build_command }}
396469

0 commit comments

Comments
 (0)