Skip to content

Commit

Permalink
Try speeding up build with ccache
Browse files Browse the repository at this point in the history
"Inspired" by Bergamot
  • Loading branch information
jelmervdl committed Dec 1, 2021
1 parent 11d99a3 commit a4e3e3b
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/macos-all.yml
Expand Up @@ -11,6 +11,13 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
ccache_basedir: ${{ github.workspace }}
ccache_dir: "${{ github.workspace }}/.ccache"
ccache_compilercheck: content
ccache_compress: 'true'
ccache_compresslevel: 9
ccache_maxsize: 200M
ccache_cmake: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache

jobs:
build-macos:
Expand All @@ -35,14 +42,45 @@ jobs:
- name: Dependencies # This qt6 build and we suppose apple accelerate was installed, but we can use openblas as a fallback until this is merged.
run: |
brew update
brew install protobuf coreutils qt libarchive openblas
brew install protobuf coreutils qt libarchive openblas ccache
# Openblas location is exported explicitly because openblas is keg-only,
# which means it was not symlinked into /usr/local/.
- name: Set BLAS Environment variables
run: |
echo "LDFLAGS=-L/usr/local/opt/openblas/lib" >> $GITHUB_ENV
echo "CPPFLAGS=-I/usr/local/opt/openblas/include" >> $GITHUB_ENV
- name: Generate ccache_vars for ccache based on machine
shell: bash
id: ccache_vars
run: |-
echo "::set-output name=hash::$(echo ${{ env.ccache_compilercheck }})"
echo "::set-output name=timestamp::$(date '+%Y-%m-%dT%H.%M.%S')"
- name: Cache-op for build-cache through ccache
uses: actions/cache@v2
with:
path: ${{ env.ccache_dir }}
key: ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}-${{ steps.ccache_vars.outputs.timestamp }}
restore-keys: |-
ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}
ccache-${{ matrix.identifier }}-${{ steps.ccache_vars.outputs.hash }}
ccache-${{ matrix.identifier }}
- name: ccache environment setup
run: |-
echo "CCACHE_COMPILER_CHECK=${{ env.ccache_compilercheck }}" >> $GITHUB_ENV
echo "CCACHE_BASEDIR=${{ env.ccache_basedir }}" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=${{ env.ccache_compress }}" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=${{ env.ccache_compresslevel }}" >> $GITHUB_ENV
echo "CCACHE_DIR=${{ env.ccache_dir }}" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=${{ env.ccache_maxsize }}" >> $GITHUB_ENV
- name: ccache prolog
run: |-
ccache -s # Print current cache stats
ccache -z # Zero cache entry
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
Expand All @@ -61,14 +99,17 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE ${{ env.ccache_cmake }}

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -j3 --target translateLocally-bin translateLocally.dmg

- name: ccache epilog
run: 'ccache -s # Print current cache stats'

- name: Output test # @TODO some more complicated test, perhaps a unit test
working-directory: ${{github.workspace}}/build
shell: bash
Expand Down

0 comments on commit a4e3e3b

Please sign in to comment.