forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 💫
1# Credit for fingerprint action https://github.com/expo/expo
2# https://github.com/expo/expo/blob/main/.github/workflows/pr-labeler.yml
3---
4name: PR Tests
5
6on:
7 push:
8 branches: [main]
9 pull_request:
10 types: [opened, synchronize]
11
12concurrency:
13 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
14 cancel-in-progress: true
15
16permissions:
17 pull-requests: write
18 actions: write
19 contents: read
20
21jobs:
22 webpack-analyzer:
23 runs-on: ubuntu-22.04
24 if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request'}}
25 steps:
26 - name: ⬇️ Checkout
27 uses: actions/checkout@v4
28 with:
29 fetch-depth: 0
30
31 - name: 🔧 Setup Node
32 uses: actions/setup-node@v6
33 with:
34 node-version-file: .nvmrc
35 cache: yarn
36
37 - name: Ensure tracking relevant branches and checkout base
38 env:
39 HEAD_REF: ${{ github.head_ref }}
40 BASE_REF: ${{ github.base_ref }}
41 run: |
42 git checkout $HEAD_REF
43 git checkout $BASE_REF
44
45 - name: Get the base commit
46 id: base-commit
47 env:
48 BASE_REF: ${{ github.base_ref }}
49 run: echo base-commit=$(git log -n 1 $BASE_REF --pretty=format:'%H') >> "$GITHUB_OUTPUT"
50
51 - name: Merge PR commit
52 env:
53 HEAD_REF: ${{ github.head_ref }}
54 run: |
55 # Have to set a git config for the merge to work
56 git config --global user.email "github-actions[bot]@users.noreply.github.com"
57 git config --global user.name "github-actions[bot]"
58 git merge --no-edit $HEAD_REF
59 yarn install
60 yarn intl:build
61
62 - name: 🔦 Generate stats file for PR
63 run: |
64 yarn generate-webpack-stats-file
65 mv stats.json ../stats-new.json
66
67 - name: ⬇️ Get base stats from cache
68 id: get-base-stats
69 uses: actions/cache@v4
70 with:
71 path: stats-base.json
72 key: stats-base-${{ steps.base-commit.outputs.base-commit }}
73
74 - name: Restore to base commit
75 if: ${{ !steps.get-base-stats.outputs.cache-hit }}
76 run: |
77 git reset HEAD~
78 git restore .
79
80 - name: 🔦 Generate stats file from base commit
81 if: ${{ !steps.get-base-stats.outputs.cache-hit }}
82 run: |
83 yarn install
84 yarn intl:build
85 yarn generate-webpack-stats-file
86 mv stats.json stats-base.json
87
88 - name: % Get diff
89 id: get-diff
90 uses: NejcZdovc/bundle-size-diff@v1
91 with:
92 base_path: "stats-base.json"
93 pr_path: "../stats-new.json"
94 excluded_assets: "(.+).chunk.js|(.+).js.map|(.+).json|(.+).png"
95
96 - name: 💬 Drop a comment
97 uses: marocchino/sticky-pull-request-comment@v2
98 with:
99 header: bundle-diff
100 message: |
101 | Old size | New size | Diff |
102 |----------|----------|-----------------------|
103 | ${{ steps.get-diff.outputs.base_file_string }} | ${{ steps.get-diff.outputs.pr_file_string }} | ${{ steps.get-diff.outputs.diff_file_string }} (${{ steps.get-diff.outputs.percent }}%) |
104 ---
105
106 fingerprint-native:
107 runs-on: ubuntu-22.04
108 if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request'}}
109 steps:
110 - name: ⬇️ Checkout
111 uses: actions/checkout@v4
112 with:
113 fetch-depth: 100
114
115 - name: ⬇️ Fetch commits from base branch
116 run: git fetch origin main:main --depth 100
117 if: github.event_name == 'pull_request'
118
119 - name: 🔧 Setup Node
120 uses: actions/setup-node@v6
121 with:
122 node-version-file: .nvmrc
123 cache: yarn
124
125 - name: 📷 Check fingerprint and install dependencies
126 id: fingerprint
127 uses: bluesky-social/github-actions/fingerprint-native@main
128 with:
129 profile: pull-request
130
131 - name: 💬 Drop a comment
132 uses: marocchino/sticky-pull-request-comment@v2
133 if: ${{ steps.fingerprint.outputs.includes-changes }}
134 with:
135 header: fingerprint-diff
136 message: |
137 The Pull Request introduced fingerprint changes against the base commit:
138 <details><summary>Fingerprint diff</summary>
139
140 ```json
141 ${{ steps.fingerprint.outputs.diff }}
142 ```
143
144 </details>
145
146 ---
147 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*
148
149 - name: 💬 Delete comment
150 uses: marocchino/sticky-pull-request-comment@v2
151 if: ${{ !steps.fingerprint.outputs.includes-changes }}
152 with:
153 header: fingerprint-diff
154 delete: true