mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
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 labeler 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 }} 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@v4 33 with: 34 node-version-file: .nvmrc 35 cache: yarn 36 37 - name: Ensure tracking relevant branches and checkout base 38 run: | 39 git checkout ${{ github.head_ref }} 40 git checkout ${{ github.base_ref }} 41 42 - name: Get the base commit 43 id: base-commit 44 run: echo base-commit=$(git log -n 1 ${{ github.base_ref }} --pretty=format:'%H') >> "$GITHUB_OUTPUT" 45 46 - name: Merge PR commit 47 run: | 48 # Have to set a git config for the merge to work 49 git config --global user.email "github-actions[bot]@users.noreply.github.com" 50 git config --global user.name "github-actions[bot]" 51 git merge --no-edit ${{ github.head_ref }} 52 yarn install 53 54 - name: 🔦 Generate stats file for PR 55 run: | 56 yarn generate-webpack-stats-file 57 mv stats.json ../stats-new.json 58 59 - name: ⬇️ Get base stats from cache 60 id: get-base-stats 61 uses: actions/cache@v4 62 with: 63 path: stats-base.json 64 key: stats-base-${{ steps.base-commit.outputs.base-commit }} 65 66 - name: Restore to base commit 67 if: ${{ !steps.get-base-stats.outputs.cache-hit }} 68 run: | 69 git reset HEAD~ 70 git restore . 71 72 - name: 🔦 Generate stats file from base commit 73 if: ${{ !steps.get-base-stats.outputs.cache-hit }} 74 run: | 75 yarn install 76 yarn generate-webpack-stats-file 77 mv stats.json stats-base.json 78 79 - name: % Get diff 80 id: get-diff 81 uses: NejcZdovc/bundle-size-diff@v1 82 with: 83 base_path: 'stats-base.json' 84 pr_path: '../stats-new.json' 85 excluded_assets: '(.+).chunk.js|(.+).js.map|(.+).json|(.+).png' 86 87 - name: 💬 Drop a comment 88 uses: marocchino/sticky-pull-request-comment@v2 89 with: 90 header: bundle-diff 91 message: | 92 | Old size | New size | Diff | 93 |----------|----------|-----------------------| 94 | ${{ 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 }}%) | 95 --- 96 97 test-suite-fingerprint: 98 runs-on: ubuntu-22.04 99 if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' }} 100 concurrency: fingerprint-${{ github.event_name != 'pull_request' && 'main' || github.run_id }} 101 steps: 102 - name: ⬇️ Checkout 103 uses: actions/checkout@v4 104 with: 105 fetch-depth: 100 106 107 - name: ⬇️ Fetch commits from base branch 108 run: git fetch origin main:main --depth 100 109 if: github.event_name == 'pull_request' 110 111 - name: 🔧 Setup Node 112 uses: actions/setup-node@v4 113 with: 114 node-version-file: .nvmrc 115 cache: yarn 116 117 - name: ⚙️ Install Dependencies 118 run: yarn install 119 120 - name: Get the base commit 121 id: base-commit 122 run: echo base-commit=$(git log -n 1 main --pretty=format:'%H') >> "$GITHUB_OUTPUT" 123 124 - name: 📷 Check fingerprint 125 id: fingerprint 126 uses: expo/expo-github-action/fingerprint@main 127 with: 128 previous-git-commit: ${{ steps.base-commit.outputs.base-commit }} 129 130 - name: 👀 Debug fingerprint 131 run: | 132 echo "previousGitCommit=${{ steps.fingerprint.outputs.previous-git-commit }} currentGitCommit=${{ steps.fingerprint.outputs.current-git-commit }}" 133 echo "isPreviousFingerprintEmpty=${{ steps.fingerprint.outputs.previous-fingerprint == '' }}" 134 135 - name: 💬 Drop a comment 136 uses: marocchino/sticky-pull-request-comment@v2 137 if: ${{ github.event_name == 'pull_request' && steps.fingerprint.outputs.fingerprint-diff != '[]' }} 138 with: 139 header: fingerprint-diff 140 message: | 141 The Pull Request introduced fingerprint changes against the base commit: ${{ steps.fingerprint.outputs.previous-git-commit }} 142 <details><summary>Fingerprint diff</summary> 143 144 ```json 145 ${{ steps.fingerprint.outputs.fingerprint-diff }} 146 ``` 147 148 </details> 149 150 --- 151 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖* 152 153 - name: 💬 Delete comment 154 uses: marocchino/sticky-pull-request-comment@v2 155 if: ${{ github.event_name == 'pull_request' && steps.fingerprint.outputs.fingerprint-diff == '[]' }} 156 with: 157 header: fingerprint-diff 158 delete: true 159