Skip to content

Commit 45b6aa5

Browse files
committed
add Nim caching to the CI
1 parent 3aa47a7 commit 45b6aa5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- stable
1414
- testing
1515
- unstable
16+
- cache-nim
1617
pull_request:
1718
paths-ignore: ['media/**', 'docs/**', '**/*.md']
1819
branches-ignore:
@@ -157,11 +158,47 @@ jobs:
157158
echo "ncpu=${ncpu}" >> $GITHUB_ENV
158159
echo "make_cmd=${make_cmd}" >> $GITHUB_ENV
159160
161+
162+
- name: Get Nim commit hash
163+
id: nim-hash
164+
run: |
165+
BRANCH="${{ matrix.branch }}"
166+
HASH=$(curl -s "https://api.github.com/repos/nim-lang/Nim/branches/${{ matrix.branch }}" | jq -r .commit.sha)
167+
echo "NIM_COMMIT_HASH=$HASH" >> $GITHUB_ENV
168+
echo "nim_commit_hash=$HASH" >> $GITHUB_OUTPUT
169+
170+
- name: Restore Nim build from cache
171+
id: nim-cache
172+
uses: actions/cache@v4
173+
with:
174+
path: |
175+
nim/bin
176+
nim/config
177+
nim/lib
178+
nim/nim.nimble
179+
key: nim-${{ matrix.branch }}-${{ steps.nim-hash.outputs.nim_commit_hash }}-${{ matrix.target.os }}-${{ matrix.target.cpu }}
180+
160181
- name: Build Nim and Nimbus dependencies
182+
if: steps.nim-cache.outputs.cache-hit != 'true'
161183
run: |
162184
${make_cmd} -j ${ncpu} NIM_COMMIT=${{ matrix.branch }} ARCH_OVERRIDE=${PLATFORM} QUICK_AND_DIRTY_COMPILER=1 update
163185
./env.sh nim --version
164186
187+
- name: Save Nim build to cache
188+
if: steps.nim-cache.outputs.cache-hit != 'true'
189+
uses: actions/cache@v4
190+
with:
191+
path: |
192+
nim/bin
193+
nim/config
194+
nim/lib
195+
nim/nim.nimble
196+
key: nim-${{ matrix.branch }}-${{ steps.nim-hash.outputs.nim_commit_hash }}-${{ matrix.target.os }}-${{ matrix.target.cpu }}
197+
198+
- name: Add Nim bin to GITHUB_PATH
199+
run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
200+
201+
165202
- name: Build binaries (with trace logging enabled)
166203
run: |
167204
${make_cmd} -j ${ncpu} V=1 NIM_COMMIT=${{ matrix.branch }} LOG_LEVEL=TRACE NIMFLAGS="-u:release --opt:none ${NIMFLAGS}"

0 commit comments

Comments
 (0)