Skip to content

Commit 3671da1

Browse files
committed
cache Nim build
1 parent efb9cd8 commit 3671da1

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

.github/workflows/common.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,23 @@ jobs:
155155
156156
157157
158+
- name: Get Nim commit hash
159+
id: nim-hash
160+
run: |
161+
BRANCH="${{ matrix.branch }}"
162+
HASH=$(curl -s "https://api.github.com/repos/nim-lang/Nim/branches/${{ matrix.branch }}" | jq -r .commit.sha)
163+
echo "NIM_COMMIT_HASH=$HASH" >> $GITHUB_ENV
164+
echo "nim_commit_hash=$HASH" >> $GITHUB_OUTPUT
165+
166+
- name: Restore Nim build from cache
167+
id: nim-cache
168+
uses: actions/cache@v4
169+
with:
170+
path: nim
171+
key: nim-${{ matrix.branch }}-${{ steps.nim-hash.outputs.nim_commit_hash }}-${{ runner.os }}-${{ matrix.target.cpu }}
172+
158173
- name: Build Nim and Nimble
174+
if: steps.nim-cache.outputs.cache-hit != 'true'
159175
env:
160176
MAKE: make -j4
161177
ARCH_OVERRIDE: ${{ matrix.target.platform }}
@@ -166,7 +182,16 @@ jobs:
166182
run: |
167183
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
168184
bash build_nim.sh nim csources dist/nimble NimBinaries
169-
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
185+
186+
- name: Save Nim build to cache
187+
if: steps.nim-cache.outputs.cache-hit != 'true'
188+
uses: actions/cache@v4
189+
with:
190+
path: nim
191+
key: nim-${{ matrix.branch }}-${{ steps.nim-hash.outputs.nim_commit_hash }}-${{ runner.os }}-${{ matrix.target.cpu }}
192+
193+
- name: Add Nim bin to GITHUB_PATH
194+
run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
170195

171196
- name: Add .nimble/bin path to GITHUB_PATH
172197
if: ${{ inputs.nimble-bin-path }}
@@ -179,6 +204,8 @@ jobs:
179204
echo '~/.nimble/bin' >> $GITHUB_PATH
180205
fi
181206
207+
208+
182209
- name: Run tests
183210
env:
184211
PLATFORM: ${{ matrix.target.platform }}

0 commit comments

Comments
 (0)