Skip to content

Commit c907b2b

Browse files
authored
Merge pull request #5609 from tautschnig/github-actions-ccache
Use CCache to speed up build times in GitHub actions
2 parents f2d735a + 1042403 commit c907b2b

File tree

2 files changed

+161
-17
lines changed

2 files changed

+161
-17
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,30 @@ jobs:
1616
# user input
1717
DEBIAN_FRONTEND: noninteractive
1818
run: |
19-
sudo apt-get install -yq gcc gdb g++ maven jq flex bison libxml2-utils
19+
sudo apt-get install -yq gcc gdb g++ maven jq flex bison libxml2-utils ccache
2020
make -C src minisat2-download
21+
- name: Prepare ccache
22+
uses: actions/cache@v2
23+
with:
24+
path: .ccache
25+
key: ${{ runner.os }}-20.04-make-${{ github.ref }}-${{ github.sha }}
26+
restore-keys: |
27+
${{ runner.os }}-20.04-make-${{ github.ref }}
28+
${{ runner.os }}-20.04-make
29+
- name: ccache environment
30+
run: |
31+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
32+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
33+
- name: Zero ccache stats and limit in size
34+
run: ccache -z --max-size=500M
2135
- name: Build with make
2236
run: |
23-
make -C src CXX='/usr/bin/g++' -j2
24-
make -C unit CXX='/usr/bin/g++' -j2
25-
make -C jbmc/src CXX='/usr/bin/g++' -j2
26-
make -C jbmc/unit CXX='/usr/bin/g++' -j2
37+
make -C src CXX='ccache /usr/bin/g++' -j2
38+
make -C unit CXX='ccache /usr/bin/g++' -j2
39+
make -C jbmc/src CXX='ccache /usr/bin/g++' -j2
40+
make -C jbmc/unit CXX='ccache /usr/bin/g++' -j2
41+
- name: Print ccache stats
42+
run: ccache -s
2743
- name: Run unit tests
2844
run: |
2945
make -C unit test
@@ -50,14 +66,30 @@ jobs:
5066
# user input
5167
DEBIAN_FRONTEND: noninteractive
5268
run: |
53-
sudo apt-get install -yq cmake ninja-build gcc g++ maven flex bison libxml2-utils dpkg-dev
69+
sudo apt-get install -yq cmake ninja-build gcc g++ maven flex bison libxml2-utils dpkg-dev ccache
70+
- name: Prepare ccache
71+
uses: actions/cache@v2
72+
with:
73+
path: .ccache
74+
key: ${{ runner.os }}-20.04-Release-${{ github.ref }}-${{ github.sha }}
75+
restore-keys: |
76+
${{ runner.os }}-20.04-Release-${{ github.ref }}
77+
${{ runner.os }}-20.04-Release
78+
- name: ccache environment
79+
run: |
80+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
81+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
5482
- name: Configure using CMake
5583
run: |
5684
mkdir build
5785
cd build
5886
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
87+
- name: Zero ccache stats and limit in size
88+
run: ccache -z --max-size=500M
5989
- name: Build with Ninja
6090
run: cd build; ninja -j2
91+
- name: Print ccache stats
92+
run: ccache -s
6193
- name: Check if package building works
6294
run: |
6395
cd build
@@ -73,14 +105,30 @@ jobs:
73105
with:
74106
submodules: true
75107
- name: Fetch dependencies
76-
run: brew install maven flex bison parallel
108+
run: brew install maven flex bison parallel ccache
109+
- name: Prepare ccache
110+
uses: actions/cache@v2
111+
with:
112+
path: .ccache
113+
key: ${{ runner.os }}-make-${{ github.ref }}-${{ github.sha }}
114+
restore-keys: |
115+
${{ runner.os }}-make-${{ github.ref }}
116+
${{ runner.os }}-make
117+
- name: ccache environment
118+
run: |
119+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
120+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
121+
- name: Zero ccache stats and limit in size
122+
run: ccache -z --max-size=500M
77123
- name: Build using Make
78124
run: |
79125
make -C src minisat2-download
80-
make -C src -j2
81-
make -C jbmc/src -j2
82-
make -C unit
83-
make -C jbmc/unit
126+
make -C src -j2 CXX="ccache clang++"
127+
make -C jbmc/src -j2 CXX="ccache clang++"
128+
make -C unit "CXX=ccache clang++"
129+
make -C jbmc/unit "CXX=ccache clang++"
130+
- name: Print ccache stats
131+
run: ccache -s
84132
- name: Run unit tests
85133
run: cd unit; ./unit_tests
86134
- name: Run JBMC unit tests
@@ -97,14 +145,30 @@ jobs:
97145
with:
98146
submodules: true
99147
- name: Fetch dependencies
100-
run: brew install cmake ninja maven flex bison
148+
run: brew install cmake ninja maven flex bison ccache
149+
- name: Prepare ccache
150+
uses: actions/cache@v2
151+
with:
152+
path: .ccache
153+
key: ${{ runner.os }}-Release-${{ github.ref }}-${{ github.sha }}
154+
restore-keys: |
155+
${{ runner.os }}-Release-${{ github.ref }}
156+
${{ runner.os }}-Release
157+
- name: ccache environment
158+
run: |
159+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
160+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
161+
- name: Zero ccache stats and limit in size
162+
run: ccache -z --max-size=500M
101163
- name: Configure using CMake
102164
run: |
103165
mkdir build
104166
cd build
105167
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++
106168
- name: Build with Ninja
107169
run: cd build; ninja -j2
170+
- name: Print ccache stats
171+
run: ccache -s
108172
- name: Run CTest
109173
run: cd build; ctest -V -L CORE . -j2
110174

