Skip to content

Commit 45b590c

Browse files
authored
Cache Spike and Sail in CI (#526)
* Cache Spike in CI * Cache Sail in CI
1 parent f22666e commit 45b590c

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

.github/workflows/test.yml

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
sudo apt-get install -y python3 python3-pip python3-venv
4444
sudo apt-get install -y gcc git autoconf automake libtool curl make unzip
4545
sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev pkg-config
46+
sudo apt-get install device-tree-compiler libboost-regex-dev libboost-system-dev
4647
pip3 install git+https://github.com/riscv/riscof.git
4748
4849
- name: Build RISCV-GNU Toolchain (${{ matrix.xlen }} bit)
@@ -61,27 +62,73 @@ jobs:
6162
run: |
6263
cd riscv-ctg
6364
pip3 install --editable .
64-
65+
66+
- name: Get Latest Spike Commit
67+
run: |
68+
SPIKE_HASH=$(git ls-remote https://github.com/riscv/riscv-isa-sim.git HEAD | awk '{ print $1}')
69+
echo "SPIKE_HASH=$SPIKE_HASH" >> "$GITHUB_ENV"
70+
71+
- name: Restore cached Spike
72+
id: cache-spike-restore
73+
uses: actions/cache/restore@v4
74+
with:
75+
path: ${{ github.workspace }}/spike
76+
key: spike-${{ env.SPIKE_HASH }}-RV${{ matrix.xlen }}
77+
6578
- name: Install Spike
79+
if: steps.cache-spike-restore.outputs.cache-hit != 'true'
6680
run: |
6781
git clone https://github.com/riscv/riscv-isa-sim.git
68-
sudo apt-get install device-tree-compiler libboost-regex-dev libboost-system-dev
6982
cd riscv-isa-sim
7083
mkdir build
7184
cd build
72-
../configure --prefix=$GITHUB_WORKSPACE/riscv64
85+
../configure --prefix=$GITHUB_WORKSPACE/spike
7386
make -j$(nproc)
74-
sudo make install
75-
echo $GITHUB_WORKSPACE/riscv64/bin >> $GITHUB_PATH
87+
make install
88+
89+
- name: Save cached Spike
90+
if: steps.cache-spike-restore.outputs.cache-hit != 'true'
91+
id: cache-spike-save
92+
uses: actions/cache/save@v4
93+
with:
94+
path: ${{ github.workspace }}/spike
95+
key: ${{ steps.cache-spike-restore.outputs.cache-primary-key }}
96+
97+
- name: Get Latest Sail Commit
98+
run: |
99+
SAIL_HASH=$(git ls-remote https://github.com/riscv/sail-riscv.git HEAD | awk '{ print $1}')
100+
echo "SAIL_HASH=$SAIL_HASH" >> "$GITHUB_ENV"
101+
102+
- name: Restore cached Sail
103+
id: cache-sail-restore
104+
uses: actions/cache/restore@v4
105+
with:
106+
path: ${{ github.workspace }}/sail
107+
key: sail-${{ env.SAIL_HASH }}-RV${{ matrix.xlen }}
76108

77109
- name: Install Sail
110+
if: steps.cache-sail-restore.outputs.cache-hit != 'true'
78111
run: |
79112
sudo mkdir -p /usr/local
80113
curl --location https://github.com/rems-project/sail/releases/download/0.18-linux-binary/sail.tar.gz | sudo tar xvz --directory=/usr/local --strip-components=1
81114
git clone https://github.com/riscv/sail-riscv.git
82115
cd sail-riscv
83116
ARCH=RV${{ matrix.xlen }} make
84-
echo $PWD/c_emulator >> $GITHUB_PATH
117+
mkdir -p $GITHUB_WORKSPACE/sail
118+
mv c_emulator/riscv_sim_RV${{ matrix.xlen }} $GITHUB_WORKSPACE/sail/riscv_sim_RV${{ matrix.xlen }}
119+
120+
- name: Save cached Sail
121+
if: steps.cache-sail-restore.outputs.cache-hit != 'true'
122+
id: cache-sail-save
123+
uses: actions/cache/save@v4
124+
with:
125+
path: ${{ github.workspace }}/sail
126+
key: ${{ steps.cache-sail-restore.outputs.cache-primary-key }}
127+
128+
- name: Set PATH
129+
run: |
130+
echo $GITHUB_WORKSPACE/spike/bin >> $GITHUB_PATH
131+
echo $GITHUB_WORKSPACE/sail >> $GITHUB_PATH
85132
86133
- name: Config and run riscof for RV${{ matrix.xlen }}
87134
run: |

0 commit comments

Comments
 (0)