Repository navigation
144 lines (125 loc) · 4.54 KB
/
Copy pathinit-submodules.yaml
File metadata and controls
144 lines (125 loc) · 4.54 KB
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
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:
inputs:
baseline_hash:
required: false
type: string
tot_hash:
required: false
type: string
outputs:
baseline_hash:
value: ${{ jobs.init-submodules.outputs.baseline_hash }}
tot_hash:
value: ${{ jobs.init-submodules.outputs.tot_hash }}
permissions:
actions: read
contents: read
env:
POSTCOMMIT_REPOSITORY: riseproject-dev/gcc-postcommit-ci
POSTCOMMIT_TOKEN: ${{ secrets.RISE_CI_READ_TOKEN }}
jobs:
init-submodules:
runs-on: ubuntu-24.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: Determine baseline
id: baseline-hash
run: |
if [ '${{ inputs.baseline_hash }}' == '' ] ; then
if [ -z "${POSTCOMMIT_TOKEN}" ]; then
echo "::error::RISE_CI_READ_TOKEN is required to read baseline issues from ${POSTCOMMIT_REPOSITORY}."
exit 1
fi
python ./scripts/get_baseline_hash.py -repo "${POSTCOMMIT_REPOSITORY}" -token "${POSTCOMMIT_TOKEN}"
export BASELINE_HASH=$(cat baseline.txt)
else
export BASELINE_HASH=${{ inputs.baseline_hash }}
fi
echo $BASELINE_HASH
echo "baseline_hash=$BASELINE_HASH" >> $GITHUB_OUTPUT
- 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: submodules-archive-17 # Invalidate cached source URLs after the mirror switch
- name: Synchronize submodule URLs
run: git submodule sync --recursive
- name: Initalize submodules cache
id: cache-init
if: steps.retrieve-cache.outputs.cache-hit != 'true'
run: |
bash scripts/update_ci_submodules.sh binutils dejagnu gdb glibc newlib 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
# 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
- name: Determine tip-of-tree hash
working-directory: riscv-gnu-toolchain/gcc
id: tot-hash
run: |
if [ '${{ inputs.tot_hash }}' != '' ]; then git checkout ${{ inputs.tot_hash }}; fi
export TOT_HASH=$(git rev-parse HEAD)
echo $TOT_HASH
echo "tot_hash=$TOT_HASH" >> $GITHUB_OUTPUT
- name: Checkout baseline GCC hash
working-directory: riscv-gnu-toolchain/gcc
run: |
git checkout ${{ steps.baseline-hash.outputs.baseline_hash }}
- 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: submodules-archive-17
- 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: gcc-sources-${{ steps.baseline-hash.outputs.baseline_hash }}
path: |
riscv-gnu-toolchain/cache.zip
retention-days: 5
outputs:
baseline_hash: ${{ steps.baseline-hash.outputs.baseline_hash }}
tot_hash: ${{ steps.tot-hash.outputs.tot_hash }}