Skip to content

feat(attachments): Emit outcomes when deleting pending attachments #61702

feat(attachments): Emit outcomes when deleting pending attachments

feat(attachments): Emit outcomes when deleting pending attachments #61702

name: 'frontend-snapshots'
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, edited]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
NODE_OPTIONS: '--max-old-space-size=4096'
SNAPSHOT_OUTPUT_DIR: .artifacts/snapshots
VCS_METADATA_FILE: .artifacts/vcs-metadata.json
jobs:
snapshots:
name: snapshot tests
# Skip 'edited' events that aren't a base branch change (e.g. title/body edits).
# When the base branch changes, the diff target changes so we need a fresh run.
if: github.event.action != 'edited' || github.event.changes.base != ''
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# Checkout the HEAD of the PR (or the commit if not a PR)
# Explicitly need to do this to avoid cases where the merge commit is used instead of the PR head,
# which can introduce diffs that aren't explicitly caused by the PR changes.
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
node-version-file: '.node-version'
- uses: pnpm/action-setup@36de12bed180fa130ed56a35e7344f2fa7a820ab # v4
- name: node_modules cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: nodemodulescache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('pnpm-lock.yaml', '.node-version') }}
- name: Install Javascript Dependencies
if: steps.nodemodulescache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
- name: Install Playwright system deps
timeout-minutes: 15
run: |
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/99-retries
echo 'Acquire::http::Timeout "30";' | sudo tee -a /etc/apt/apt.conf.d/99-retries
for i in 1 2 3; do
echo "::group::playwright install-deps (attempt $i)"
timeout -k 30 4m pnpm exec playwright install-deps chromium && ok=1 || ok=0
echo "::endgroup::"
[ "$ok" = 1 ] && exit 0
echo "Attempt $i failed; clearing apt locks and retrying in 15s..."
sudo pkill -9 -f apt-get 2>/dev/null || true
sudo rm -f /var/lib/apt/lists/lock /var/lib/dpkg/lock* /var/cache/apt/archives/lock 2>/dev/null || true
sudo dpkg --configure -a 2>/dev/null || true
sleep 15
done
echo "playwright install-deps failed after 3 attempts"
exit 1
- name: Playwright browser cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: playwrightcache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install Playwright browser
if: steps.playwrightcache.outputs.cache-hit != 'true'
timeout-minutes: 15
run: |
for i in 1 2 3; do
echo "::group::playwright install browser (attempt $i)"
timeout -k 30 4m pnpm exec playwright install chromium && ok=1 || ok=0
echo "::endgroup::"
[ "$ok" = 1 ] && exit 0
echo "Attempt $i failed or timed out; retrying in 15s..."
sleep 15
done
echo "playwright browser install failed after 3 attempts"
exit 1
- name: Run snapshot tests
env:
SENTRY_DSN: ${{ secrets.SENTRY_SNAPSHOTS_DSN }}
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }}
run: pnpm run snapshots
- name: Compute merge base SHA
if: github.event_name == 'pull_request' && !cancelled()
id: merge-base
# A failed build would suppress the upload workflow entirely; an empty
# base_sha only drops the comparison.
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: |
MERGE_BASE=$(gh api repos/${{ github.repository }}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} --jq '.merge_base_commit.sha')
echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT"
# PR context the upload workflow can't read from the workflow_run event.
- name: Write VCS metadata
if: ${{ !cancelled() }}
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
BASE_SHA: ${{ steps.merge-base.outputs.sha }}
run: |
set -euo pipefail
mkdir -p "$(dirname "$VCS_METADATA_FILE")"
jq -n \
--arg pr_number "$PR_NUMBER" \
--arg base_ref "$BASE_REF" \
--arg base_sha "$BASE_SHA" \
'{pr_number: $pr_number, base_ref: $base_ref, base_sha: $base_sha}' \
> "$VCS_METADATA_FILE"
cat "$VCS_METADATA_FILE"
- name: Upload snapshots artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: frontend-snapshots-${{ github.run_id }}
path: .artifacts
retention-days: 1
if-no-files-found: error
# .artifacts is a dot-directory, so its contents count as hidden.
include-hidden-files: true