Skip to content

Commit a27560d

Browse files
committed
error messaging and simplification
1 parent b16d1e4 commit a27560d

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

.github/workflows/weekly-api-diff.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616
with:
17-
fetch-depth: 0 # required for --auto-baseline to find the last Publish commit
17+
fetch-depth: 0 # required for build:api-published to find the last Publish commit
1818

1919
- uses: actions/setup-node@v4
2020
with:
@@ -31,13 +31,8 @@ jobs:
3131
- name: Build release baseline
3232
run: yarn build:api-published
3333

34-
# Generate diff — compareAPIs.js requires absolute paths
3534
- name: Generate diff
36-
run: |
37-
yarn compare:apis \
38-
--branch-api-dir=$GITHUB_WORKSPACE/dist/branch-api \
39-
--base-api-dir=$GITHUB_WORKSPACE/dist/base-api \
40-
--isCI > /tmp/diff-current.txt 2>&1 || true
35+
run: yarn compare:apis --isCI > /tmp/diff-current.txt 2>&1 || true
4136

4237
# Check out snapshots repo so we can read the previous diff and commit the new one
4338
- uses: actions/checkout@v4
@@ -78,6 +73,11 @@ jobs:
7873
python3 << 'PYEOF'
7974
import json, os, urllib.request, subprocess
8075
76+
required = ['SLACK_TSDIFF_CHROMATIC_BOT_TOKEN', 'SLACK_CHANNEL_ID', 'GITHUB_TOKEN', 'TODAY', 'SNAPSHOTS_REPO', 'GITHUB_WORKSPACE']
77+
missing = [k for k in required if not os.environ.get(k)]
78+
if missing:
79+
raise SystemExit(f"Missing required environment variables: {', '.join(missing)}")
80+
8181
today = os.environ['TODAY']
8282
channel = os.environ['SLACK_CHANNEL_ID']
8383
snapshots_repo = os.environ['SNAPSHOTS_REPO']
@@ -129,4 +129,6 @@ jobs:
129129
)
130130
resp = json.loads(urllib.request.urlopen(req).read())
131131
print("Slack response:", resp.get('ok'), resp.get('error', ''))
132+
if not resp.get('ok'):
133+
raise SystemExit(f"Slack error: {resp.get('error')}")
132134
PYEOF

.github/workflows/weekly-chromatic.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ jobs:
7474
import json, os, urllib.request
7575
from datetime import date
7676
77+
required = ['SLACK_TSDIFF_CHROMATIC_BOT_TOKEN', 'SLACK_CHANNEL_ID']
78+
missing = [k for k in required if not os.environ.get(k)]
79+
if missing:
80+
raise SystemExit(f"Missing required environment variables: {', '.join(missing)}")
81+
7782
today = date.today().isoformat()
7883
channel = os.environ['SLACK_CHANNEL_ID']
7984
slack_token = os.environ['SLACK_TSDIFF_CHROMATIC_BOT_TOKEN']

scripts/weekly-api-diff/prompt.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ This also takes 10-30 minutes.
5656

5757
```bash
5858
cd $HOME/dev/react-spectrum
59-
yarn compare:apis \
60-
--branch-api-dir=$HOME/dev/react-spectrum/dist/branch-api \
61-
--base-api-dir=$HOME/dev/react-spectrum/dist/base-api \
62-
--isCI 2>&1 | tee $HOME/dev/react-spectrum-api-snapshots/diffs/$TODAY.txt
59+
yarn compare:apis --isCI 2>&1 | tee $HOME/dev/react-spectrum-api-snapshots/diffs/$TODAY.txt
6360
```
6461

6562
Check if the output file is empty:
@@ -86,6 +83,8 @@ ls -t $HOME/dev/react-spectrum-api-snapshots/diffs/*.txt 2>/dev/null | sed -n '2
8683

8784
```bash
8885
cd $HOME/dev/react-spectrum-api-snapshots
86+
git checkout main
87+
git pull origin main
8988
git add diffs/$TODAY.txt
9089
git commit -m "weekly api diff $TODAY"
9190
git push

0 commit comments

Comments
 (0)