mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-13 15:46:46 +03:00
858ba9eabc
Upgrading release-please-action to v4 requires some changes: - Move some settings from the action inputs to a manifest file (release-type, extra-files) - Rename default-branch to target-branch Additionally: - There is an example in the new release-please-action docs that covers our exact use case for upload-release-action, but with the official GitHub CLI app. So we drop upload-release-action and use the GitHub CLI instead. - There is an output in release-please-action that gives access to the patch version from semver. We should use this instead of running endsWith() over tag_name. - Update mxschmitt/action-tmate@v3.6 => v3.17. This is a trivial update on an action that I missed in my last audit.
130 lines
4.3 KiB
YAML
130 lines
4.3 KiB
YAML
name: Update All Screenshots
|
|
# Updates all screenshots on an existing PR, assuming permission has been given
|
|
# to maintainers to make edits.
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
# Allows for manual triggering on PRs. They should be reviewed first, to
|
|
# avoid malicious code executing in the lab.
|
|
inputs:
|
|
pr:
|
|
description: "A PR number to build and test in the lab, then update all the screenshots."
|
|
required: true
|
|
|
|
jobs:
|
|
set-pending-status:
|
|
name: Set Pending Status
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: refs/pull/${{ inputs.pr }}/head
|
|
|
|
- name: Set commit status to pending
|
|
uses: ./.github/workflows/custom-actions/set-commit-status
|
|
with:
|
|
context: Update All Screenshots
|
|
state: pending
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run-lab-tests:
|
|
name: Get Selenium Lab Screenshots
|
|
needs: [set-pending-status]
|
|
uses: ./.github/workflows/selenium-lab-tests.yaml
|
|
with:
|
|
pr: ${{ inputs.pr }}
|
|
test_filter: layout
|
|
ignore_test_status: true
|
|
job_name_prefix: "Get Selenium Lab Screenshots / "
|
|
|
|
update-pr:
|
|
name: Update PR
|
|
runs-on: ubuntu-latest
|
|
needs: [run-lab-tests]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: refs/pull/${{ inputs.pr }}/head
|
|
|
|
- name: Get artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: test/test/assets/screenshots/
|
|
pattern: screenshots-*
|
|
merge-multiple: true
|
|
|
|
- name: Update screenshots
|
|
run: |
|
|
# Install prerequisites.
|
|
npm ci
|
|
|
|
# Update the official screenshots for any that have visibly changed.
|
|
# This is not a byte-for-byte comparison, but based on pixel diffs.
|
|
./build/updateScreenshots.py
|
|
|
|
# Emulate the actions bot.
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
# Commit the changes. Ignore failure, in case there are no changes.
|
|
git add test/test/assets/screenshots/*/*.png || true
|
|
git commit -m ':robot: Update all screenshots' || true
|
|
|
|
- name: Update PR
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
# Update the PR.
|
|
PR_API_URL="/repos/${{ github.repository }}/pulls/${{ inputs.pr }}"
|
|
REMOTE=$(gh api $PR_API_URL | jq -r .head.repo.html_url)
|
|
BRANCH=$(gh api $PR_API_URL | jq -r .head.ref)
|
|
|
|
# If there were no changes, this will do nothing, but succeed.
|
|
git push "$REMOTE" HEAD:"$BRANCH"
|
|
|
|
- name: Debug
|
|
uses: mxschmitt/action-tmate@v3.17
|
|
with:
|
|
limit-access-to-actor: true
|
|
if: failure()
|
|
|
|
set-final-status:
|
|
name: Set Final Status
|
|
runs-on: ubuntu-latest
|
|
needs: [run-lab-tests, update-pr]
|
|
# Will run on success or failure, but not if the workflow is cancelled.
|
|
if: ${{ success() || failure() }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: refs/pull/${{ inputs.pr }}/head
|
|
|
|
- name: Compute final status
|
|
id: compute
|
|
run: |
|
|
# The final status must be one of: success, failure, error, pending.
|
|
# However, the status from "result" from an earlier job is one of:
|
|
# success, failure, cancelled, skipped.
|
|
# We start by mapping those.
|
|
LAB_TEST_RESULT=$(echo "${{ needs.run-lab-tests.result }}" \
|
|
| sed -Ee 's/(cancelled|skipped)/error/')
|
|
UPDATE_PR_RESULT=$(echo "${{ needs.update-pr.result }}" \
|
|
| sed -Ee 's/(cancelled|skipped)/error/')
|
|
|
|
if [[ "$LAB_TEST_RESULT" == "success" ]]; then
|
|
# If run-lab-tests succeeded, use the status of update-pr, which
|
|
# comes after that. If that is blank, default to "error".
|
|
echo "status=${UPDATE_PR_RESULT:-error}" >> $GITHUB_OUTPUT
|
|
else
|
|
# If run-lab-tests failed, use that. If that is blank, default to
|
|
# "error".
|
|
echo "status=${LAB_TEST_RESULT:-error}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Report final status
|
|
uses: ./.github/workflows/custom-actions/set-commit-status
|
|
with:
|
|
context: Update All Screenshots
|
|
state: ${{ steps.compute.outputs.status }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|