@@ -12,70 +12,51 @@ jobs:
1212 cache :
1313 name : Update Submodule Cache
1414 runs-on : ubuntu-24.04
15+ outputs :
16+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
17+ env :
18+ cache-path : |
19+ .git/modules
20+ binutils
21+ gdb
22+ gcc
23+ llvm
24+ newlib
25+ glibc
26+ musl
27+ uclib-ng
28+ dejagnu
29+ pk
30+ qemu
31+ spike
1532 steps :
1633 - uses : actions/checkout@v4
1734
18- - name : Cache GCC
19- uses : actions/cache@v4
20- with :
21- path : |
22- .git/modules/gcc
23- gcc
24- key : compiler-gcc
25-
26- - name : Cache LLVM
27- uses : actions/cache@v4
28- with :
29- path : |
30- .git/modules/llvm
31- llvm
32- key : compiler-llvm
33-
34- - name : Cache Newlib
35- uses : actions/cache@v4
36- with :
37- path : |
38- .git/modules/newlib
39- newlib
40- key : mode-newlib
35+ - name : Generate Submodule Hash
36+ id : submodule-hash
37+ run : echo "HASH=$(git submodule | sha1sum | sed 's/.\{3\}$//')" >> $GITHUB_OUTPUT
4138
42- - name : Cache Linux
39+ - name : Check is Cache Exists for Exact Submodule Configuration
40+ id : cache-check
4341 uses : actions/cache@v4
4442 with :
45- path : |
46- .git/modules/glibc
47- glibc
48- key : mode-linux
43+ path : ${{ env.cache-path }}
44+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
45+ lookup-only : true
4946
50- - name : Cache musl
47+ - name : If no Cache Hit, Update Cache
5148 uses : actions/cache@v4
49+ if : steps.cache-check.outputs.cache-hit != 'true'
5250 with :
53- path : |
54- .git/modules/musl
55- musl
56- key : mode-musl
57-
58- - name : Cache uClibc
59- uses : actions/cache@v4
60- with :
61- path : |
62- .git/modules/uclibc-ng
63- uclibc-ng
64- key : mode-uclibc
51+ path : ${{ env.cache-path }}
52+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
53+ restore-keys : |
54+ submodules-
6555
66- - name : Cache Always Required Submodules
67- uses : actions/cache@v4
68- with :
69- path : |
70- .git/modules/binutils
71- .git/modules/gdb
72- binutils
73- gdb
74- key : general-dependencies
75-
76- - name : Clone needed submodules
56+ - name : Clone submodules
57+ if : steps.cache-check.outputs.cache-hit != 'true'
7758 run : |
78- git submodule update --init --progress --depth 1 --jobs $(nproc) binutils gdb gcc llvm newlib glibc musl
59+ git submodule update --init --progress --depth 1 --jobs $(nproc) binutils gdb gcc llvm newlib glibc musl dejagnu pk qemu spike
7960 git submodule update --init --progress uclibc-ng
8061
8162
8465 name : Build Toolchain Variants
8566 runs-on : ${{ matrix.os }}
8667 needs : [cache]
68+ env :
69+ cache-key : ${{ needs.cache.outputs.key }}
8770 strategy :
8871 matrix :
8972 os : [ubuntu-22.04, ubuntu-24.04]
@@ -105,63 +88,44 @@ jobs:
10588 echo "-- After --"
10689 df -h
10790
108- - name : Generate Required Submodules
109- id : required-submodules
91+ - name : Generate Submodules List
92+ id : cache-path
11093 run : |
94+ submodules="gdb:binutils"
11195 case "${{ matrix.mode }}" in
11296 "linux")
113- MODE_SUBMODULE=" glibc";;
97+ submodules="$submodules: glibc";;
11498 "musl")
115- MODE_SUBMODULE=" musl";;
99+ submodules="$submodules: musl";;
116100 "uclibc")
117- MODE_SUBMODULE=" uclibc-ng";;
101+ submodules="$submodules: uclibc-ng";;
118102 "newlib")
119- MODE_SUBMODULE=" newlib";;
103+ submodules="$submodules: newlib";;
120104 *)
121105 echo "Invalid Mode"; exit 1;;
122106 esac
123- echo "MODE_SUBMODULE=$MODE_SUBMODULE" >> $GITHUB_OUTPUT
124107 case "${{ matrix.compiler }}" in
125108 "gcc")
126- COMPILER_SUBMODULE=" gcc";;
109+ submodules="$submodules: gcc";;
127110 "llvm")
128- COMPILER_SUBMODULE=" llvm";;
111+ submodules="$submodules: llvm";;
129112 *)
130113 echo "Invalid Compiler"; exit 1;;
131114 esac
132- echo "COMPILER_SUBMODULE=$COMPILER_SUBMODULE" >> $GITHUB_OUTPUT
115+ submodules=$(echo $submodules | sed 's/:/\n/g')
116+ submodules=$submodules$'\n'$(echo "$submodules" | sed -e 's/^/.git\/modules\//')
117+ echo 'submodules<<EOF' >> $GITHUB_OUTPUT
118+ echo "$submodules" >> $GITHUB_OUTPUT
119+ echo 'EOF' >> $GITHUB_OUTPUT
133120
134121 - uses : actions/checkout@v4
135122
136- - name : Load Compiler Submodule from Cache
123+ - name : Load Cache
137124 uses : actions/cache/restore@v4
138- env :
139- submodule : ${{ steps.required-submodules.outputs.COMPILER_SUBMODULE }}
140125 with :
141126 path : |
142- .git/modules/${{ env.submodule }}
143- ${{ env.submodule }}
144- key : compiler-${{ matrix.compiler }}
145-
146- - name : Load Mode Submodule from Cache
147- uses : actions/cache/restore@v4
148- env :
149- submodule : ${{ steps.required-submodules.outputs.MODE_SUBMODULE }}
150- with :
151- path : |
152- .git/modules/${{ env.submodule }}
153- ${{ env.submodule }}
154- key : mode-${{ matrix.mode }}
155-
156- - name : Load Always Required Submodules from Cache
157- uses : actions/cache/restore@v4
158- with :
159- path : |
160- .git/modules/binutils
161- .git/modules/gdb
162- binutils
163- gdb
164- key : general-dependencies
127+ ${{ steps.cache-path.outputs.submodules }}
128+ key : ${{ env.cache-key }}
165129
166130 - name : Install Dependencies
167131 run : sudo ./.github/setup-apt.sh
@@ -218,6 +182,9 @@ jobs:
218182 test-sim :
219183 name : Test Simulation
220184 runs-on : ${{ matrix.os }}
185+ needs : [cache]
186+ env :
187+ cache-key : ${{ needs.cache.outputs.key }}
221188 strategy :
222189 matrix :
223190 os : [ubuntu-24.04]
@@ -236,6 +203,25 @@ jobs:
236203
237204 - uses : actions/checkout@v4
238205
206+ - uses : actions/cache/restore@v4
207+ with :
208+ path : |
209+ .git/modules/gcc
210+ .git/modules/newlib
211+ .git/modules/binutils
212+ .git/modules/gdb
213+ .git/modules/spike
214+ .git/modules/pk
215+ .git/modules/dejagnu
216+ gcc
217+ newlib
218+ binutils
219+ gdb
220+ spike
221+ pk
222+ dejagnu
223+ key : ${{ env.cache-key }}
224+
239225 - name : Install Dependencies
240226 run : sudo ./.github/setup-apt.sh
241227
0 commit comments