@@ -187,7 +251,21 @@ jobs:
187251
- name: Fetch dependencies
188252
run: |
189253
choco install winflexbison3
254+
nuget install clcache -OutputDirectory "c:\tools" -ExcludeVersion -Version 4.1.0
255+
echo "c:\tools\clcache\clcache-4.1.0" >> $env:GITHUB_PATH
190256
- uses: microsoft/[email protected]
257+
- name: Prepare ccache
258+
uses: actions/cache@v2
259+
with:
260+
path: .ccache
261+
key: ${{ runner.os }}-msbuild-${{ github.ref }}-${{ github.sha }}
262+
restore-keys: |
263+
${{ runner.os }}-msbuild-${{ github.ref }}
264+
${{ runner.os }}-msbuild
265+
- name: ccache environment
266+
run: |
267+
echo "CLCACHE_BASEDIR=$((Get-Item -Path '.\').FullName)" >> $env:GITHUB_ENV
268+
echo "CLCACHE_DIR=$pwd\.ccache" >> $env:GITHUB_ENV
191269
- name: Configure with cmake
192270
run: |
193271
New-Item -ItemType Directory -Path build
@@ -196,7 +274,9 @@ jobs:
196274
- name: Build Release
197275
run: |
198276
Set-Location build
199-
cmake --build . --config Release -- /p:CL_MPcount=2
277+
cmake --build . --config Release -- /p:CL_MPcount=2 /p:CLToolExe=clcache
278+
- name: Print ccache stats
279+
run: clcache -s
200280
- name: Create packages
201281
id: create_packages
202282
# We need to get the path to cpack because fascinatingly,
@@ -218,7 +298,21 @@ jobs:
218298
with:
219299
submodules: recursive
220300
- name: Fetch dependencies
221-
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev
301+
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev ccache
302+
- name: Prepare ccache
303+
uses: actions/cache@v2
304+
with:
305+
path: .ccache
306+
key: ${{ runner.os }}-18.04-Release-${{ github.ref }}-${{ github.sha }}
307+
restore-keys: |
308+
${{ runner.os }}-18.04-Release-${{ github.ref }}
309+
${{ runner.os }}-18.04-Release
310+
- name: ccache environment
311+
run: |
312+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
313+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
314+
- name: Zero ccache stats and limit in size
315+
run: ccache -z --max-size=500M
222316
- name: Configure CMake
223317
run: |
224318
mkdir build
@@ -228,6 +322,8 @@ jobs:
228322
run: |
229323
cd build
230324
ninja -j2
325+
- name: Print ccache stats
326+
run: ccache -s
231327
- name: Run CTest
232328
run: cd build; ctest . -V -L CORE -C Release -j2
233329
- name: Create packages

