Skip to content

Commit 52aec5a

Browse files
committed
Change workflow to just check for file updates, rather than identical files
1 parent 1cd40bb commit 52aec5a

File tree

1 file changed

+50
-32
lines changed

1 file changed

+50
-32
lines changed

.github/workflows/check_precompiled.yml

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: Check Precompiled Binaries
22

33
on:
4-
push:
54
pull_request:
5+
paths:
6+
- 'enc_bootloader/**'
7+
- 'picoboot_flash_id/**'
8+
- 'xip_ram_perms/**'
69

710
jobs:
811
check-precompiled:
9-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
1012
runs-on: ubuntu-latest
1113
steps:
1214
- name: Checkout
@@ -23,49 +25,65 @@ jobs:
2325
path: pico-sdk
2426
submodules: 'true'
2527

26-
- name: Create copies of the precompiled binaries
27-
run: |
28-
cp enc_bootloader/enc_bootloader.elf enc_bootloader/enc_bootloader.elf.orig
29-
cp enc_bootloader/enc_bootloader_mbedtls.elf enc_bootloader/enc_bootloader_mbedtls.elf.orig
30-
cp picoboot_flash_id/flash_id.bin picoboot_flash_id/flash_id.bin.orig
31-
cp xip_ram_perms/xip_ram_perms.elf xip_ram_perms/xip_ram_perms.elf.orig
32-
3328
- name: Build and Install
3429
run: |
3530
cmake -S . -B build -G "Ninja" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" -D USE_PRECOMPILED=FALSE
3631
cmake --build build
3732
sudo cmake --install build
3833
39-
- name: Check if precompiled binaries are up to date
40-
env:
41-
ALL_FINE: 1
34+
- name: Check precompiled binaries have been updated
4235
run: |
43-
# Compare the files
44-
if ! cmp -s enc_bootloader/enc_bootloader.elf enc_bootloader/enc_bootloader.elf.orig; then
45-
echo "Error: enc_bootloader.elf is out of date"
46-
ALL_FINE=0
47-
fi
36+
updated_files=$(curl -s -u "${{ github.repository_owner }}":"${{ github.token }}" -H "Accept: application/vnd.github.v3+json" "${{ github.event.pull_request._links.self.href }}/files")
37+
updated_files=$(jq -r '.[] | .filename' <<<"$updated_files")
4838
49-
if ! cmp -s enc_bootloader/enc_bootloader_mbedtls.elf enc_bootloader/enc_bootloader_mbedtls.elf.orig; then
50-
echo "Error: enc_bootloader_mbedtls.elf is out of date"
51-
ALL_FINE=0
52-
fi
39+
echo "Updated files: $updated_files"
5340
54-
if ! cmp -s picoboot_flash_id/flash_id.bin picoboot_flash_id/flash_id.bin.orig; then
55-
echo "Error: flash_id.bin is out of date"
56-
ALL_FINE=0
41+
# enc_bootloader
42+
echo "$updated_files" | grep -q "enc_bootloader/.*\.elf"
43+
enc_bootloader_elf_not_updated=$?
44+
if [ $enc_bootloader_elf_not_updated -eq 1 ]; then
45+
echo "Checking enc_bootloader files for modifications as ELFs have not been updated"
46+
for file in enc_bootloader/*; do
47+
if echo "$file" | grep -q "CMakeLists.txt" || echo "$file" | grep -q "BUILD.bazel"; then
48+
continue
49+
fi
50+
if echo "$updated_files" | grep -q "$file"; then
51+
echo "File $file is in the PR but enc_bootloader ELFs have not been updated"
52+
exit 1
53+
fi
54+
done
5755
fi
5856
59-
if ! cmp -s xip_ram_perms/xip_ram_perms.elf xip_ram_perms/xip_ram_perms.elf.orig; then
60-
echo "Error: xip_ram_perms.elf is out of date"
61-
ALL_FINE=0
57+
# picoboot_flash_id
58+
echo "$updated_files" | grep -q "picoboot_flash_id/.*\.bin"
59+
flash_id_bin_not_updated=$?
60+
if [ $flash_id_bin_not_updated -eq 1 ]; then
61+
echo "Checking picoboot_flash_id files for modifications as BINs have not been updated"
62+
for file in picoboot_flash_id/*; do
63+
if echo "$file" | grep -q "CMakeLists.txt" || echo "$file" | grep -q "BUILD.bazel"; then
64+
continue
65+
fi
66+
if echo "$updated_files" | grep -q "$file"; then
67+
echo "File $file is in the PR but flash_id BINs have not been updated"
68+
exit 1
69+
fi
70+
done
6271
fi
6372
64-
if [ "$ALL_FINE" -eq 1 ]; then
65-
echo "All precompiled binaries are up to date"
66-
else
67-
echo "Some precompiled binaries are out of date - update by building with USE_PRECOMPILED=FALSE, or use the artifact from this workflow"
68-
exit 1
73+
# xip_ram_perms
74+
echo "$updated_files" | grep -q "xip_ram_perms/.*\.elf"
75+
xip_ram_perms_elf_not_updated=$?
76+
if [ $xip_ram_perms_elf_not_updated -eq 1 ]; then
77+
echo "Checking xip_ram_perms files for modifications as ELFs have not been updated"
78+
for file in xip_ram_perms/*; do
79+
if echo "$file" | grep -q "CMakeLists.txt" || echo "$file" | grep -q "BUILD.bazel"; then
80+
continue
81+
fi
82+
if echo "$updated_files" | grep -q "$file"; then
83+
echo "File $file is in the PR but xip_ram_perms ELFs have not been updated"
84+
exit 1
85+
fi
86+
done
6987
fi
7088
7189
- name: Upload new precompiled binaries

0 commit comments

Comments
 (0)