-
Notifications
You must be signed in to change notification settings - Fork 1
174 lines (155 loc) · 5.88 KB
/
init-submodules.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: "Intialize submodules"
# Upload the sources as an artifact for other steps to use
# This centralizes the process and reduces overall compute time
on:
workflow_call:
outputs:
gcchash:
value: ${{ jobs.init-submodules.outputs.gcchash }}
inputs:
prefix:
description: 'uploaded file prefix'
required: false
type: string
gcchash:
description: 'gcc hash to build. If blank then use tip-of-tree.'
required: false
type: string
gcc_branch:
description: 'GCC branch to pull from'
required: false
type: string
default: 'master'
binutils_branch:
description: 'binutils branch to pull from (only used if prefix is binutils_)'
required: false
type: string
default: 'master'
jobs:
init-submodules:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Retrieve cache
id: retrieve-cache
uses: actions/cache@v4
with:
path: |
riscv-gnu-toolchain/.git
riscv-gnu-toolchain/binutils
riscv-gnu-toolchain/dejagnu
riscv-gnu-toolchain/gcc
riscv-gnu-toolchain/gdb
riscv-gnu-toolchain/glibc
riscv-gnu-toolchain/newlib
riscv-gnu-toolchain/qemu
key: ${{ inputs.prefix }}submodules-archive-11 # Numbered archive to allow for easy transition when bumping submodules
- name: Initalize submodules cache
id: cache-init
if: steps.retrieve-cache.outputs.cache-hit != 'true'
run: |
git submodule update --init --recursive --depth 1 binutils
git submodule update --init --recursive --depth 1 dejagnu
git submodule update --init --recursive --depth 1 gdb
git submodule update --init --recursive --depth 1 glibc
git submodule update --init --recursive --depth 1 newlib
git submodule update --init --recursive --depth 1 qemu
continue-on-error: true
- name: Initalize submodules cache
if: steps.cache-init.outcome == 'failure'
run: |
echo "Failed to initialize cache submodules. Retrying in 1 min"
sleep 60
git submodule update --init --recursive --depth 1 binutils
git submodule update --init --recursive --depth 1 dejagnu
git submodule update --init --recursive --depth 1 gdb
git submodule update --init --recursive --depth 1 glibc
git submodule update --init --recursive --depth 1 newlib
git submodule update --init --recursive --depth 1 qemu
- name: Initialize gcc
if: steps.retrieve-cache.outputs.cache-hit != 'true'
id: gcc-cache
uses: ./.github/actions/common/init-and-pull-gcc
with:
init: true
branch: ${{ inputs.gcc_branch }}
- name: Intialize binutils
if: ${{ inputs.prefix == 'binutils_' && steps.retrieve-cache.outputs.cache-hit != 'true' }}
working-directory: ./riscv-gnu-toolchain
id: binutils-cache
run: |
rm -rf binutils
# Use the mirror since github tends to be pretty reliable for cloning.
git clone https://github.com/bminor/binutils-gdb.git binutils
cd binutils
git checkout ${{ inputs.binutils_branch }}
git pull
# Does not remove and reclone gcc if we hit cache
- name: Checkout GCC
if: steps.gcc-cache.outcome == 'skipped'
uses: ./.github/actions/common/init-and-pull-gcc
with:
init: false
branch: ${{ inputs.gcc_branch }}
- name: Apply newlib fixups
if: steps.retrieve-cache.outputs.cache-hit != 'true'
run: |
cd newlib
git config --global user.email "[email protected]"
git config --global user.name "Github Bot"
git am ../fixups/newlib/*.patch
- name: Get hash
working-directory: riscv-gnu-toolchain/gcc
id: gcc-hash
run: |
if [ "${{ inputs.gcchash }}" == "" ]; then
export GCCHASH=$(git rev-parse HEAD)
else
export GCCHASH=${{ inputs.gcchash }}
fi
echo $GCCHASH
git checkout $GCCHASH
# If it's a binutils run, we need to lie about the hash
if [ "${{ inputs.prefix }}" == "binutils_" ]; then
cd ../binutils
git checkout ${{ inputs.binutils_branch }}
git pull
export GCCHASH=$(git rev-parse HEAD)
fi
echo "gcchash=$GCCHASH" >> "$GITHUB_OUTPUT"
- name: Cache submodules
if: steps.retrieve-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
riscv-gnu-toolchain/.git
riscv-gnu-toolchain/binutils
riscv-gnu-toolchain/dejagnu
riscv-gnu-toolchain/gcc
riscv-gnu-toolchain/gdb
riscv-gnu-toolchain/glibc
riscv-gnu-toolchain/newlib
riscv-gnu-toolchain/qemu
key: ${{ inputs.prefix }}submodules-archive-11
- name: Make cache zip
run: |
zip -r cache.zip .git binutils dejagnu gcc gdb glibc newlib qemu
# Use artifact rather than cache since cache downloads are flaky/hang.
# Artifacts are reliable but ~30 min slower to set up.
# Setup is done on one runner, so this isn't a show stopper.
- name: Upload git cache
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.prefix }}gcc-sources-${{ steps.gcc-hash.outputs.gcchash }}
path: |
riscv-gnu-toolchain/cache.zip
retention-days: 5
outputs:
gcchash: ${{ steps.gcc-hash.outputs.gcchash }}