From 3ee6a2baf27968a4d5ba850da220cda8eb5a771a Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 7 Sep 2021 22:50:47 -0700 Subject: [PATCH] Enable ccache for faster builds --- .github/ccache.sh | 17 +++++++++++++++++ .github/workflows/build.yml | 28 ++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 .github/ccache.sh diff --git a/.github/ccache.sh b/.github/ccache.sh new file mode 100644 index 000000000..16f310495 --- /dev/null +++ b/.github/ccache.sh @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 869bcab22..a60099c62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,7 @@ on: - 'buildSrc/**' - 'build.py' - 'gradle.properties' + - '.github/workflows/build.yml' pull_request: branches: [ master ] workflow_dispatch: @@ -22,6 +23,9 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] + env: + NDK_CCACHE: ${{ github.workspace }}/ccache + CCACHE_DIR: ${{ github.workspace }}/.ccache steps: - name: Check out @@ -40,12 +44,8 @@ jobs: with: python-version: '3.x' - - name: Set up GitHub env - run: | - 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: Set up ccache + run: bash .github/ccache.sh - name: Cache Gradle uses: actions/cache@v2 @@ -56,14 +56,26 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} 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 run: python build.py ndk - name: Build release - run: python build.py -vr all + run: | + ./ccache -zp + python build.py -vr all - name: Build debug - run: python build.py -v all + run: | + python build.py -v all + ./ccache -s - name: Stop gradle daemon run: ./gradlew --stop