7
7
pull_request :
8
8
branches :
9
9
- 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
11
25
jobs :
12
26
cache :
13
27
name : Update Submodule Cache
14
28
runs-on : ubuntu-24.04
29
+ outputs :
30
+ key : submodules-${{ steps.submodule-hash.outputs.HASH }}
15
31
steps :
16
32
- uses : actions/checkout@v4
17
33
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
57
37
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
60
41
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
65
45
66
- - name : Cache Always Required Submodules
46
+ - name : If no Cache Hit, Update Cache
67
47
uses : actions/cache@v4
48
+ if : steps.cache-check.outputs.cache-hit != 'true'
68
49
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-
75
54
76
- - name : Clone needed submodules
55
+ - name : Clone submodules
56
+ if : steps.cache-check.outputs.cache-hit != 'true'
77
57
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
79
59
git submodule update --init --progress uclibc-ng
80
60
81
61
84
64
name : Build Toolchain Variants
85
65
runs-on : ${{ matrix.os }}
86
66
needs : [cache]
67
+ env :
68
+ cache-key : ${{ needs.cache.outputs.key }}
87
69
strategy :
88
70
matrix :
89
71
os : [ubuntu-22.04, ubuntu-24.04]
@@ -105,63 +87,44 @@ jobs:
105
87
echo "-- After --"
106
88
df -h
107
89
108
- - name : Generate Required Submodules
109
- id : required-submodules
90
+ - name : Generate Submodules List
91
+ id : cache-path
92
+ if : false
110
93
run : |
94
+ submodules="gdb:binutils"
111
95
case "${{ matrix.mode }}" in
112
96
"linux")
113
- MODE_SUBMODULE=" glibc";;
97
+ submodules="$submodules: glibc";;
114
98
"musl")
115
- MODE_SUBMODULE=" musl";;
99
+ submodules="$submodules: musl";;
116
100
"uclibc")
117
- MODE_SUBMODULE=" uclibc-ng";;
101
+ submodules="$submodules: uclibc-ng";;
118
102
"newlib")
119
- MODE_SUBMODULE=" newlib";;
103
+ submodules="$submodules: newlib";;
120
104
*)
121
105
echo "Invalid Mode"; exit 1;;
122
106
esac
123
- echo "MODE_SUBMODULE=$MODE_SUBMODULE" >> $GITHUB_OUTPUT
124
107
case "${{ matrix.compiler }}" in
125
108
"gcc")
126
- COMPILER_SUBMODULE=" gcc";;
109
+ submodules="$submodules: gcc";;
127
110
"llvm")
128
- COMPILER_SUBMODULE=" llvm";;
111
+ submodules="$submodules: llvm";;
129
112
*)
130
113
echo "Invalid Compiler"; exit 1;;
131
114
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
133
120
134
121
- uses : actions/checkout@v4
135
122
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
157
124
uses : actions/cache/restore@v4
158
125
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 }}
165
128
166
129
- name : Install Dependencies
167
130
run : sudo ./.github/setup-apt.sh
@@ -218,6 +181,9 @@ jobs:
218
181
test-sim :
219
182
name : Test Simulation
220
183
runs-on : ${{ matrix.os }}
184
+ needs : [cache]
185
+ env :
186
+ cache-key : ${{ needs.cache.outputs.key }}
221
187
strategy :
222
188
matrix :
223
189
os : [ubuntu-24.04]
@@ -236,6 +202,11 @@ jobs:
236
202
237
203
- uses : actions/checkout@v4
238
204
205
+ - uses : actions/cache/restore@v4
206
+ with :
207
+ path : ${{ env.cache-path }}
208
+ key : ${{ env.cache-key }}
209
+
239
210
- name : Install Dependencies
240
211
run : sudo ./.github/setup-apt.sh
241
212
0 commit comments