77 pull_request :
88 branches :
99 - master
10-
10+ env :
11+ cache-path : |
12+ .git/modules
13+ binutils
14+ gdb
15+ gcc
16+ llvm
17+ newlib
18+ glibc
19+ musl
20+ uclib-ng
21+ dejagnu
22+ pk
23+ qemu
24+ spike
1125jobs :
1226 cache :
1327 name : Update Submodule Cache
1428 runs-on : ubuntu-24.04
29+ outputs :
30+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
1531 steps :
1632 - uses : actions/checkout@v4
1733
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
41-
42- - name : Cache Linux
43- uses : actions/cache@v4
44- with :
45- path : |
46- .git/modules/glibc
47- glibc
48- key : mode-linux
49-
50- - name : Cache musl
51- uses : actions/cache@v4
52- with :
53- path : |
54- .git/modules/musl
55- musl
56- key : mode-musl
34+ - name : Generate Submodule Hash
35+ id : submodule-hash
36+ run : echo "HASH=$(git submodule | sha1sum | head -c 40)" >> $GITHUB_OUTPUT
5737
58- - name : Cache uClibc
59- uses : actions/cache@v4
38+ - name : Check is Cache Exists for Exact Submodule Configuration
39+ id : cache-check
40+ uses : actions/cache/restore@v4
6041 with :
61- path : |
62- .git/modules/uclibc-ng
63- uclibc-ng
64- key : mode-uclibc
42+ path : ${{ env.cache-path }}
43+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
44+ lookup-only : true
6545
66- - name : Cache Always Required Submodules
46+ - name : If no Cache Hit, Update Cache
6747 uses : actions/cache@v4
48+ if : steps.cache-check.outputs.cache-hit != 'true'
6849 with :
69- path : |
70- .git/modules/binutils
71- .git/modules/gdb
72- binutils
73- gdb
74- key : general-dependencies
50+ path : ${{ env.cache-path }}
51+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
52+ restore-keys : |
53+ submodules-
7554
76- - name : Clone needed submodules
55+ - name : Clone submodules
56+ if : steps.cache-check.outputs.cache-hit != 'true'
7757 run : |
78- git submodule update --init --progress --depth 1 --jobs $(nproc) binutils gdb gcc llvm newlib glibc musl
58+ git submodule update --init --progress --depth 1 --jobs $(nproc) binutils gdb gcc llvm newlib glibc musl dejagnu pk qemu spike
7959 git submodule update --init --progress uclibc-ng
8060
8161
8464 name : Build Toolchain Variants
8565 runs-on : ${{ matrix.os }}
8666 needs : [cache]
67+ env :
68+ cache-key : ${{ needs.cache.outputs.key }}
8769 strategy :
8870 matrix :
8971 os : [ubuntu-22.04, ubuntu-24.04]
@@ -105,63 +87,44 @@ jobs:
10587 echo "-- After --"
10688 df -h
10789
108- - name : Generate Required Submodules
109- id : required-submodules
90+ - name : Generate Submodules List
91+ id : cache-path
92+ if : false
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
137- uses : actions/cache/restore@v4
138- env :
139- submodule : ${{ steps.required-submodules.outputs.COMPILER_SUBMODULE }}
140- with :
141- 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
123+ - name : Load Cache
157124 uses : actions/cache/restore@v4
158125 with :
159- path : |
160- .git/modules/binutils
161- .git/modules/gdb
162- binutils
163- gdb
164- key : general-dependencies
126+ path : ${{ env.cache-path }}
127+ key : ${{ env.cache-key }}
165128
166129 - name : Install Dependencies
167130 run : sudo ./.github/setup-apt.sh
@@ -218,6 +181,9 @@ jobs:
218181 test-sim :
219182 name : Test Simulation
220183 runs-on : ${{ matrix.os }}
184+ needs : [cache]
185+ env :
186+ cache-key : ${{ needs.cache.outputs.key }}
221187 strategy :
222188 matrix :
223189 os : [ubuntu-24.04]
@@ -236,6 +202,11 @@ jobs:
236202
237203 - uses : actions/checkout@v4
238204
205+ - uses : actions/cache/restore@v4
206+ with :
207+ path : ${{ env.cache-path }}
208+ key : ${{ env.cache-key }}
209+
239210 - name : Install Dependencies
240211 run : sudo ./.github/setup-apt.sh
241212
0 commit comments