Skip to content

Commit

Permalink
305 add ccache to linux build (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabele authored May 30, 2024
1 parent 369edec commit 2994f76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
41 changes: 21 additions & 20 deletions .github/actions/linux-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: "Linux Build"
description: "Build the C++ library on Linux. Produces artifact build-cpp-linux-$compiler-$version-$config."
inputs:
#take care to adapt the unique cache keys and artifact names below when adding new inputs that affect compilation
#keys also need to be adapted in the other jobs of the pipeline that use the artifacts
config:
description: "Configuration to build (Release or Debug, see CMAKE_BUILD_TYPE)"
required: true
Expand All @@ -21,38 +23,22 @@ inputs:
description: "Turn coverage on (ON or OFF, default OFF)"
required: false
default: "OFF"
sanitize-ub:
description: "Turn on UB sanitzer (ON or OFF, default OFF)"
required: false
default: "OFF"
sanitize-addr:
description: "Turn on address sanitzer (ON or OFF, default OFF)"
required: false
default: "OFF"
build-tests:
description: "Build tests"
required: false
default: "ON"
build-benchmarks:
description: "Build benchmarks"
sanitizers:
description: "Turn on sanitzers (ON or OFF, default OFF)"
required: false
default: "OFF"
openmp:
description: "Enable Multithreading with OpenMP (ON or OFF, default OFF). If ON, adds `-omp` to the name of the artifact."
required: false
default: "OFF"
enable-optimization:
description: "Enable optimization with Ipopt (ON or OFF, default ON)"
required: false
default: "ON"
runs:
using: "composite"
steps:
- name: Install dependencies
shell: bash
run: |
sudo apt-get -qq update
sudo apt-get -qq -y install lcov
sudo apt-get -qq -y install lcov ccache
if [[ "${{ inputs.optional-dependencies }}" == "ON" ]]; then
sudo apt-get -qq -y install libhdf5-dev
fi
Expand All @@ -71,6 +57,21 @@ runs:
sudo apt-get -qq -y install clang-14
fi
fi
- name: ccache
id: ccache
uses: hendrikmuhs/[email protected]
with:
# free total space for cache available on github is limited to 10GB, so only save on main branch;
# other branches will try to use cache from main, but branches that are too old won't benefit;
save: ${{ github.ref_name == 'main' }}
# set enough space per build cache to keep a few previous versions to be used by older branches
# debug builds require more space
max-size: ${{ inputs.config == 'Release' && '200M' || '1G' }}
# saves cache as `ccache-<key>-<timestamp>` (timestamp added automatically, key must be unique, github caches are never overwritten)
# key should be a composite of all options that affect the compilation
key: linux-${{ inputs.compiler }}-${{ inputs.version }}-${{ inputs.config }}-cov${{ inputs.coverage }}-dep${{ inputs.optional-dependencies }}-omp${{ inputs.openmp }}-san${{ inputs.sanitizers }}
# load most recent cache where a prefix of the key matches a restore-key, e.g. from the most recent nightly run of the same build
restore-keys: linux-${{ inputs.compiler }}-${{ inputs.version }}-${{ inputs.config }}-cov${{ inputs.coverage }}-dep${{ inputs.optional-dependencies }}-omp${{ inputs.openmp }}-san${{ inputs.sanitizers }}
- name: Build
shell: bash
run: |
Expand All @@ -96,7 +97,7 @@ runs:
exit 1
fi
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=${{ inputs.config }} -DMEMILIO_BUILD_TESTS=${{ inputs.build-tests }} -DMEMILIO_BUILD_BENCHMARKS=${{ inputs.build-benchmarks }} -DMEMILIO_ENABLE_IPOPT=${{ inputs.enable-optimization }} -DMEMILIO_TEST_COVERAGE=${{ inputs.coverage }} -DMEMILIO_SANITIZE_ADDRESS=${{ inputs.sanitize-addr }} -DMEMILIO_SANITIZE_UNDEFINED=${{ inputs.sanitize-ub }} -DMEMILIO_USE_BUNDLED_JSONCPP=${{ inputs.optional-dependencies }} -DMEMILIO_ENABLE_OPENMP=${{ inputs.openmp }} ..
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ inputs.config }} -DMEMILIO_ENABLE_IPOPT=ON -DMEMILIO_TEST_COVERAGE=${{ inputs.coverage }} -DMEMILIO_SANITIZE_ADDRESS=${{ inputs.sanitizers }} -DMEMILIO_SANITIZE_UNDEFINED=${{ inputs.sanitizers }} -DMEMILIO_USE_BUNDLED_JSONCPP=${{ inputs.optional-dependencies }} -DMEMILIO_ENABLE_OPENMP=${{ inputs.openmp }} ..
make -j4
- name: create build dir archive
shell: bash
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
config: ${{ matrix.config }}
version: ${{ matrix.version }}
coverage: ${{ (matrix.compiler == 'gcc' && matrix.config == 'Debug' && matrix.version == 'latest') && 'ON' || 'OFF' }} # `c && t || f` is (usually) equivalent to `c ? t : f`
sanitize-addr: ${{ (matrix.compiler == 'gcc' && matrix.config == 'Debug' && matrix.version == 'latest') && 'ON' || 'OFF' }}
sanitize-ub: ${{ (matrix.compiler == 'gcc' && matrix.config == 'Debug' && matrix.version == 'latest') && 'ON' || 'OFF' }}
sanitizers: ${{ (matrix.compiler == 'gcc' && matrix.config == 'Debug' && matrix.version == 'latest') && 'ON' || 'OFF' }}

build-cpp-gcc-no-optional-deps:
if: github.event.pull_request.draft == false
Expand Down

0 comments on commit 2994f76

Please sign in to comment.