1
1
name : Check Precompiled Binaries
2
2
3
3
on :
4
- push :
5
4
pull_request :
5
+ paths :
6
+ - ' enc_bootloader/**'
7
+ - ' picoboot_flash_id/**'
8
+ - ' xip_ram_perms/**'
6
9
7
10
jobs :
8
11
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
10
12
runs-on : ubuntu-latest
11
13
steps :
12
14
- name : Checkout
@@ -23,49 +25,65 @@ jobs:
23
25
path : pico-sdk
24
26
submodules : ' true'
25
27
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
-
33
28
- name : Build and Install
34
29
run : |
35
30
cmake -S . -B build -G "Ninja" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" -D USE_PRECOMPILED=FALSE
36
31
cmake --build build
37
32
sudo cmake --install build
38
33
39
- - name : Check if precompiled binaries are up to date
40
- env :
41
- ALL_FINE : 1
34
+ - name : Check precompiled binaries have been updated
42
35
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")
48
38
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"
53
40
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
57
55
fi
58
56
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
62
71
fi
63
72
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
69
87
fi
70
88
71
89
- name : Upload new precompiled binaries
0 commit comments