Enable ccache for faster builds

This commit is contained in:
topjohnwu 2021-09-07 22:50:47 -07:00 committed by John Wu
parent 69fa7f238d
commit 3ee6a2baf2
2 changed files with 37 additions and 8 deletions

17
.github/ccache.sh vendored Normal file
View File

@ -0,0 +1,17 @@
OS=$(uname)
CCACHE_VER=4.4
case $OS in
Darwin )
brew install ccache
ln -s $(which ccache) ./ccache
;;
Linux )
sudo apt-get install -y ccache
ln -s $(which ccache) ./ccache
;;
* )
curl -OL https://github.com/ccache/ccache/releases/download/v${CCACHE_VER}/ccache-${CCACHE_VER}-windows-64.zip
unzip -j ccache-*-windows-64.zip '*/ccache.exe'
;;
esac

View File

@ -10,6 +10,7 @@ on:
- 'buildSrc/**' - 'buildSrc/**'
- 'build.py' - 'build.py'
- 'gradle.properties' - 'gradle.properties'
- '.github/workflows/build.yml'
pull_request: pull_request:
branches: [ master ] branches: [ master ]
workflow_dispatch: workflow_dispatch:
@ -22,6 +23,9 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ] os: [ ubuntu-latest, windows-latest, macos-latest ]
env:
NDK_CCACHE: ${{ github.workspace }}/ccache
CCACHE_DIR: ${{ github.workspace }}/.ccache
steps: steps:
- name: Check out - name: Check out
@ -40,12 +44,8 @@ jobs:
with: with:
python-version: '3.x' python-version: '3.x'
- name: Set up GitHub env - name: Set up ccache
run: | run: bash .github/ccache.sh
ndk_ver=$(sed -n 's/^magisk.fullNdkVersion=//p' gradle.properties)
echo ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT >> $GITHUB_ENV
echo MAGISK_NDK_VERSION=$ndk_ver >> $GITHUB_ENV
shell: bash
- name: Cache Gradle - name: Cache Gradle
uses: actions/cache@v2 uses: actions/cache@v2
@ -56,14 +56,26 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: ${{ runner.os }}-gradle- restore-keys: ${{ runner.os }}-gradle-
- name: Cache ccache
id: ccache-cache
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.ccache
key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-ccache-
- name: Set up NDK - name: Set up NDK
run: python build.py ndk run: python build.py ndk
- name: Build release - name: Build release
run: python build.py -vr all run: |
./ccache -zp
python build.py -vr all
- name: Build debug - name: Build debug
run: python build.py -v all run: |
python build.py -v all
./ccache -s
- name: Stop gradle daemon - name: Stop gradle daemon
run: ./gradlew --stop run: ./gradlew --stop