Skip to content

Use CCache to speed up build times in GitHub actions #5609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 110 additions & 14 deletions .github/workflows/pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,30 @@ jobs:
# user input
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get install -yq gcc gdb g++ maven jq flex bison libxml2-utils
sudo apt-get install -yq gcc gdb g++ maven jq flex bison libxml2-utils ccache
make -C src minisat2-download
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-20.04-make-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-20.04-make-${{ github.ref }}
${{ runner.os }}-20.04-make
- name: ccache environment
run: |
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
- name: Zero ccache stats and limit in size
run: ccache -z --max-size=500M
- name: Build with make
run: |
make -C src CXX='/usr/bin/g++' -j2
make -C unit CXX='/usr/bin/g++' -j2
make -C jbmc/src CXX='/usr/bin/g++' -j2
make -C jbmc/unit CXX='/usr/bin/g++' -j2
make -C src CXX='ccache /usr/bin/g++' -j2
make -C unit CXX='ccache /usr/bin/g++' -j2
make -C jbmc/src CXX='ccache /usr/bin/g++' -j2
make -C jbmc/unit CXX='ccache /usr/bin/g++' -j2
- name: Print ccache stats
run: ccache -s
- name: Run unit tests
run: |
make -C unit test
Expand All @@ -50,14 +66,30 @@ jobs:
# user input
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get install -yq cmake ninja-build gcc g++ maven flex bison libxml2-utils dpkg-dev
sudo apt-get install -yq cmake ninja-build gcc g++ maven flex bison libxml2-utils dpkg-dev ccache
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-20.04-Release-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-20.04-Release-${{ github.ref }}
${{ runner.os }}-20.04-Release
- name: ccache environment
run: |
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
- name: Configure using CMake
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
- name: Zero ccache stats and limit in size
run: ccache -z --max-size=500M
- name: Build with Ninja
run: cd build; ninja -j2
- name: Print ccache stats
run: ccache -s
- name: Check if package building works
run: |
cd build
Expand All @@ -73,14 +105,30 @@ jobs:
with:
submodules: true
- name: Fetch dependencies
run: brew install maven flex bison parallel
run: brew install maven flex bison parallel ccache
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-make-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-make-${{ github.ref }}
${{ runner.os }}-make
- name: ccache environment
run: |
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
- name: Zero ccache stats and limit in size
run: ccache -z --max-size=500M
- name: Build using Make
run: |
make -C src minisat2-download
make -C src -j2
make -C jbmc/src -j2
make -C unit
make -C jbmc/unit
make -C src -j2 CXX="ccache clang++"
make -C jbmc/src -j2 CXX="ccache clang++"
make -C unit "CXX=ccache clang++"
make -C jbmc/unit "CXX=ccache clang++"
- name: Print ccache stats
run: ccache -s
- name: Run unit tests
run: cd unit; ./unit_tests
- name: Run JBMC unit tests
Expand All @@ -97,14 +145,30 @@ jobs:
with:
submodules: true
- name: Fetch dependencies
run: brew install cmake ninja maven flex bison
run: brew install cmake ninja maven flex bison ccache
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-Release-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-Release-${{ github.ref }}
${{ runner.os }}-Release
- name: ccache environment
run: |
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
- name: Zero ccache stats and limit in size
run: ccache -z --max-size=500M
- name: Configure using CMake
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++
- name: Build with Ninja
run: cd build; ninja -j2
- name: Print ccache stats
run: ccache -s
- name: Run CTest
run: cd build; ctest -V -L CORE . -j2

