diff --git a/.github/workflows/macos-all.yml b/.github/workflows/macos-all.yml index 1a8ff01f..d50c45eb 100644 --- a/.github/workflows/macos-all.yml +++ b/.github/workflows/macos-all.yml @@ -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: @@ -35,7 +42,7 @@ 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/. @@ -43,6 +50,37 @@ jobs: 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 @@ -61,7 +99,7 @@ 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 @@ -69,6 +107,9 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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