Skip to content

Commit 1465edf

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

File tree

1 file changed

+52
-34
lines changed

1 file changed

+52
-34
lines changed

.github/workflows/check_precompiled.yml

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
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:
@@ -23,50 +26,65 @@ jobs:
2326
path: pico-sdk
2427
submodules: 'true'
2528

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-
3329
- name: Build and Install
3430
run: |
3531
cmake -S . -B build -G "Ninja" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" -D USE_PRECOMPILED=FALSE
3632
cmake --build build
3733
sudo cmake --install build
3834
39-
- name: Check if precompiled binaries are up to date
40-
env:
41-
ALL_FINE: 1
35+
- name: Check precompiled binaries have been updated
4236
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
37+
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")
38+
updated_files=$(jq -r '.[] | .filename' <<<"$updated_files")
4839
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
40+
echo "Updated files: $updated_files"
5341
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
57-
fi
42+
# enc_bootloader
43+
enc_bootloader_elf_not_updated=$(! echo "$updated_files" | grep -q "enc_bootloader/enc_bootloader.elf")
44+
enc_bootloader_mbedtls_elf_not_updated=$(! echo "$updated_files" | grep -q "enc_bootloader/enc_bootloader_mbedtls.elf")
45+
echo "enc_bootloader_elf_not_updated: $enc_bootloader_elf_not_updated"
46+
echo "enc_bootloader_mbedtls_elf_not_updated: $enc_bootloader_mbedtls_elf_not_updated"
47+
for file in enc_bootloader/*; do
48+
if echo "$updated_files" | grep -q "$file"; then
49+
echo "File $file is in the PR"
50+
if $enc_bootloader_elf_not_updated || $enc_bootloader_mbedtls_elf_not_updated; then
51+
echo "File $file is in the PR but not enc_bootloader/enc_bootloader.elf"
52+
exit 1
53+
fi
54+
else
55+
echo "File $file is not in the PR"
56+
fi
57+
done
5858
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
62-
fi
59+
# picoboot_flash_id
60+
flash_id_bin_not_updated=$(! echo "$updated_files" | grep -q "picoboot_flash_id/flash_id.bin")
61+
echo "flash_id_bin_not_updated: $flash_id_bin_not_updated"
62+
for file in picoboot_flash_id/*; do
63+
if echo "$updated_files" | grep -q "$file"; then
64+
echo "File $file is in the PR"
65+
if $flash_id_bin_not_updated; then
66+
echo "File $file is in the PR but not picoboot_flash_id/flash_id.bin"
67+
exit 1
68+
fi
69+
else
70+
echo "File $file is not in the PR"
71+
fi
72+
done
6373
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
69-
fi
74+
# xip_ram_perms
75+
xip_ram_perms_elf_not_updated=$(! echo "$updated_files" | grep -q "xip_ram_perms/xip_ram_perms.elf")
76+
echo "xip_ram_perms_elf_not_updated: $xip_ram_perms_elf_not_updated"
77+
for file in xip_ram_perms/*; do
78+
if echo "$updated_files" | grep -q "$file"; then
79+
echo "File $file is in the PR"
80+
if $xip_ram_perms_elf_not_updated; then
81+
echo "File $file is in the PR but not xip_ram_perms/xip_ram_perms.elf"
82+
exit 1
83+
fi
84+
else
85+
echo "File $file is not in the PR"
86+
fi
87+
done
7088
7189
- name: Upload new precompiled binaries
7290
if: always()

0 commit comments

Comments
 (0)