1414 name : consensus_sim + pm unit tests (distro Boost)
1515 runs-on : ubuntu-latest
1616 timeout-minutes : 180
17+ env :
18+ CCACHE_DIR : /home/runner/.cache/ccache
19+ CCACHE_MAXSIZE : 1G
1720
1821 steps :
1922 - uses : actions/checkout@v6
@@ -60,10 +63,13 @@ jobs:
6063 libbz2-dev liblzma-dev libzstd-dev libreadline-dev \
6164 libtool ncurses-dev pkg-config zlib1g-dev
6265
66+ # ccache >= 4 keeps its cache in ~/.cache/ccache, not ~/.ccache, so the old path
67+ # never existed and nothing was ever saved ("Path Validation Error"). Pin the
68+ # directory so the restore/save path and ccache agree.
6369 - name : Restore ccache
6470 uses : actions/cache@v5
6571 with :
66- path : ~/.ccache
72+ path : ${{ env.CCACHE_DIR }}
6773 key : tests-ccache-${{ runner.os }}-${{ github.sha }}
6874 restore-keys : tests-ccache-${{ runner.os }}-
6975
8591 TEST_CMAKE=$(find ../tests -mindepth 2 -maxdepth 2 -name CMakeLists.txt)
8692 TEST_BINS=$(grep -ho 'add_test(NAME [a-z_]* COMMAND [a-z_]*' $TEST_CMAKE | awk '{print $NF}')
8793 make -j"$(nproc)" $TEST_BINS
94+ ccache -s
8895
8996 - name : Run tests
9097 env :
@@ -111,6 +118,9 @@ jobs:
111118 validators : [1, 2]
112119 runs-on : ubuntu-latest
113120 timeout-minutes : 120
121+ env :
122+ CCACHE_DIR : /home/runner/.cache/ccache
123+ CCACHE_MAXSIZE : 1G
114124
115125 steps :
116126 - uses : actions/checkout@v6
@@ -129,10 +139,18 @@ jobs:
129139 apt="sudo apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20"
130140 $apt update
131141 $apt install -y --no-install-recommends \
132- build-essential cmake libboost-all-dev libssl-dev \
142+ build-essential ccache cmake libboost-all-dev libssl-dev \
133143 libbz2-dev liblzma-dev libzstd-dev libreadline-dev \
134144 libtool ncurses-dev pkg-config zlib1g-dev
135145
146+ # One cache per matrix arm: CHAIN_TESTNET_VALIDATORS changes compile flags.
147+ - name : Restore ccache
148+ uses : actions/cache@v5
149+ with :
150+ path : ${{ env.CCACHE_DIR }}
151+ key : testnet-ccache-${{ runner.os }}-v${{ matrix.validators }}-${{ github.sha }}
152+ restore-keys : testnet-ccache-${{ runner.os }}-v${{ matrix.validators }}-
153+
136154 - name : Configure and build the consensus simulator (testnet config)
137155 run : |
138156 set -euo pipefail
@@ -143,12 +161,15 @@ jobs:
143161 multi=(-DCHAIN_TESTNET_VALIDATORS=2)
144162 fi
145163 cmake -DCMAKE_BUILD_TYPE=Release \
164+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
165+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
146166 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
147167 -DBUILD_SHARED_LIBRARIES=FALSE \
148168 -DCHAINBASE_CHECK_LOCKING=FALSE \
149169 -DBUILD_TESTNET=TRUE \
150170 -DBUILD_CONSENSUS_TESTS=ON "${multi[@]}" ..
151171 make -j"$(nproc)" consensus_sim_tests
172+ ccache -s
152173
153174 - name : Run the simulator
154175 run : |
0 commit comments