|
| 1 | +name: Check Prebuild Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'scripts/prebuild/**' |
| 7 | + - 'scripts/utils/**' |
| 8 | + - 'scripts/algolia/**' |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + check-prebuild-binaries: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + name: Validate prebuild binaries are updated |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 |
| 21 | + |
| 22 | + - name: Get changed files |
| 23 | + id: changed-files |
| 24 | + uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8 # v45.0.7 |
| 25 | + with: |
| 26 | + files: | |
| 27 | + scripts/prebuild/** |
| 28 | + scripts/utils/** |
| 29 | + scripts/algolia/** |
| 30 | + files_ignore: | |
| 31 | + scripts/prebuild/prebuild-arm-mac-binary.gz |
| 32 | + scripts/prebuild/prebuild-x64-linux-binary.gz |
| 33 | + scripts/prebuild/prebuild-arm-linux-binary.gz |
| 34 | +
|
| 35 | + - name: Check if prebuild scripts changed |
| 36 | + id: check-changes |
| 37 | + run: | |
| 38 | + echo "Changed files: ${{ steps.changed-files.outputs.all_changed_files }}" |
| 39 | + if [[ "${{ steps.changed-files.outputs.any_changed }}" == "true" ]]; then |
| 40 | + echo "prebuild_changed=true" >> $GITHUB_OUTPUT |
| 41 | + echo "✅ Prebuild scripts have changed" |
| 42 | + else |
| 43 | + echo "prebuild_changed=false" >> $GITHUB_OUTPUT |
| 44 | + echo "ℹ️ No prebuild script changes detected" |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Check if binaries were updated |
| 48 | + id: check-binaries |
| 49 | + if: steps.check-changes.outputs.prebuild_changed == 'true' |
| 50 | + uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8 # v45.0.7 |
| 51 | + with: |
| 52 | + files: | |
| 53 | + scripts/prebuild/prebuild-arm-mac-binary.gz |
| 54 | + scripts/prebuild/prebuild-x64-linux-binary.gz |
| 55 | + scripts/prebuild/prebuild-arm-linux-binary.gz |
| 56 | +
|
| 57 | + - name: Validate binary updates |
| 58 | + if: steps.check-changes.outputs.prebuild_changed == 'true' |
| 59 | + run: | |
| 60 | + echo "Prebuild scripts changed: ${{ steps.check-changes.outputs.prebuild_changed }}" |
| 61 | + echo "Binaries changed: ${{ steps.check-binaries.outputs.any_changed }}" |
| 62 | + echo "Changed binaries: ${{ steps.check-binaries.outputs.all_changed_files }}" |
| 63 | +
|
| 64 | + if [[ "${{ steps.check-binaries.outputs.any_changed }}" != "true" ]]; then |
| 65 | + echo "❌ ERROR: Prebuild scripts have been modified but the required gzipped binaries have not been updated!" |
| 66 | + echo "" |
| 67 | + echo "The following files were changed in scripts/prebuild/:" |
| 68 | + echo "${{ steps.changed-files.outputs.all_changed_files }}" |
| 69 | + echo "" |
| 70 | + echo "Please ensure you have updated the following gzipped binaries:" |
| 71 | + echo "- scripts/prebuild/prebuild-arm-mac-binary.gz" |
| 72 | + echo "- scripts/prebuild/prebuild-x64-linux-binary.gz" |
| 73 | + echo "- scripts/prebuild/prebuild-arm-linux-binary.gz" |
| 74 | + echo "" |
| 75 | + echo "ℹ️ You can rebuild them with 'npm run compile-prebuild' and then commit the changes." |
| 76 | + exit 1 |
| 77 | +
|
| 78 | + else |
| 79 | + # Check if all binaries were updated |
| 80 | + ARM_MAC_UPDATED=false |
| 81 | + X64_LINUX_UPDATED=false |
| 82 | + ARM_LINUX_UPDATED=false |
| 83 | +
|
| 84 | + if echo "${{ steps.check-binaries.outputs.all_changed_files }}" | grep -q "prebuild-arm-mac-binary.gz"; then |
| 85 | + ARM_MAC_UPDATED=true |
| 86 | + echo "✅ ARM Mac binary updated" |
| 87 | + fi |
| 88 | +
|
| 89 | + if echo "${{ steps.check-binaries.outputs.all_changed_files }}" | grep -q "prebuild-x64-linux-binary.gz"; then |
| 90 | + X64_LINUX_UPDATED=true |
| 91 | + echo "✅ x64 Linux binary updated" |
| 92 | + fi |
| 93 | +
|
| 94 | + if echo "${{ steps.check-binaries.outputs.all_changed_files }}" | grep -q "prebuild-arm-linux-binary.gz"; then |
| 95 | + ARM_LINUX_UPDATED=true |
| 96 | + echo "✅ ARM Linux binary updated" |
| 97 | + fi |
| 98 | +
|
| 99 | + if [[ "$ARM_MAC_UPDATED" != "true" || "$X64_LINUX_UPDATED" != "true" || "$ARM_LINUX_UPDATED" != "true" ]]; then |
| 100 | + echo "⚠️ WARNING: Not all required binaries were updated:" |
| 101 | + [[ "$ARM_MAC_UPDATED" != "true" ]] && echo " - Missing: scripts/prebuild/prebuild-arm-mac-binary.gz" |
| 102 | + [[ "$X64_LINUX_UPDATED" != "true" ]] && echo " - Missing: scripts/prebuild/prebuild-x64-linux-binary.gz" |
| 103 | + [[ "$ARM_LINUX_UPDATED" != "true" ]] && echo " - Missing: scripts/prebuild/prebuild-arm-linux-binary.gz" |
| 104 | + echo "" |
| 105 | + echo "ℹ️ You can rebuild them with 'npm run compile-prebuild' and then commit the changes." |
| 106 | + exit 1 |
| 107 | + fi |
| 108 | + fi |
| 109 | +
|
| 110 | + - name: No changes detected |
| 111 | + if: steps.check-changes.outputs.prebuild_changed == 'false' |
| 112 | + run: | |
| 113 | + echo "✅ No prebuild script changes detected. No binary validation required." |
0 commit comments