An open source design system that's fully customizable and agent ready
TypeScript
chore(ci): remove pr-screenshots workflow (#596)
Cindy Zhangb5916259c6a1
diff --git a/.github/SAMPLE_PR_COMMENT.md b/.github/SAMPLE_PR_COMMENT.mdindex 3538ca2de4..a53f92d514 100644--- a/.github/SAMPLE_PR_COMMENT.md+++ b/.github/SAMPLE_PR_COMMENT.md@@ -76,10 +76,6 @@ This is an example of what the PR enrichment workflow will post as a comment on</details>-### Component Previews--Component screenshots are available in the [workflow artifacts](https://github.com/example/xds/actions/runs/12345).----<sub>Generated by PR Enrichment workflow | [View full report](https://github.com/example/xds/actions/runs/12345)</sub>diff --git a/.github/scripts/capture-screenshots.js b/.github/scripts/capture-screenshots.jsdeleted file mode 100644index c78e9d6e8d..0000000000--- a/.github/scripts/capture-screenshots.js+++ /dev/null@@ -1,504 +0,0 @@-#!/usr/bin/env node--/**- * @description Captures screenshots and videos of component stories using Playwright- * @input --storybook-dir <path> --output-dir <path> --components <comma-separated> --video- * @output PNG screenshots and GIF videos in output directory with manifest- */--const { chromium } = require('playwright');-const fs = require('fs');-const path = require('path');-const http = require('http');-const { execSync } = require('child_process');--const args = process.argv.slice(2);-const getArg = (name) => {- const idx = args.indexOf(`--${name}`);- return idx !== -1 ? args[idx + 1] : null;-};-const hasFlag = (name) => args.includes(`--${name}`);--const storybookDir = getArg('storybook-dir') || 'apps/storybook/dist';-const outputDir = getArg('output-dir') || 'screenshots';-const componentsArg = getArg('components') || '';-const components = componentsArg.split(',').filter(Boolean);-const captureVideo = hasFlag('video');--// Simple static file server with proper MIME types-function createServer(dir, port) {- return new Promise((resolve) => {- const server = http.createServer((req, res) => {- let filePath = path.join(dir, req.url === '/' ? 'index.html' : req.url);-- // Handle query strings- filePath = filePath.split('?')[0];-- const ext = path.extname(filePath);- const contentTypes = {- '.html': 'text/html',- '.js': 'application/javascript',- '.mjs': 'application/javascript',- '.cjs': 'application/javascript',- '.css': 'text/css',- '.json': 'application/json',- '.png': 'image/png',- '.jpg': 'image/jpeg',- '.jpeg': 'image/jpeg',- '.gif': 'image/gif',- '.svg': 'image/svg+xml',- '.woff': 'font/woff',- '.woff2': 'font/woff2',- '.ttf': 'font/ttf',- '.eot': 'application/vnd.ms-fontobject',- };-- fs.readFile(filePath, (err, data) => {- if (err) {- res.writeHead(404);- res.end('Not found');- return;- }- res.writeHead(200, { 'Content-Type': contentTypes[ext] || 'application/octet-stream' });- res.end(data);- });- });-- server.listen(port, () => {- console.log(`Storybook server running on http://localhost:${port}`);- resolve(server);- });- });-}--// Get stories from storybook-async function getStories(storybookPath) {- const storiesJsonPath = path.join(storybookPath, 'index.json');-- try {- const content = fs.readFileSync(storiesJsonPath, 'utf8');- const data = JSON.parse(content);- return data.entries || data.stories || {};- } catch (e) {- console.error('Could not read stories index:', e.message);- return {};- }-}--async function captureScreenshots() {- console.log('Starting screenshot capture...');- console.log(`Components to capture: ${components.length > 0 ? components.join(', ') : 'none (no components specified)'}`);-- // Ensure output directory exists- fs.mkdirSync(outputDir, { recursive: true });-- const storybookPath = path.resolve(process.cwd(), storybookDir);-- if (!fs.existsSync(storybookPath)) {- console.error(`Storybook build not found at ${storybookPath}`);- fs.writeFileSync(path.join(outputDir, 'screenshots.json'), JSON.stringify({- error: 'Storybook not built',- screenshots: [],- }));- return;- }-- // Start server- const port = 6006;- const server = await createServer(storybookPath, port);-- // Get stories- const stories = await getStories(storybookPath);- const storyIds = Object.keys(stories);-- console.log(`Found ${storyIds.length} stories`);-- // Filter stories for relevant components - exclude docs pages- const relevantStories = storyIds.filter(id => {- // Skip docs pages - they often have rendering issues- if (id.endsWith('--docs')) return false;-- // If no components specified, don't capture any (avoid accidental full runs)- if (components.length === 0) return false;-- const story = stories[id];- const title = story.title || '';-- // Titles are like "Core/XDSButton" or "Layout/XDSCard"- // Components are folder names like "Button" or "Layout"- const titleParts = title.split('/');- const componentPart = titleParts.length > 1 ? titleParts[1] : titleParts[0];- // Remove "XDS" prefix if present for matching- const normalizedComponent = componentPart.replace(/^XDS/i, '').toLowerCase();-- return components.some(comp => {- const compLower = comp.toLowerCase();- // Match only by component name (e.g., "Button" matches "Core/XDSButton")- return normalizedComponent === compLower;- });- });-- // When video is enabled, only record video for the Default story of each component- // to avoid spending ~7s per story on video capture + conversion- const defaultStoryIds = new Set();- if (captureVideo) {- const byComponent = {};- for (const storyId of relevantStories) {- const story = stories[storyId];- const title = story.title || '';- if (!byComponent[title]) byComponent[title] = [];- byComponent[title].push({ id: storyId, name: story.name || '' });- }- for (const [, componentStories] of Object.entries(byComponent)) {- // Prefer "Default" story, fall back to first story- const defaultStory = componentStories.find(s => s.name === 'Default') || componentStories[0];- if (defaultStory) defaultStoryIds.add(defaultStory.id);- }- }-- console.log(`Capturing ${relevantStories.length} relevant stories`);- if (captureVideo) {- console.log(`Video capture enabled for ${defaultStoryIds.size} default stories (screenshots only for the rest)`);- }-- const browser = await chromium.launch();-- const screenshots = [];-- for (const storyId of relevantStories) {- const story = stories[storyId];-- // Only record video for Default stories to save time- const shouldRecordVideo = captureVideo && defaultStoryIds.has(storyId);-- // Create context with video recording if enabled for this story- const contextOptions = {- viewport: { width: 800, height: 600 },- deviceScaleFactor: 2,- };-- if (shouldRecordVideo) {- contextOptions.recordVideo = {- dir: path.join(outputDir, 'videos'),- size: { width: 800, height: 600 },- };- // Ensure videos directory exists- fs.mkdirSync(path.join(outputDir, 'videos'), { recursive: true });- }-- const context = await browser.newContext(contextOptions);- const page = await context.newPage();-- try {- // Navigate to story in iframe mode- const url = `http://localhost:${port}/iframe.html?id=${storyId}&viewMode=story`;- await page.goto(url, { waitUntil: 'networkidle', timeout: 30000 });-- // Wait for Storybook to render the story- await page.waitForSelector('#storybook-root', { timeout: 10000 });-- // Wait for all stylesheets to be loaded- await page.evaluate(async () => {- // Wait for all link stylesheets- const links = Array.from(document.querySelectorAll('link[rel="stylesheet"]'));- await Promise.all(links.map(link => {- if (link.sheet) return Promise.resolve();- return new Promise((resolve) => {- link.addEventListener('load', resolve);- link.addEventListener('error', resolve);- });- }));-- // Wait for any style elements to be processed- await new Promise(resolve => requestAnimationFrame(resolve));- await new Promise(resolve => requestAnimationFrame(resolve));- });-- // Wait for styles to be injected (StyleX runtime injection)- await page.waitForTimeout(1500);-- // Wait for any fonts to load- await page.evaluate(() => document.fonts.ready);-- // Wait for CSS variables to be resolved - check for theme wrapper- await page.evaluate(async () => {- // Wait for CSS custom properties to be defined- const checkStyles = () => {- const storyRoot = document.querySelector('#storybook-root');- if (!storyRoot) return false;-- // Check if any element has computed styles (not just default)- const firstChild = storyRoot.querySelector('*');- if (firstChild) {- const styles = getComputedStyle(firstChild);- // Check if display is not empty (styles are applied)- return styles.display !== '';- }- return true;- };-- // Poll for styles to be ready- for (let i = 0; i < 20; i++) {- if (checkStyles()) break;- await new Promise(r => setTimeout(r, 100));- }- });-- // Additional wait for any CSS transitions/animations- await page.waitForTimeout(500);-- // If capturing video, ensure we have some content recorded- if (shouldRecordVideo) {- // Wait to ensure video has content- await page.waitForTimeout(500);- }-- // Take screenshot of just the story root- const storyRoot = await page.$('#storybook-root');-- const screenshotFilename = `${storyId.replace(/[^a-z0-9]/gi, '-')}.png`;- const screenshotPath = path.join(outputDir, screenshotFilename);-- if (storyRoot) {- await storyRoot.screenshot({ path: screenshotPath });- } else {- await page.screenshot({ path: screenshotPath, fullPage: false });- }-- const result = {- storyId,- title: story.title,- name: story.name,- filename: screenshotFilename,- };-- // If capturing video, simulate some interactions with visible cursor- if (shouldRecordVideo) {- // Inject a visible cursor element- await page.evaluate(() => {- const cursor = document.createElement('div');- cursor.id = 'playwright-cursor';- cursor.innerHTML = `- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M5.5 3.21V20.8C5.5 21.3 5.74 21.48 6.09 21.21L10.85 17.38L14.03 23.44C14.16 23.69 14.45 23.8 14.71 23.67L16.81 22.62C17.07 22.49 17.18 22.2 17.05 21.94L13.86 15.87L19.77 14.82C20.19 14.74 20.3 14.41 19.99 14.13L6.41 2.93C6.1 2.65 5.5 2.75 5.5 3.21Z" fill="white" stroke="black" stroke-width="1.5"/>- </svg>- `;- cursor.style.cssText = `- position: fixed;- top: 100px;- left: 100px;- width: 24px;- height: 24px;- pointer-events: none;- z-index: 999999;- transform: translate(-2px, -2px);- `;- document.body.appendChild(cursor);-- // Expose function to update cursor position- window.updateCursor = (x, y) => {- cursor.style.left = x + 'px';- cursor.style.top = y + 'px';- };- });-- // Helper function to move cursor smoothly to a position- const moveCursorTo = async (targetX, targetY) => {- // Get current cursor position- const pos = await page.evaluate(() => {- const cursor = document.getElementById('playwright-cursor');- return {- x: parseFloat(cursor.style.left) || 100,- y: parseFloat(cursor.style.top) || 100- };- });-- // Animate cursor movement in steps- const steps = 15;- for (let i = 1; i <= steps; i++) {- const x = pos.x + (targetX - pos.x) * (i / steps);- const y = pos.y + (targetY - pos.y) * (i / steps);-- // Update cursor position directly- await page.evaluate(({x, y}) => {- window.updateCursor(x, y);- }, {x, y});-- // Also move the actual mouse to trigger hover effects- await page.mouse.move(x, y);- await page.waitForTimeout(25);- }- };-- // Helper to move to element center- const moveCursorToElement = async (element) => {- const box = await element.boundingBox();- if (!box) return false;- await moveCursorTo(box.x + box.width / 2, box.y + box.height / 2);- return true;- };-- // Start cursor in center- await page.evaluate(() => window.updateCursor(400, 300));- await page.waitForTimeout(500);-- // Hover over interactive elements to show hover states- const buttons = await page.$$('button');- for (const button of buttons.slice(0, 3)) {- try {- if (await moveCursorToElement(button)) {- await page.waitForTimeout(500);- }- } catch {- // Element not hoverable, skip- }- }-- // Hover over links- const links = await page.$$('a');- for (const link of links.slice(0, 2)) {- try {- if (await moveCursorToElement(link)) {- await page.waitForTimeout(500);- }- } catch {- // Element not hoverable, skip- }- }-- // Hover over spans (badges, etc)- const spans = await page.$$('span[class]');- for (const span of spans.slice(0, 6)) {- try {- if (await moveCursorToElement(span)) {- await page.waitForTimeout(400);- }- } catch {- // Element not hoverable, skip- }- }-- // Move cursor away and wait- await moveCursorTo(50, 50);- await page.waitForTimeout(500);- }-- // Close page to finalize video recording- await page.close();-- let videoPath = null;- if (shouldRecordVideo) {- const video = page.video();- if (video) {- // Wait for video to be saved - this resolves when the file is ready- try {- videoPath = await video.path();- } catch (e) {- console.error(`[warn] Failed to get video path for ${storyId}: ${e.message}`);- }- }- }-- // Close context - this is when video is fully written- await context.close();-- // Now process video after context is closed- if (shouldRecordVideo && videoPath) {- // Give filesystem time to sync- await new Promise(r => setTimeout(r, 500));-- // Ensure the video file exists and has content- const videoStats = fs.existsSync(videoPath) ? fs.statSync(videoPath) : null;-- if (videoStats && videoStats.size > 1000) {- // Convert to GIF using ffmpeg- const gifFilename = `${storyId.replace(/[^a-z0-9]/gi, '-')}.gif`;- const gifPath = path.join(outputDir, gifFilename);-- // Also keep the video as mp4 for better quality viewing- const mp4Filename = `${storyId.replace(/[^a-z0-9]/gi, '-')}.mp4`;- const mp4Path = path.join(outputDir, mp4Filename);-- try {- // Convert webm to mp4 for broader compatibility- execSync(- `ffmpeg -i "${videoPath}" -c:v libx264 -preset fast -crf 23 "${mp4Path}" -y 2>&1`,- { stdio: 'pipe', timeout: 30000 }- );-- if (fs.existsSync(mp4Path) && fs.statSync(mp4Path).size > 100) {- result.mp4Filename = mp4Filename;- }- } catch (e) {- console.error(`[warn] MP4 conversion failed for ${storyId}: ${e.message}`);- }-- try {- // Use ffmpeg to convert webm to gif (with palette for better quality)- // Add -t 5 to limit to 5 seconds max, and use simpler filter for reliability- execSync(- `ffmpeg -i "${videoPath}" -t 5 -vf "fps=8,scale=400:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "${gifPath}" -y 2>&1`,- { stdio: 'pipe', timeout: 30000 }- );-- // Verify GIF was created- if (fs.existsSync(gifPath) && fs.statSync(gifPath).size > 100) {- result.videoFilename = gifFilename;- console.log(`[ok] Video: ${story.title} / ${story.name} (${videoStats.size} bytes webm -> gif + mp4)`);- } else {- console.error(`[warn] GIF file empty or not created for ${storyId}`);- }- } catch (e) {- console.error(`[warn] GIF conversion failed for ${storyId}: ${e.message}`);- }-- // Clean up webm file- try {- fs.unlinkSync(videoPath);- } catch {}- } else {- console.error(`[warn] Video file too small or missing for ${storyId}: ${videoStats?.size || 0} bytes`);- // Clean up invalid webm file- try {- if (videoPath && fs.existsSync(videoPath)) fs.unlinkSync(videoPath);- } catch {}- }- }-- screenshots.push(result);-- console.log(`[ok] Captured: ${story.title} / ${story.name}`);- } catch (e) {- console.error(`[fail] Failed: ${storyId} - ${e.message}`);- await context.close();- }- }-- await browser.close();- server.close();-- // Clean up videos directory if empty- try {- const videosDir = path.join(outputDir, 'videos');- if (fs.existsSync(videosDir) && fs.readdirSync(videosDir).length === 0) {- fs.rmdirSync(videosDir);- }- } catch {}-- // Write manifest- fs.writeFileSync(- path.join(outputDir, 'screenshots.json'),- JSON.stringify({- screenshots,- hasVideos: captureVideo,- capturedAt: new Date().toISOString()- }, null, 2)- );-- console.log(`\nCaptured ${screenshots.length} screenshots${captureVideo ? ' with videos' : ''}`);-}--captureScreenshots().catch(e => {- console.error('Screenshot capture failed:', e);- process.exit(1);-});diff --git a/.github/scripts/generate-pr-comment.js b/.github/scripts/generate-pr-comment.jsindex f8131b9e56..1acdf1a56c 100644--- a/.github/scripts/generate-pr-comment.js+++ b/.github/scripts/generate-pr-comment.js@@ -1,8 +1,8 @@#!/usr/bin/env node/**- * @description Generates and posts PR comment with analysis results and embedded screenshots- * @input --analysis <file> --a11y <file> --screenshots <file> --screenshot-urls <file> --storybook-url <url> --run-url <url>+ * @description Generates and posts PR comment with analysis results+ * @input --analysis <file> --a11y <file> --storybook-url <url> --run-url <url>* @output Formatted markdown comment body to stdout*/@@ -17,8 +17,6 @@ const getArg = (name) => {const analysisFile = getArg('analysis') || 'analysis.json';const a11yFile = getArg('a11y') || 'a11y-report.json';-const screenshotsFile = getArg('screenshots') || 'screenshots/screenshots.json';-const screenshotUrlsFile = getArg('screenshot-urls') || 'screenshot-urls.json';const runUrl = getArg('run-url') || '';const prNumber = getArg('pr-number') || '';const storybookUrl = getArg('storybook-url') || '';@@ -27,9 +25,6 @@ const sandboxUrl = getArg('sandbox-url') || '';// Read analysis resultslet analysis = { newComponents: [], modifiedComponents: [], componentStats: {}, totalBundle: {} };let a11yReport = { components: {} };-let screenshotsData = { screenshots: [] };-let screenshotUrls = {};-try {analysis = JSON.parse(fs.readFileSync(analysisFile, 'utf8'));} catch (e) {@@ -42,18 +37,6 @@ try {console.error('Warning: Could not read a11y report:', e.message);}-try {- screenshotsData = JSON.parse(fs.readFileSync(screenshotsFile, 'utf8'));-} catch (e) {- console.error('Warning: Could not read screenshots manifest:', e.message);-}--try {- screenshotUrls = JSON.parse(fs.readFileSync(screenshotUrlsFile, 'utf8'));-} catch (e) {- console.error('Warning: Could not read screenshot URLs:', e.message);-}-// Build a Storybook deep link URL for a component// Story titles like "Core/XDSButton" become path "/docs/core-xdsbutton--docs"function getStorybookLink(storybookBaseUrl, storyTitle) {@@ -140,69 +123,6 @@ if (analysis.bundleDelta) {bundleSection += `**Bundle size ${direction}:** ${delta > 0 ? '+' : ''}${delta} bytes\n\n`;}-// Build screenshots section with embedded images-let screenshotSection = '';-const hasAffectedComponents = (analysis.newComponents?.length > 0) || (analysis.modifiedComponents?.length > 0);-const screenshots = screenshotsData.screenshots || [];--if (hasAffectedComponents && screenshots.length > 0) {- screenshotSection = `### Component Previews\n\n`;-- const hasVideos = screenshots.some(s => s.videoFilename);- if (hasVideos) {- screenshotSection += `_Includes interactive hover previews as animated GIFs._\n\n`;- }-- // Group screenshots by component title- const byComponent = {};- for (const shot of screenshots) {- const compName = shot.title?.split('/').pop() || shot.title || 'Unknown';- if (!byComponent[compName]) {- byComponent[compName] = [];- }- byComponent[compName].push(shot);- }-- for (const [compName, shots] of Object.entries(byComponent)) {- screenshotSection += `#### ${compName}\n\n`;-- for (const shot of shots) {- const storyName = shot.name || shot.storyId;- const filename = shot.filename;- const imageUrl = screenshotUrls[filename];- const videoFilename = shot.videoFilename;- const videoUrl = videoFilename ? screenshotUrls[videoFilename] : null;- const mp4Filename = shot.mp4Filename;- const mp4Url = mp4Filename ? screenshotUrls[mp4Filename] : null;-- if (imageUrl || videoUrl) {- screenshotSection += `<details>\n<summary><strong>${storyName}</strong></summary>\n\n`;-- if (imageUrl) {- screenshotSection += `**Screenshot:**\n\n\n\n`;- }-- if (videoUrl) {- // Link to mp4 if available, otherwise link to gif- const fullVideoUrl = mp4Url || videoUrl;- screenshotSection += `**Interaction Preview:** (${extLink('view video', fullVideoUrl)})\n\n\n\n`;- }-- // Build a direct Storybook link for this specific story- const storyLink = storybookUrl ? `${storybookUrl}?path=/story/${shot.storyId}` : null;- if (storyLink) {- screenshotSection += `${extLink('View in Storybook', storyLink)} · `;- }- screenshotSection += `\`${shot.storyId}\`\n\n`;-- screenshotSection += `</details>\n\n`;- } else {- screenshotSection += `- **${storyName}** _(media not available)_\n`;- }- }- }-}-// Build storybook link sectionlet storybookSection = '';if (storybookUrl) {@@ -238,7 +158,6 @@ const body = `## PR Analysis Report${storybookSection}${sandboxSection}${componentSection || '_No new or modified components detected._\n\n'}${bundleSection}${a11ySection}-${screenshotSection}---<sub>Generated by PR Enrichment workflow${footerLinksStr}</sub>diff --git a/.github/scripts/test-pr-enrichment.js b/.github/scripts/test-pr-enrichment.jsindex b3d8610323..0df0023eee 100644--- a/.github/scripts/test-pr-enrichment.js+++ b/.github/scripts/test-pr-enrichment.js@@ -225,21 +225,12 @@ if (analysis.bundleDelta) {bundleSection += `**Bundle size ${direction}:** ${delta > 0 ? '+' : ''}${delta} bytes\n\n`;}-// Build screenshots section-let screenshotSection = '';-const hasAffectedComponents = (analysis.newComponents?.length > 0) || (analysis.modifiedComponents?.length > 0);-if (hasAffectedComponents && runUrl) {- screenshotSection = `### Component Previews\n\n`;- screenshotSection += `Component screenshots are available in the [workflow artifacts](${runUrl}).\n\n`;-}-// Build the full commentconst body = `## PR Analysis Report${componentSection || '_No new or modified components detected._\n\n'}${bundleSection}${a11ySection}-${screenshotSection}---<sub>Generated by PR Enrichment workflow${runUrl ? ` | [View full report](${runUrl})` : ''}</sub>diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex c9400941bf..a610040a46 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1,4 +1,4 @@-# PR CI: test, build, analyze, screenshot, a11y audit, and comment+# PR CI: test, build, analyze, a11y audit, and comment# Everything runs in parallel where possible## Merge queue: test + build also run on merge_group events so the@@ -23,7 +23,7 @@ concurrency:jobs:# Lightweight check — does the PR touch any core components?- # Gates pr-screenshots and pr-a11y to avoid unnecessary work+ # Gates pr-a11y to avoid unnecessary workcheck-components:if: github.event_name == 'pull_request'runs-on: ubuntu-latest@@ -171,7 +171,7 @@ jobs:retention-days: 1# Post PR comment with preview links + analysis as soon as build finishes- # Does NOT wait for test, screenshots, or a11y — those update the comment later+ # Does NOT wait for test or a11y — those update the comment laterpr-comment:if: github.event_name == 'pull_request'needs: [build]@@ -242,98 +242,7 @@ jobs:});}- # Capture component screenshots and videos (parallel with a11y)- # Skipped when no components changed.- pr-screenshots:- needs: [build, check-components]- if: github.event_name == 'pull_request' && needs.check-components.outputs.has_components == 'true'- runs-on: ubuntu-latest- steps:- - name: Checkout- uses: actions/checkout@v4-- - name: Setup Node.js- uses: actions/setup-node@v4- with:- node-version: 22- cache: 'yarn'-- - name: Download analysis artifact- uses: actions/download-artifact@v4- with:- name: pr-analysis-- - name: Download Storybook artifact- uses: actions/download-artifact@v4- with:- name: storybook-${{ needs.build.outputs.short_hash }}- path: apps/storybook/dist-- - name: Install Playwright- run: yarn install --frozen-lockfile && npx playwright install chromium-- - name: Install ffmpeg for video conversion- run: sudo apt-get update && sudo apt-get install -y ffmpeg-- - name: Capture component screenshots and videos- run: |- COMPONENTS=$(cat analysis.json | jq -r '(.newComponents + .modifiedComponents) | join(",")')- node .github/scripts/capture-screenshots.js \- --storybook-dir apps/storybook/dist \- --output-dir screenshots \- --components "$COMPONENTS" \- --video-- - name: Upload screenshots and videos to GitHub- env:- REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}- run: |- npm install -g @dvcorg/cml-- echo '{}' > screenshot-urls.json-- for file in screenshots/*.png; do- if [ -f "$file" ]; then- filename=$(basename "$file")- url=$(cml publish "$file")- echo "Uploaded $filename -> $url"- jq --arg name "$filename" --arg url "$url" \- '. + {($name): $url}' screenshot-urls.json > tmp.json && mv tmp.json screenshot-urls.json- fi- done-- for file in screenshots/*.gif; do- if [ -f "$file" ]; then- filename=$(basename "$file")- url=$(cml publish "$file")- echo "Uploaded $filename -> $url"- jq --arg name "$filename" --arg url "$url" \- '. + {($name): $url}' screenshot-urls.json > tmp.json && mv tmp.json screenshot-urls.json- fi- done-- for file in screenshots/*.mp4; do- if [ -f "$file" ]; then- filename=$(basename "$file")- url=$(cml publish "$file")- echo "Uploaded $filename -> $url"- jq --arg name "$filename" --arg url "$url" \- '. + {($name): $url}' screenshot-urls.json > tmp.json && mv tmp.json screenshot-urls.json- fi- done-- cat screenshot-urls.json-- - name: Upload screenshots artifact- uses: actions/upload-artifact@v4- with:- name: component-screenshots- path: |- screenshots/- screenshot-urls.json- retention-days: 30-- # Accessibility audit (parallel with screenshots)+ # Accessibility audit# Skipped when no components changed.pr-a11y:needs: [build, check-components]@@ -378,9 +287,9 @@ jobs:path: a11y-report.jsonretention-days: 1- # Update PR comment with screenshots + a11y results once they're ready+ # Update PR comment with a11y results once they're readypr-comment-update:- needs: [build, check-components, pr-screenshots, pr-a11y]+ needs: [build, check-components, pr-a11y]if: always() && github.event_name == 'pull_request' && needs.build.result == 'success' && needs.check-components.outputs.has_components == 'true'runs-on: ubuntu-lateststeps:@@ -397,13 +306,6 @@ jobs:with:name: pr-analysis- - name: Download screenshots artifact- if: needs.pr-screenshots.result == 'success'- uses: actions/download-artifact@v4- with:- name: component-screenshots- path: screenshots-artifact-- name: Download a11y artifactif: needs.pr-a11y.result == 'success'uses: actions/download-artifact@v4@@ -418,20 +320,9 @@ jobs:echo '{"components":{},"summary":{"componentsAudited":0,"totalViolations":0}}' > a11y-report.jsonfi- SCREENSHOTS_ARG=""- SCREENSHOT_URLS_ARG=""- if [ -f screenshots-artifact/screenshots/screenshots.json ]; then- SCREENSHOTS_ARG="--screenshots screenshots-artifact/screenshots/screenshots.json"- fi- if [ -f screenshots-artifact/screenshot-urls.json ]; then- SCREENSHOT_URLS_ARG="--screenshot-urls screenshots-artifact/screenshot-urls.json"- fi-COMMENT_BODY=$(node .github/scripts/generate-pr-comment.js \--analysis analysis.json \--a11y a11y-report.json \- $SCREENSHOTS_ARG \- $SCREENSHOT_URLS_ARG \--storybook-url "${{ needs.build.outputs.storybook_url }}" \--sandbox-url "${{ needs.build.outputs.sandbox_url }}" \--run-url "$RUN_URL" \