[snap] enable ccache in Linux Snap workflow

Also adding `push` to triggering events to populate the cache.

Signed-off-by: Michał Sawicz <michal@sawicz.net>
This commit is contained in:
Michał Sawicz 2021-01-06 18:06:17 +01:00 committed by Dirk Hohndel
parent d2bbe36572
commit 4ecb8ba0cc
2 changed files with 69 additions and 0 deletions

44
.github/workflows/linux-snap.patch vendored Normal file
View file

@ -0,0 +1,44 @@
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -32,6 +32,7 @@ parts:
googlemaps:
source: git://github.com/Subsurface/googlemaps.git
build-packages:
+ - ccache
- wget
override-pull: |
snapcraftctl pull
@@ -75,6 +76,8 @@ parts:
plugin: qmake
options:
- INCLUDEPATH+=QtHeaders
+ - QMAKE_CC=ccache gcc
+ - QMAKE_CXX=ccache g++
desktop-qt5:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
@@ -105,7 +108,11 @@ parts:
source: .
source-type: git
source-subdir: libdivecomputer
+ configflags:
+ - CC=ccache gcc
+ - CXX=ccache g++
build-packages:
+ - ccache
- libbluetooth-dev
- libhidapi-dev
- libusb-dev
@@ -127,9 +134,12 @@ parts:
- -DLIBGIT2_DYNAMIC=ON
- -DFTDISUPPORT=ON
- -DLIBDIVECOMPUTER_LIBRARIES=../../../stage/lib/libdivecomputer.so
+ - -DCMAKE_C_COMPILER_LAUNCHER=ccache
+ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
source-type: git
build-packages:
- build-essential
+ - ccache
- libcurl4-gnutls-dev
- libftdi1-dev
- libgit2-dev

View file

@ -28,11 +28,36 @@ jobs:
# Needed for version determination to work
fetch-depth: 0
- name: Set up CCache
id: setup-ccache
run: |
sudo apt-get install ccache
ccache --max-size=2G
sg lxd -c '/snap/bin/lxc profile device add default ccache disk source=${HOME}/.ccache/ path=/root/.ccache'
# Patch snapcraft.yaml to enable ccache
patch -p1 < .github/workflows/linux-snap.patch
# Find common base between master and HEAD to use as cache key.
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules origin master
echo "::set-output name=key::$( git merge-base origin/master ${{ github.sha }} )"
- name: CCache
uses: actions/cache@v2
with:
key: ccache-${{ runner.os }}-${{ steps.setup-ccache.outputs.key }}
restore-keys: |
ccache-${{ runner.os }}-
path: ~/.ccache/**
- name: Build
run: |
# Build the `subsurface` part.
sg lxd -c '/snap/bin/snapcraft build --use-lxd subsurface'
- name: Clear CCache stats
run: ccache --show-stats --zero-stats
- name: Build and verify the snap
id: build-snap
env: