Skip to content

Commit c36c923

Browse files
authored
enhance(ci): add cache to evmone evm builds (#1828)
1 parent 3c58e8d commit c36c923

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

.github/actions/build-evm-client/evmone/action.yaml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,62 @@ inputs:
1616
runs:
1717
using: "composite"
1818
steps:
19+
- name: Get latest evmone commit
20+
id: evmone-sha
21+
shell: bash
22+
run: |
23+
SHA=$(git ls-remote https://github.com/${{ inputs.repo }}.git refs/heads/${{ inputs.ref }} | cut -f1)
24+
echo "sha=$SHA" >> $GITHUB_OUTPUT
25+
echo "Latest evmone commit: $SHA"
26+
- name: Prepare cache target dir
27+
shell: bash
28+
run: mkdir -p "$GITHUB_WORKSPACE/evmone/build"
29+
- name: Restore build cache
30+
id: cache-restore
31+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830
32+
with:
33+
path: |
34+
${{ github.workspace }}/evmone/build
35+
key: evmone-build-targets=${{ inputs.targets }}-sha=${{ steps.evmone-sha.outputs.sha }}
36+
restore-keys: |
37+
evmone-build-targets=${{ inputs.targets }}-
1938
- name: Checkout evmone
39+
if: steps.cache-restore.outputs.cache-hit != 'true'
2040
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2141
with:
2242
repository: ${{ inputs.repo }}
23-
ref: ${{ inputs.ref }}
43+
ref: ${{ steps.evmone-sha.outputs.sha }}
2444
path: evmone
2545
submodules: true
2646
- name: Setup cmake
47+
if: steps.cache-restore.outputs.cache-hit != 'true'
2748
uses: jwlawson/actions-setup-cmake@802fa1a2c4e212495c05bf94dba2704a92a472be
2849
with:
2950
cmake-version: '3.x'
3051
- name: "Install GMP Linux"
31-
if: runner.os == 'Linux'
52+
if: runner.os == 'Linux' && steps.cache-restore.outputs.cache-hit != 'true'
3253
shell: bash
3354
run: sudo apt-get -q update && sudo apt-get -qy install libgmp-dev
3455
- name: Install GMP macOS
35-
if: runner.os == 'macOS'
56+
if: runner.os == 'macOS' && steps.cache-restore.outputs.cache-hit != 'true'
3657
shell: bash
3758
run: |
3859
brew update && brew install gmp
3960
- name: Build evmone binary
61+
if: steps.cache-restore.outputs.cache-hit != 'true'
4062
shell: bash
4163
run: |
4264
mkdir -p $GITHUB_WORKSPACE/bin
4365
cd $GITHUB_WORKSPACE/evmone
4466
cmake -S . -B build -DEVMONE_TESTING=ON -DEVMONE_PRECOMPILES_SILKPRE=1
4567
cmake --build build --parallel --target ${{ inputs.targets }}
46-
echo $GITHUB_WORKSPACE/evmone/build/bin/ >> $GITHUB_PATH
68+
- name: Add evmone bin to PATH
69+
shell: bash
70+
run: echo $GITHUB_WORKSPACE/evmone/build/bin/ >> $GITHUB_PATH
71+
- name: Save build cache
72+
if: steps.cache-restore.outputs.cache-hit != 'true'
73+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830
74+
with:
75+
path: |
76+
${{ github.workspace }}/evmone/build
77+
key: evmone-build-targets=${{ inputs.targets }}-sha=${{ steps.evmone-sha.outputs.sha }}

0 commit comments

Comments
 (0)