From 77b73dcb3a2a461d846e354daa87ac6abebd1e4a Mon Sep 17 00:00:00 2001 From: rdlabo Date: Sun, 27 Sep 2026 03:07:03 +0900 Subject: [PATCH 1/2] fix: preserve adaptive tab screenshots in snapshot updates --- .github/workflows/update-screenshots.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-screenshots.yml b/.github/workflows/update-screenshots.yml index ce74833a..58540b53 100644 --- a/.github/workflows/update-screenshots.yml +++ b/.github/workflows/update-screenshots.yml @@ -105,7 +105,9 @@ jobs: uses: actions/upload-artifact@v5 with: name: updated-screenshots - path: demo/e2e/screenshot.spec.ts-snapshots/*.png + path: | + demo/e2e/screenshot.spec.ts-snapshots/*.png + demo/e2e/adaptive-tab-bar.spec.ts-snapshots/*.png if-no-files-found: error commit-screenshots: @@ -134,7 +136,8 @@ jobs: script: | const fs = require('fs'); const path = require('path'); - const snapshotPrefix = 'demo/e2e/screenshot.spec.ts-snapshots'; + const snapshotPrefix = 'demo/e2e'; + const snapshotDirectories = ['screenshot.spec.ts-snapshots', 'adaptive-tab-bar.spec.ts-snapshots']; const artifactDirectory = 'updated-screenshots'; const expectedHeadSha = process.env.EXPECTED_HEAD_SHA; const expectedHeadRef = process.env.EXPECTED_HEAD_REF; @@ -158,11 +161,20 @@ jobs: return; } - const filenames = fs.readdirSync(artifactDirectory).sort(); - if (filenames.length === 0 || filenames.some((filename) => !/^[A-Za-z0-9._-]+\.png$/.test(filename))) { - core.setFailed('The screenshot artifact contains an unexpected file.'); + const directories = fs.readdirSync(artifactDirectory).sort(); + if (directories.join('\n') !== [...snapshotDirectories].sort().join('\n')) { + core.setFailed('The screenshot artifact contains missing or unexpected directories.'); return; } + const filenames = []; + for (const directory of directories) { + const files = fs.readdirSync(path.join(artifactDirectory, directory)).sort(); + if (files.length === 0 || files.some((filename) => !/^[A-Za-z0-9._-]+\.png$/.test(filename))) { + core.setFailed('The screenshot artifact contains missing or unexpected files.'); + return; + } + filenames.push(...files.map((filename) => `${directory}/${filename}`)); + } const commit = await github.rest.git.getCommit({ owner: context.repo.owner, @@ -181,7 +193,7 @@ jobs: const tree = currentTree.data.tree .filter((entry) => entry.type === 'blob' && - entry.path.startsWith(`${snapshotPrefix}/`) && + snapshotDirectories.some((directory) => entry.path.startsWith(`${snapshotPrefix}/${directory}/`)) && !uploadedPaths.has(entry.path) ) .map((entry) => ({ path: entry.path, mode: '100644', type: 'blob', sha: null })); From d0014802102f8cc0c1ddd611f7f18d32609f99eb Mon Sep 17 00:00:00 2001 From: rdlabo Date: Sun, 27 Sep 2026 03:13:32 +0900 Subject: [PATCH 2/2] fix: scope required screenshots to the PR base branch --- .github/workflows/update-screenshots.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-screenshots.yml b/.github/workflows/update-screenshots.yml index 58540b53..542c6068 100644 --- a/.github/workflows/update-screenshots.yml +++ b/.github/workflows/update-screenshots.yml @@ -137,7 +137,8 @@ jobs: const fs = require('fs'); const path = require('path'); const snapshotPrefix = 'demo/e2e'; - const snapshotDirectories = ['screenshot.spec.ts-snapshots', 'adaptive-tab-bar.spec.ts-snapshots']; + const snapshotDirectories = ['screenshot.spec.ts-snapshots']; + if (process.env.EXPECTED_BASE_REF === 'main') snapshotDirectories.push('adaptive-tab-bar.spec.ts-snapshots'); const artifactDirectory = 'updated-screenshots'; const expectedHeadSha = process.env.EXPECTED_HEAD_SHA; const expectedHeadRef = process.env.EXPECTED_HEAD_REF;