Expand Down Expand Up @@ -187,7 +251,21 @@ jobs:
- name: Fetch dependencies
run: |
choco install winflexbison3
nuget install clcache -OutputDirectory "c:\tools" -ExcludeVersion -Version 4.1.0
echo "c:\tools\clcache\clcache-4.1.0" >> $env:GITHUB_PATH
- uses: microsoft/[email protected]
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-msbuild-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-msbuild-${{ github.ref }}
${{ runner.os }}-msbuild
- name: ccache environment
run: |
echo "CLCACHE_BASEDIR=$((Get-Item -Path '.\').FullName)" >> $env:GITHUB_ENV
echo "CLCACHE_DIR=$pwd\.ccache" >> $env:GITHUB_ENV
- name: Configure with cmake
run: |
New-Item -ItemType Directory -Path build
Expand All @@ -196,7 +274,9 @@ jobs:
- name: Build Release
run: |
Set-Location build
cmake --build . --config Release -- /p:CL_MPcount=2
cmake --build . --config Release -- /p:CL_MPcount=2 /p:CLToolExe=clcache
- name: Print ccache stats
run: clcache -s
- name: Create packages
id: create_packages
# We need to get the path to cpack because fascinatingly,
Expand All @@ -218,7 +298,21 @@ jobs:
with:
submodules: recursive
- name: Fetch dependencies
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev ccache
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-18.04-Release-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-18.04-Release-${{ github.ref }}
${{ runner.os }}-18.04-Release
- name: ccache environment
run: |
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
- name: Zero ccache stats and limit in size
run: ccache -z --max-size=500M
- name: Configure CMake
run: |
mkdir build
Expand All @@ -228,6 +322,8 @@ jobs:
run: |
cd build
ninja -j2
- name: Print ccache stats
run: ccache -s
- name: Run CTest
run: cd build; ctest . -V -L CORE -C Release -j2
- name: Create packages
Expand Down
54 changes: 51 additions & 3 deletions .github/workflows/release-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,32 @@ jobs:
with:
submodules: recursive
- name: Fetch dependencies
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev ccache
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-20.04-Release-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-20.04-Release-${{ github.ref }}
${{ runner.os }}-20.04-Release
- name: ccache environment
run: |
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
- name: Configure CMake
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
- name: Zero ccache stats and limit in size
run: ccache -z --max-size=500M
- name: Build using Ninja
run: |
cd build
ninja -j2
- name: Print ccache stats
run: ccache -s
- name: Run CTest
run: cd build; ctest . -V -L CORE -C Release -j2
- name: Create packages
Expand Down Expand Up @@ -53,16 +69,32 @@ jobs:
with:
submodules: recursive
- name: Fetch dependencies
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev
run: sudo apt install g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev ccache
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-18.04-Release-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-18.04-Release-${{ github.ref }}
${{ runner.os }}-18.04-Release
- name: ccache environment
run: |
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
- name: Configure CMake
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
- name: Zero ccache stats and limit in size
run: ccache -z --max-size=500M
- name: Build using Ninja
run: |
cd build
ninja -j2
- name: Print ccache stats
run: ccache -s
- name: Run CTest
run: cd build; ctest . -V -L CORE -C Release -j2
- name: Create packages
Expand Down Expand Up @@ -110,12 +142,26 @@ jobs:
- name: Fetch dependencies
run: |
choco install winflexbison3
nuget install clcache -OutputDirectory "c:\tools" -ExcludeVersion -Version 4.1.0
echo "c:\tools\clcache\clcache-4.1.0" >> $env:GITHUB_PATH
- uses: microsoft/[email protected]
name: Setup Visual Studio environment
- name: Setup code sign environment
run: |
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
echo "pfxcert=$([string](Get-Location)+'\CodeSignCertificate.pfx')" >> $env:GITHUB_ENV
- name: Prepare ccache
uses: actions/cache@v2
with:
path: .ccache
key: ${{ runner.os }}-msbuild-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-msbuild-${{ github.ref }}
${{ runner.os }}-msbuild
- name: ccache environment
run: |
echo "CLCACHE_BASEDIR=$((Get-Item -Path '.\').FullName)" >> $env:GITHUB_ENV
echo "CLCACHE_DIR=$pwd\.ccache" >> $env:GITHUB_ENV
- name: Configure with cmake
run: |
New-Item -ItemType Directory -Path build
Expand All @@ -124,7 +170,9 @@ jobs:
- name: Build Release
run: |
Set-Location build
cmake --build . --config Release -j2
cmake --build . --config Release -j2 -- /p:CLToolExe=clcache
- name: Print ccache stats
run: clcache -s
- name: Create packages
id: create_packages
run: |
Expand Down