Skip to content
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

SWC-6624: store Playwright reports with traces in S3 when e2e workflow runs in Sage repo #5245

Merged
merged 7 commits into from
Dec 13, 2023

Conversation

hallieswan
Copy link
Contributor

.. Sage-Bionetworks repo forked repos
traces included in report not included in report
report location S3 bucket GitHub artifact
saved report format one blob per shard archive of blobs and merged HTML report
trigger push to develop and release-** branches push
job concurrency restricted - allow at most one playwright-tests job to run at a time within the repo unrestricted
matrix strategy 3 shards 3 shards
matrix parallelization restricted - allow at most one shard to run at a time per workflow run allow all three shards to run at the same time per workflow run

Comment on lines +30 to +39
# Ensure that at most one playwright-tests job will run at a time in Sage-Bionetworks repo,
# but allow multiple playwright-test jobs to run concurrently in forked repos
# Per https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
# "When a concurrent job or workflow is queued, if another job or workflow
# using the same concurrency group in the repository is in progress,
# the queued job or workflow will be pending. Any previously pending job or
# workflow in the concurrency group will be cancelled."
# Related discussion here: https://github.com/orgs/community/discussions/5435
concurrency:
group: ${{ github.repository_owner == 'Sage-Bionetworks' && format('${0}-${1}', github.workflow, '-playwright-tests') || format('${0}-${1}', github.run_id, matrix.shard ) }}
Copy link
Contributor Author

@hallieswan hallieswan Dec 12, 2023

Choose a reason for hiding this comment

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

Apply a concurrency group to playwright-tests jobs so that the e2e workflow uses at most one macOS runner at a time. GitHub's current concurrency implementation cancels previously queued pending jobs, rather than queuing and executing all pending jobs. So if more than two e2e workflow runs are triggered at the same time, depending on when each playwright-tests job starts, a subset or none of the e2e shards may run per workflow run. However, once all other jobs have finished running, the cancelled job(s) could be manually re-triggered, if needed.

For now, plan to monitor the e2e tests and the frequency of cancelled jobs, then decide whether another solution should be investigated.

Note: I applied concurrency at the playwright-tests job level, so that the build job (which builds SWC and runs unit tests on a Linux runner) will always run, regardless of how many e2e workflows have been triggered.

Comment on lines +85 to +86
TRACE_TOGGLE: ${{ github.repository_owner == 'Sage-Bionetworks' && 'on' || 'off'}}
run: yarn playwright test --shard ${{ matrix.shard }} --trace=${{ env.TRACE_TOGGLE }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only record a trace when running the workflow in the Sage-Bionetworks repo

- name: Upload blob report to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
if: always()
if: ${{ github.repository_owner != 'Sage-Bionetworks' && always() }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only attach the blob report as a GitHub artifact in forked repos

@@ -83,7 +112,7 @@ jobs:
merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
# But skip this job if the previous job was cancelled or skipped
if: ${{ !cancelled() && needs.playwright-tests.result != 'skipped' }}
if: ${{ github.repository_owner != 'Sage-Bionetworks' && !cancelled() && needs.playwright-tests.result != 'skipped' }}
Copy link
Contributor Author

@hallieswan hallieswan Dec 12, 2023

Choose a reason for hiding this comment

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

Similarly, only merge the blob reports into an HTML report in forked repos

@hallieswan hallieswan marked this pull request as ready for review December 12, 2023 21:53
@hallieswan hallieswan self-assigned this Dec 12, 2023
Copy link
Contributor

@nickgros nickgros left a comment

Choose a reason for hiding this comment

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

LGTM! The bash scripts will be especially helpful, and the README updates are very much appreciated.

e2e_workflow/README.md Outdated Show resolved Hide resolved
- name: Upload blob report to S3
if: github.repository_owner == 'Sage-Bionetworks'
run: |
aws s3 sync ./blob-report --region us-east-1 s3://${{ env.DESTINATION_BUCKET }}/${{ env.REPORT_ID }}/
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a retention policy be specified here? Or is it specified on the bucket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The policy is specified on the bucket -- objects are set to expire after 14 days, which matches the retention set for reports stored as GitHub artifacts.

-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${REPO_OWNER}/${REPO_NAME}/actions/runs/${RUN_ID}/artifacts" \
| jq '.artifacts[] | select(.name | contains("html-report")) | {id, name}')
Copy link
Contributor

Choose a reason for hiding this comment

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

jq may not be installed on dev machines, might want to add that to instructions (unless maybe it's a dependency of gh?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh good call! I don't believe jq is a dependency of gh, so I'll make a note to install it in the README.

Copy link
Contributor

@xschildw xschildw left a comment

Choose a reason for hiding this comment

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

Nice! Couple of questions offline.

@hallieswan hallieswan merged commit 5b74853 into develop Dec 13, 2023
8 checks passed
@hallieswan hallieswan deleted the SWC-6624 branch December 13, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants