-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: '${{ github.workflow }}-${{ github.ref_name }}' | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ci: | ||
name: CI | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-13] | ||
|
||
runs-on: ${{matrix.os}} | ||
container: ${{ matrix.os == 'ubuntu-latest' && 'ghcr.io/f3d-app/f3d-superbuild-ci' || null }} | ||
|
||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
path: 'source' | ||
fetch-depth: 0 | ||
|
||
- name: Checkout HelloWorld | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: f3d-app/HelloWorld | ||
path: HelloWorld | ||
ref: v2.0.1 | ||
|
||
- name: Install tools Windows | ||
if: runner.os == 'Windows' | ||
shell: cmd | ||
run: choco install ninja | ||
|
||
- name: Setup msvc Windows | ||
if: runner.os == 'Windows' | ||
uses: TheMrMilchmann/setup-msvc-dev@v3 | ||
with: | ||
arch: x64 | ||
|
||
- name: Use sccache action | ||
uses: ./source/ | ||
with: | ||
key: MyKey-0 | ||
|
||
- name: Setup directories | ||
working-directory: ${{github.workspace}}/HelloWorld | ||
shell: bash | ||
run: mkdir build | ||
|
||
- name: Configure | ||
working-directory: ${{github.workspace}}/HelloWorld/build | ||
shell: bash | ||
run: > | ||
cmake ../ | ||
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache | ||
-DCMAKE_C_COMPILER_LAUNCHER=sccache | ||
${{ runner.os == 'Windows' && '-G Ninja' || null }} | ||
- name: Build | ||
working-directory: ${{github.workspace}}/HelloWorld/build | ||
shell: bash | ||
run: cmake --build . | ||
|
||
- name: Show and check sccache | ||
shell: bash | ||
run: | | ||
sccache --show-stats | ||
sccache --show-stats | grep "Compile requests executed" | grep 1 | grep '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
# sccache-setup-action | ||
|
||
A github action to install and setup sccache to speed up your builds | ||
|
||
It installs (on Windows using `choco` and on MacOS using `brew`), recover a cached sccache cache using the github cache action | ||
then setup and run a sccache server. | ||
|
||
On Linux, it assumes sccache is available. | ||
|
||
Example usage: | ||
|
||
``` | ||
- name: Install and setup sccache | ||
uses: f3d-app/sccache-setup-action@v1 | ||
with: | ||
key: MyKey-0 | ||
``` | ||
|
||
Then during the configuration of your build, add sccache as a launcher, eg, for CMake: | ||
|
||
``` | ||
- name: Configure | ||
working-directory: ${{github.workspace}}/build | ||
shell: bash | ||
run: > | ||
cmake ../source | ||
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache | ||
-DCMAKE_C_COMPILER_LAUNCHER=sccache | ||
``` | ||
|
||
Resulting caches can be seen in your actions tab. | ||
|
||
To check the sccache action is behaving as expected, it is possible to add the following at the end of your job: | ||
|
||
``` | ||
- name: Stop and check sccache | ||
shell: bash | ||
run: sccache --show-stats | ||
``` | ||
|
||
Please note sccache does not work with Visual Studio Generator on Windows but requires ninja-build in that case: | ||
https://github.com/mozilla/sccache/issues/957 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: 'Install and Setup sccache' | ||
description: 'Install and setup sccache' | ||
branding: | ||
icon: 'arrow-up' | ||
color: 'green' | ||
inputs: | ||
key: | ||
description: 'Cache key to differentiate between caches' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
|
||
- name: Install sccache Windows | ||
if: runner.os == 'Windows' | ||
shell: cmd | ||
run: choco install sccache | ||
|
||
- name: Install sccache MacOS | ||
if: runner.os == 'macOS' | ||
shell: bash | ||
run: brew install sccache | ||
|
||
- name: Initialize sccache environnement | ||
shell: bash | ||
run: | | ||
sccache --start-server | ||
echo SCCACHE_CACHE=$(sccache --show-stats | grep Local | cut -d '"' -f2) >> $GITHUB_ENV | ||
echo DATE_STRING=$(date +'%Y%m%d') >> $GITHUB_ENV | ||
sccache --stop-server | ||
- name: Recover sccache cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{env.SCCACHE_CACHE}} | ||
key: sccache-cache-${{inputs.key}}-${{env.DATE_STRING}} | ||
restore-keys: sccache-cache-${{inputs.key}} | ||
|
||
- name: Start sccache | ||
shell: bash | ||
run: sccache --start-server |