Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 61 additions & 2 deletions .github/workflows/test-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ on:
default: ''
required: false
type: string
BUILD_WORKFLOW_FILENAME:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is odd in my opinion. It seems to be used as a fallback when no TESTED_ARTIFACT_SLUG is passed (because it is optional).

But the fallback hinges on the assumption that whatever other (non-build-and-distribute) build workflow also produces an artifact. And that said artifact cannot be referenced with a predictable name (convention or workflow output)

Is there even a second build workflow where these constraints apply?

Maybe I lack the full picture, but my gut feeling would be to make this "named artifact only" and reduce the complexity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Mollie repo the WF which calls B&D is:

Name: Create release package
Filename: release.yml

description: Workflow filename to resolve the build run ID from when triggered outside of a workflow_run event.
default: 'build-and-distribute.yml'
required: false
type: string
TESTED_ARTIFACT_DIR:
Comment thread
mishautkin marked this conversation as resolved.
Outdated
description: Directory to download the tested artifact into.
default: 'tests/qa/resources/files'
required: false
type: string
TESTED_ARTIFACT_SLUG:
Comment thread
mishautkin marked this conversation as resolved.
Outdated
description: >
Plugin slug used to download and rename the tested artifact.
Downloads the B&D artifact matching `<slug>-*` and renames it to `<slug>.zip`
in TESTED_ARTIFACT_DIR, ready for plugin installation.
default: ''
required: false
type: string
secrets:
ENV_FILE_DATA:
description: Additional environment variables for the tests.
Expand Down Expand Up @@ -189,8 +207,7 @@ jobs:
rsync -av ./build/ . && rm -rf ./build/

- name: Install Playwright dependencies
run: |
npx playwright install ${{ inputs.PLAYWRIGHT_BROWSER_ARGS }}
run: npx playwright install ${{ inputs.PLAYWRIGHT_BROWSER_ARGS }}

- name: Create environment file
env:
Expand Down Expand Up @@ -267,6 +284,48 @@ jobs:
npx wp-env run tests-cli wp config set WP_HOME "$NGROK_URL"
sed -i "s|WP_BASE_URL=.*|WP_BASE_URL=$NGROK_URL|" .env.ci

- name: Resolve tested artifact run ID
id: resolve-artifact-run-id
if: ${{ inputs.TESTED_ARTIFACT_SLUG != '' }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to run when the slug is NOT passed, right?

@mishautkin mishautkin Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opposite 🤔: supposed to run only if the slug is passed. This WF is also used for tests of websites which are deployed to static test envs - in this case there's no artifact

env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" = "workflow_run" ]; then
RUN_ID="${{ github.event.workflow_run.id }}"
echo "Using workflow_run event run ID: $RUN_ID"
else
RUN_ID=$(gh run list \
--repo "${{ github.repository }}" \
--workflow="${{ inputs.BUILD_WORKFLOW_FILENAME }}" \
--branch="${{ github.ref_name }}" \
--status=success \
--limit=1 \
--json databaseId \
-q '.[0].databaseId')
if [ -z "$RUN_ID" ]; then
echo "::error::No successful ${{ inputs.BUILD_WORKFLOW_FILENAME }} run found on branch ${{ github.ref_name }}"
exit 1
fi
echo "Resolved run ID from gh run list: $RUN_ID"
fi
echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"

- name: Download tested artifact
if: ${{ inputs.TESTED_ARTIFACT_SLUG != '' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh run download ${{ steps.resolve-artifact-run-id.outputs.run_id }} \
-p "${{ inputs.TESTED_ARTIFACT_SLUG }}-*" \
-D "${{ inputs.TESTED_ARTIFACT_DIR }}"

- name: Rename tested artifact
if: ${{ inputs.TESTED_ARTIFACT_SLUG != '' }}
working-directory: ${{ inputs.TESTED_ARTIFACT_DIR }}
run: |
SLUG="${{ inputs.TESTED_ARTIFACT_SLUG }}"
mv "${SLUG}-"*.zip "${SLUG}.zip"

- name: Execute custom code before executing the test script
env:
GH_TOKEN: ${{ github.token }}
Expand Down
Loading