.github/workflows/release-packages.yaml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,32 @@ jobs:
1313
with:
1414
submodules: recursive
1515
- name: Fetch dependencies
16-
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev
16+
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev ccache
17+
- name: Prepare ccache
18+
uses: actions/cache@v2
19+
with:
20+
path: .ccache
21+
key: ${{ runner.os }}-20.04-Release-${{ github.ref }}-${{ github.sha }}
22+
restore-keys: |
23+
${{ runner.os }}-20.04-Release-${{ github.ref }}
24+
${{ runner.os }}-20.04-Release
25+
- name: ccache environment
26+
run: |
27+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
28+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
1729
- name: Configure CMake
1830
run: |
1931
mkdir build
2032
cd build
2133
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
34+
- name: Zero ccache stats and limit in size
35+
run: ccache -z --max-size=500M
2236
- name: Build using Ninja
2337
run: |
2438
cd build
2539
ninja -j2
40+
- name: Print ccache stats
41+
run: ccache -s
2642
- name: Run CTest
2743
run: cd build; ctest . -V -L CORE -C Release -j2
2844
- name: Create packages
@@ -53,16 +69,32 @@ jobs:
5369
with:
5470
submodules: recursive
5571
- name: Fetch dependencies
56-
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev
72+
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev ccache
73+
- name: Prepare ccache
74+
uses: actions/cache@v2
75+
with:
76+
path: .ccache
77+
key: ${{ runner.os }}-18.04-Release-${{ github.ref }}-${{ github.sha }}
78+
restore-keys: |
79+
${{ runner.os }}-18.04-Release-${{ github.ref }}
80+
${{ runner.os }}-18.04-Release
81+
- name: ccache environment
82+
run: |
83+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
84+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
5785
- name: Configure CMake
5886
run: |
5987
mkdir build
6088
cd build
6189
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
90+
- name: Zero ccache stats and limit in size
91+
run: ccache -z --max-size=500M
6292
- name: Build using Ninja
6393
run: |
6494
cd build
6595
ninja -j2
96+
- name: Print ccache stats
97+
run: ccache -s
6698
- name: Run CTest
6799
run: cd build; ctest . -V -L CORE -C Release -j2
68100
- name: Create packages
@@ -110,12 +142,26 @@ jobs:
110142
- name: Fetch dependencies
111143
run: |
112144
choco install winflexbison3
145+
nuget install clcache -OutputDirectory "c:\tools" -ExcludeVersion -Version 4.1.0
146+
echo "c:\tools\clcache\clcache-4.1.0" >> $env:GITHUB_PATH
113147
- uses: microsoft/[email protected]
114148
name: Setup Visual Studio environment
115149
- name: Setup code sign environment
116150
run: |
117151
echo "$(Split-Path -Path $(Get-ChildItem -Path ${env:ProgramFiles(x86)} -Recurse -Filter 'signtool.exe' | Where-Object FullName -like '*10.0.19041.0\x64\signtool.exe').FullName)" >> $env:GITHUB_PATH
118152
echo "pfxcert=$([string](Get-Location)+'\CodeSignCertificate.pfx')" >> $env:GITHUB_ENV
153+
- name: Prepare ccache
154+
uses: actions/cache@v2
155+
with:
156+
path: .ccache
157+
key: ${{ runner.os }}-msbuild-${{ github.ref }}-${{ github.sha }}
158+
restore-keys: |
159+
${{ runner.os }}-msbuild-${{ github.ref }}
160+
${{ runner.os }}-msbuild
161+
- name: ccache environment
162+
run: |
163+
echo "CLCACHE_BASEDIR=$((Get-Item -Path '.\').FullName)" >> $env:GITHUB_ENV
164+
echo "CLCACHE_DIR=$pwd\.ccache" >> $env:GITHUB_ENV
119165
- name: Configure with cmake
120166
run: |
121167
New-Item -ItemType Directory -Path build
@@ -124,7 +170,9 @@ jobs:
124170
- name: Build Release
125171
run: |
126172
Set-Location build
127-
cmake --build . --config Release -j2
173+
cmake --build . --config Release -j2 -- /p:CLToolExe=clcache
174+
- name: Print ccache stats
175+
run: clcache -s
128176
- name: Create packages
129177
id: create_packages
130178
run: |

0 commit comments

Comments
 (0)