Skip to content

Commit 4ddca40

Browse files
authored
[ci] Enable Remote Caching for CMake (#5168)
Also remove ccache support when the launcher is specified. This was preventing sccache to work.
1 parent 551e03e commit 4ddca40

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/presubmit.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,20 @@ jobs:
8282
generator: 'Visual Studio 17 2022'
8383
cmake_flags: '-DCMAKE_CONFIGURATION_TYPES="Release"'
8484
runs-on: ${{matrix.os}}
85+
env:
86+
SCCACHE_GHA_ENABLED: true
87+
SCCACHE_GCS_BUCKET: or-tools-github-remote-caching
88+
SCCACHE_GCS_KEY_PREFIX: cmake
89+
SCCACHE_GCS_RW_MODE: READ_WRITE
8590
steps:
8691
- uses: actions/checkout@v6
92+
- uses: 'google-github-actions/auth@v3'
93+
with:
94+
credentials_json: '${{secrets.GCP_BUCKET_API_KEY}}'
95+
- name: Run sccache-cache
96+
uses: mozilla-actions/sccache-action@v0.0.10
97+
env:
98+
SCCACHE_GCS_KEY_PATH: ${{env.GOOGLE_GHA_CREDS_PATH}}
8799
- uses: actions/setup-java@v5
88100
if: ${{ matrix.build == 'java' }}
89101
with:
@@ -94,10 +106,10 @@ jobs:
94106
python-version: ${{env.PYTHON_VERSION}}
95107
- name: Setup linux
96108
if: ${{ matrix.platform == 'linux' }}
97-
run: sudo apt install -y ninja-build ccache swig
109+
run: sudo apt install -y ninja-build swig
98110
- name: Setup macos
99111
if: ${{ matrix.platform == 'macos' }}
100-
run: brew install ccache swig
112+
run: brew install swig
101113
- name: Setup Linux Python Env
102114
if: ${{ matrix.build == 'python' && matrix.platform == 'linux' }}
103115
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
@@ -124,6 +136,8 @@ jobs:
124136
-DUSE_GLPK=OFF
125137
-DUSE_HIGHS=OFF
126138
-DUSE_SCIP=OFF
139+
-DCMAKE_C_COMPILER_LAUNCHER=${{env.SCCACHE_PATH}}
140+
-DCMAKE_CXX_COMPILER_LAUNCHER=${{env.SCCACHE_PATH}}
127141
- name: Build
128142
run: cmake --build build --config Release -j --target ${{ matrix.generator == 'Ninja' && 'all' || 'ALL_BUILD'}}
129143
- name: Test

cmake/ccache.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14-
if(NOT UNIX)
14+
if((NOT UNIX) OR (CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER))
1515
return()
1616
endif()
1717

0 commit comments

Comments
 (0)