From 8f5bcad244fcd35febbea22e42fc4b9d306a371b Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 29 Sep 2023 23:38:01 -0700 Subject: [PATCH] [ci] Use sccache for cmake builds (#5692) --- .github/workflows/cmake.yml | 29 ++++++++++++++++++++++++----- .github/workflows/sanitizers.yml | 13 ++++++++++--- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index dff4a42ef5..93809039c4 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -25,8 +25,6 @@ jobs: runs-on: ${{ matrix.os }} container: ${{ matrix.container }} steps: - - uses: actions/checkout@v3 - - name: Install dependencies (Linux) if: runner.os == 'Linux' run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3 ninja-build @@ -41,15 +39,24 @@ jobs: with: python-version: 3.8 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Install jinja run: python -m pip install jinja2 + - uses: actions/checkout@v3 + - name: configure - run: cmake -S . -B build -G "Ninja" ${{ matrix.flags }} + run: cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ matrix.flags }} + env: + SCCACHE_GHA_ENABLED: "true" - name: build working-directory: build run: cmake --build . --parallel $(nproc) + env: + SCCACHE_GHA_ENABLED: "true" - name: test working-directory: build @@ -59,7 +66,6 @@ jobs: name: "Build - Windows" runs-on: windows-2022 steps: - - uses: actions/checkout@v3 - uses: ilammy/msvc-dev-cmd@v1 - name: Install CMake @@ -71,26 +77,39 @@ jobs: vcpkgDirectory: ${{ runner.workspace }}/vcpkg vcpkgGitCommitId: 78b61582c9e093fda56a01ebb654be15a0033897 # HEAD on 2023-08-6 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Install jinja run: python -m pip install jinja2 + - uses: actions/checkout@v3 + - name: configure - run: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release + run: cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release + env: + SCCACHE_GHA_ENABLED: "true" # Build wpiutil at full speed, wpimath depends on wpiutil - name: build wpiutil working-directory: build run: cmake --build . --parallel $(nproc) --target wpiutil/all + env: + SCCACHE_GHA_ENABLED: "true" # Build wpimath slow to prevent OOM - name: build wpimath working-directory: build run: cmake --build . --parallel 1 --target wpimath/all + env: + SCCACHE_GHA_ENABLED: "true" # Build everything else fast - name: build working-directory: build run: cmake --build . --parallel $(nproc) + env: + SCCACHE_GHA_ENABLED: "true" - name: test working-directory: build diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 3f68a61451..9c5e46efe5 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -28,20 +28,27 @@ jobs: runs-on: ubuntu-22.04 container: wpilib/roborio-cross-ubuntu:2023-22.04 steps: - - uses: actions/checkout@v3 - - name: Install Dependencies run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3 clang-14 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Install jinja run: python -m pip install jinja2 + - uses: actions/checkout@v3 + - name: configure - run: mkdir build && cd build && cmake -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 ${{ matrix.cmake-flags }} .. + run: mkdir build && cd build && cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 ${{ matrix.cmake-flags }} .. + env: + SCCACHE_GHA_ENABLED: "true" - name: build working-directory: build run: cmake --build . --parallel $(nproc) + env: + SCCACHE_GHA_ENABLED: "true" - name: test working-directory: build