-
Notifications
You must be signed in to change notification settings - Fork 6
Reuse B&D artifact in test-playwright.yml #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
650e47e
14f2f4c
99cb100
d8febed
e47c138
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,24 @@ on: | |
| default: '' | ||
| required: false | ||
| type: string | ||
| BUILD_WORKFLOW_FILENAME: | ||
| 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: | ||
|
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: | ||
|
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. | ||
|
|
@@ -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: | ||
|
|
@@ -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 != '' }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is supposed to run when the slug is NOT passed, right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||
|
|
||
There was a problem hiding this comment.
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_SLUGis 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.
There was a problem hiding this comment.
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