diff --git a/.github/workflows/weekly-api-diff.yml b/.github/workflows/weekly-api-diff.yml index 1c49feb88d6..4c6a4f0e2ed 100644 --- a/.github/workflows/weekly-api-diff.yml +++ b/.github/workflows/weekly-api-diff.yml @@ -35,7 +35,7 @@ jobs: run: yarn build:api-published - name: Generate diff - run: yarn compare:apis --isCI > /tmp/diff-current.txt || true + run: yarn compare:apis --isCI > /tmp/diff-current.md || true # Check out snapshots repo so we can read the previous diff and commit the new one - uses: actions/checkout@v4 @@ -76,12 +76,12 @@ jobs: if [ "$NEW_RELEASE" != "true" ]; then # Compare against the last diff in the snapshots repo - PREV=$(ls snapshots/diffs/*.txt 2>/dev/null | sort -r | head -1) + PREV=$(ls snapshots/diffs/*.md 2>/dev/null | sort -r | head -1) echo "" echo "=== Delta computation ===" echo "Comparing against: ${PREV:-(none, first run)}" if [ -n "$PREV" ]; then - diff "$PREV" /tmp/diff-current.txt > /tmp/weekly-delta.txt || true + diff "$PREV" /tmp/diff-current.md > /tmp/weekly-delta.txt || true else echo "(first run — no previous diff to compare against)" > /tmp/weekly-delta.txt fi @@ -89,7 +89,7 @@ jobs: echo "" echo "=== File sizes ===" - echo "diff-current.txt: $(wc -c < /tmp/diff-current.txt) bytes" + echo "diff-current.md: $(wc -c < /tmp/diff-current.md) bytes" ls /tmp/weekly-delta.txt 2>/dev/null && echo "weekly-delta.txt: $(wc -c < /tmp/weekly-delta.txt) bytes" || echo "weekly-delta.txt: not created" echo "" echo "=== Delta content (first 20 lines) ===" @@ -99,9 +99,9 @@ jobs: # Skip if no difference from last diff (aka no change from last week/last run), or if the diff against the release code is empty echo "" echo "=== Commit decision ===" - if [ -s /tmp/diff-current.txt ] && ([ "$NEW_RELEASE" = "true" ] || [ -s /tmp/weekly-delta.txt ]); then + if [ -s /tmp/diff-current.md ] && ([ "$NEW_RELEASE" = "true" ] || [ -s /tmp/weekly-delta.txt ]); then echo "Committing diff to snapshots repo" - cp /tmp/diff-current.txt snapshots/diffs/$TODAY.txt + cp /tmp/diff-current.md snapshots/diffs/$TODAY.md mkdir -p snapshots/deltas if [ -s /tmp/weekly-delta.txt ]; then # Save processed delta: strip > / < markers and line-number markers, @@ -115,20 +115,20 @@ jobs: echo "=== API CHANGES RELEASED SINCE LAST WEEK (were in last week's diff, now gone) ===" echo "$RELEASED" fi - } > snapshots/deltas/$TODAY.txt + } > snapshots/deltas/$TODAY.md fi cd snapshots git config user.email "github-actions@github.com" git config user.name "GitHub Actions" - git add diffs/$TODAY.txt - [ -f deltas/$TODAY.txt ] && git add deltas/$TODAY.txt + git add diffs/$TODAY.md + [ -f deltas/$TODAY.md ] && git add deltas/$TODAY.md echo "$CURRENT_PUBLISH" > last-publish-hash.txt git add last-publish-hash.txt echo "=== Staged changes ===" git diff --cached --stat git diff --cached --quiet || (git commit -m "weekly api diff $TODAY" && git push) else - echo "Skipping commit — diff-current empty=$([ ! -s /tmp/diff-current.txt ] && echo yes || echo no), new_release=$NEW_RELEASE, delta_empty=$([ ! -s /tmp/weekly-delta.txt ] && echo yes || echo no)" + echo "Skipping commit — diff-current empty=$([ ! -s /tmp/diff-current.md ] && echo yes || echo no), new_release=$NEW_RELEASE, delta_empty=$([ ! -s /tmp/weekly-delta.txt ] && echo yes || echo no)" fi # Summarize with GitHub Models (free via GITHUB_TOKEN) and post to Slack @@ -136,6 +136,7 @@ jobs: env: SLACK_TSDIFF_CHROMATIC_BOT_TOKEN: ${{ secrets.SLACK_TSDIFF_CHROMATIC_BOT_TOKEN }} SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }} + TEST_SLACK_ID: ${{ secrets.TEST_SLACK_ID }} GITHUB_TOKEN: ${{ github.token }} run: | python3 << 'PYEOF' @@ -152,15 +153,15 @@ jobs: slack_token = os.environ['SLACK_TSDIFF_CHROMATIC_BOT_TOKEN'] github_token = os.environ['GITHUB_TOKEN'] workspace = os.environ['GITHUB_WORKSPACE'] - diff_url = f"https://github.com/{snapshots_repo}/blob/main/diffs/{today}.txt" - delta_url = f"https://github.com/{snapshots_repo}/blob/main/deltas/{today}.txt" + diff_url = f"https://github.com/{snapshots_repo}/blob/main/diffs/{today}.md" + delta_url = f"https://github.com/{snapshots_repo}/blob/main/deltas/{today}.md" - vs_release_size = os.path.getsize('/tmp/diff-current.txt') + vs_release_size = os.path.getsize('/tmp/diff-current.md') vs_last_week_size = os.path.getsize('/tmp/weekly-delta.txt') if os.path.exists('/tmp/weekly-delta.txt') else 0 - prev_files = sorted(glob.glob(f"{workspace}/snapshots/diffs/*.txt"), reverse=True) - prev_date = os.path.basename(prev_files[0]).replace('.txt', '') if prev_files else None - prev_url = f"https://github.com/{snapshots_repo}/blob/main/diffs/{prev_date}.txt" if prev_date else None + prev_files = sorted(glob.glob(f"{workspace}/snapshots/diffs/*.md"), reverse=True) + prev_date = os.path.basename(prev_files[0]).replace('.md', '') if prev_files else None + prev_url = f"https://github.com/{snapshots_repo}/blob/main/diffs/{prev_date}.md" if prev_date else None new_release = os.environ.get('NEW_RELEASE') == 'true' @@ -191,7 +192,7 @@ jobs: body = f"New release since last diff — resetting baseline. Full diff vs release: {diff_url}\n\nReact ✅ if changes look expected, or 🚨 if something looks wrong." else: # Read the already-processed delta saved by the shell step - delta_path = f"{workspace}/snapshots/deltas/{today}.txt" + delta_path = f"{workspace}/snapshots/deltas/{today}.md" model_input_full = open(delta_path).read() if os.path.exists(delta_path) else "" TRUNCATE_LIMIT = 8000 truncated = len(model_input_full) > TRUNCATE_LIMIT diff --git a/scripts/buildBranchAPI.js b/scripts/buildBranchAPI.js index b663c368cd3..954d338db58 100644 --- a/scripts/buildBranchAPI.js +++ b/scripts/buildBranchAPI.js @@ -163,6 +163,23 @@ async function build() { recursive: true }); + // Collect workspace package names so we can strip intra-monorepo dependencies. + // Sibling packages may pin exact versions (e.g. "@adobe/react-spectrum": "3.47.0") + // that don't match the workspace version being built, causing yarn to install from + // npm instead of symlinking to the workspace. Removing these entries lets yarn always + // resolve them via the workspace. + let workspacePackageNames = new Set( + packages + .map(p => { + try { + return JSON.parse(fs.readFileSync(path.join(srcDir, 'packages', p), 'utf8')).name; + } catch { + return null; + } + }) + .filter(Boolean) + ); + let excludeList = ['@react-spectrum/story-utils']; // Copy packages over to temp dir console.log('copying over'); @@ -186,6 +203,13 @@ async function build() { delete json.main; delete json.module; delete json.devDependencies; + if (json.dependencies) { + for (let dep of Object.keys(json.dependencies)) { + if (workspacePackageNames.has(dep)) { + delete json.dependencies[dep]; + } + } + } json.apiCheck = 'dist/api.json'; json.targets = { apiCheck: {}