Skip to content

Commit 6eb74d2

Browse files
authored
fix: external contributors CI (#653)
## 📜 Description Fix `size-diff` and `deploy-preview`. ## 💡 Motivation and Context I hate to see failing PRs (especially when it's a false positive). ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### CI - split size-diff into two actions (with artifacts sharing); - don't run deploy preview for forks; ## 🤔 How Has This Been Tested? Can be tested only after PR merge. ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 1ba0685 commit 6eb74d2

File tree

3 files changed

+76
-16
lines changed

3 files changed

+76
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🧪 Size diff
1+
name: 🧪 Size calculation
22

33
on:
44
pull_request:
@@ -7,34 +7,43 @@ on:
77
- "FabricExample/**"
88
- "docs/**"
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
11-
check-diff:
12-
name: 🔬 Find npm package size diff
14+
calculate-sizes:
15+
name: 🔬 Calculate package sizes
1316
runs-on: ubuntu-latest
14-
permissions:
15-
pull-requests: write
1617
steps:
1718
- name: Checkout to target branch
1819
uses: actions/checkout@v4
1920
with:
2021
ref: ${{ github.event.pull_request.base.ref }}
22+
2123
- uses: actions/setup-node@v4
2224
with:
2325
node-version: 18.19.0
2426
cache: yarn
27+
2528
- name: Install dependencies
2629
run: yarn install --frozen-lockfile
30+
2731
- name: Calculate size of package (target)
2832
id: old-size
2933
run: echo "OLD_SIZE=$(node scripts/size.js)" >> "$GITHUB_OUTPUT"
34+
3035
- uses: actions/checkout@v4
36+
3137
- name: Install dependencies
3238
run: yarn install --frozen-lockfile
39+
3340
- name: Pack
3441
run: npm pack --json
42+
3543
- name: Calculate size of package (current)
3644
id: new-size
3745
run: echo "NEW_SIZE=$(node scripts/size.js)" >> "$GITHUB_OUTPUT"
46+
3847
- name: Calculate difference
3948
id: diff
4049
env:
@@ -43,15 +52,23 @@ jobs:
4352
run: |
4453
echo "DIFF=$((NEW_SIZE - OLD_SIZE))" >> "$GITHUB_OUTPUT"
4554
echo "SIGN=$([ $((NEW_SIZE - OLD_SIZE)) -gt 0 ] && echo "📈" || echo "📉")" >> "$GITHUB_OUTPUT"
46-
- uses: marocchino/sticky-pull-request-comment@v2
47-
env:
48-
NEW_SIZE: ${{ steps.new-size.outputs.NEW_SIZE }}
49-
OLD_SIZE: ${{ steps.old-size.outputs.OLD_SIZE }}
50-
DIFF: ${{ steps.diff.outputs.DIFF }}
51-
SIGN: ${{ steps.diff.outputs.SIGN }}
55+
56+
- name: Create size data files
57+
run: |
58+
echo "${{ steps.new-size.outputs.NEW_SIZE }}" > new-size.txt
59+
echo "${{ steps.old-size.outputs.OLD_SIZE }}" > old-size.txt
60+
echo "${{ steps.diff.outputs.DIFF }}" > diff.txt
61+
echo "${{ steps.diff.outputs.SIGN }}" > sign.txt
62+
echo "${{ github.event.pull_request.number }}" > pr-number.txt
63+
64+
- name: Upload size data
65+
uses: actions/upload-artifact@v4
5266
with:
53-
message: |
54-
### 📊 Package size report
55-
| Current size | Target Size | Difference |
56-
| ------------- | ------------- | ------------------------ |
57-
| ${{ env.NEW_SIZE }} bytes | ${{ env.OLD_SIZE }} bytes | ${{ env.DIFF }} bytes ${{ env.SIGN }} |
67+
name: size-data
68+
path: |
69+
new-size.txt
70+
old-size.txt
71+
diff.txt
72+
sign.txt
73+
pr-number.txt
74+
retention-days: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 📝 Create size diff comment
2+
3+
on:
4+
workflow_run:
5+
workflows: ["🧪 Size calculation"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
pull-requests: write
11+
actions: read
12+
13+
jobs:
14+
comment:
15+
name: 💬 Post size diff comment
16+
runs-on: ubuntu-latest
17+
if: github.event.workflow_run.conclusion == 'success'
18+
steps:
19+
- name: Download size data
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: size-data
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
run-id: ${{ github.event.workflow_run.id }}
25+
26+
- name: Read size data
27+
id: size-data
28+
run: |
29+
echo "NEW_SIZE=$(cat new-size.txt)" >> "$GITHUB_OUTPUT"
30+
echo "OLD_SIZE=$(cat old-size.txt)" >> "$GITHUB_OUTPUT"
31+
echo "DIFF=$(cat diff.txt)" >> "$GITHUB_OUTPUT"
32+
echo "SIGN=$(cat sign.txt)" >> "$GITHUB_OUTPUT"
33+
echo "PR_NUMBER=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT"
34+
35+
- uses: marocchino/sticky-pull-request-comment@v2
36+
with:
37+
number: ${{ steps.size-data.outputs.PR_NUMBER }}
38+
message: |
39+
### 📊 Package size report
40+
| Current size | Target Size | Difference |
41+
| ------------- | ------------- | ------------------------ |
42+
| ${{ steps.size-data.outputs.NEW_SIZE }} bytes | ${{ steps.size-data.outputs.OLD_SIZE }} bytes | ${{ steps.size-data.outputs.DIFF }} bytes ${{ steps.size-data.outputs.SIGN }} |

.github/workflows/verify-docs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
preview:
5050
runs-on: ubuntu-latest
5151
name: 🛫 Deploy preview
52+
if: ${{ !github.event.pull_request.head.repo.fork }}
5253
defaults:
5354
run:
5455
working-directory: docs

0 commit comments

Comments
 (0)