-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make ci match conan specified toolchain correctly (#8)
- Force setup-cpp to install the same llvm version according to `llvm-<version>` when `compiler: llvm-<version>` and `clang-tidy: <version>` differs. - Match conan profile name with a regex pattern.
- Loading branch information
1 parent
e2672fa
commit e762099
Showing
7 changed files
with
182 additions
and
108 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,67 @@ | ||
name: "parse_environment" | ||
description: "Parse environment" | ||
inputs: | ||
os: | ||
required: true | ||
description: "Operating system" | ||
compiler: | ||
required: true | ||
description: "Compiler" | ||
outputs: | ||
os_name: | ||
description: "Operating system name (ubuntu converted to linux)" | ||
value: ${{ steps.os.outputs.name }} | ||
os_version: | ||
description: "Operating system version (if not set in inputs.os, set to latest)" | ||
value: ${{ steps.os.outputs.version }} | ||
arch: | ||
description: "Architecture" | ||
value: ${{ steps.arch.outputs.value }} | ||
compiler_name: | ||
description: "Compiler name (llvm converted to clang)" | ||
value: ${{ steps.compiler.outputs.name }} | ||
compiler_version: | ||
description: "Compiler version (if not set in inputs.compiler, set to latest)" | ||
value: ${{ steps.compiler.outputs.version }} | ||
gcov_executable: | ||
description: "The corresponding gcov_executable (Available only for clang and gcc)" | ||
value: ${{ steps.gcov.outputs.value }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Parse os and os version | ||
id: os | ||
shell: bash | ||
env: | ||
VALUE: ${{ contains(matrix.os, '-') && matrix.os || format('{0}-{1}', matrix.os, 'latest') }} | ||
run: | | ||
export NAME=${VALUE%%-*} | ||
echo name=${NAME/ubuntu/linux} >> "$GITHUB_OUTPUT" | ||
export VERSION=${VALUE##*-} | ||
echo version=$VERSION >> "$GITHUB_OUTPUT" | ||
- name: Parse architecture | ||
id: arch | ||
shell: bash | ||
run: | | ||
echo value=${{ steps.os.outputs.name == 'macos' && steps.os.outputs.version >= '14' && 'armv8' || 'x86_64' }} >> "$GITHUB_OUTPUT" | ||
- name: Parse compiler and compiler version | ||
id: compiler | ||
shell: bash | ||
env: | ||
VALUE: ${{ contains(matrix.compiler, '-') && matrix.compiler || format('{0}-{1}', matrix.compiler, 'latest') }} | ||
run: | | ||
export NAME=${VALUE%%-*} | ||
echo name=${NAME/llvm/clang} >> "$GITHUB_OUTPUT" | ||
export VERSION=${VALUE##*-} | ||
echo version=$VERSION >> "$GITHUB_OUTPUT" | ||
- name: Parse gcov | ||
id: gcov | ||
shell: bash | ||
run: | | ||
echo "value=${{ contains(matrix.compiler, 'llvm') && 'llvm-cov gcov' || contains(matrix.compiler, 'gcc') && format('{0}-{1}', 'gcov', steps.compiler.outputs.version) || '' }}" >> "$GITHUB_OUTPUT" |
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,15 +1,11 @@ | ||
name: "setup_cache" | ||
description: "sets up the shared cache" | ||
inputs: | ||
compiler: | ||
key: | ||
required: true | ||
description: "Compiler" | ||
build_type: | ||
required: true | ||
description: "Build type" | ||
developer_mode: | ||
required: true | ||
description: "Developer mode" | ||
description: "Cache key" | ||
restore_key: | ||
description: "Restore key when cache misses" | ||
|
||
runs: | ||
using: "composite" | ||
|
@@ -20,14 +16,14 @@ runs: | |
path: | | ||
~/.cache/pip | ||
~/.ccache | ||
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.developer_mode }}-${{ hashFiles('**/CMakeLists.txt') }} | ||
key: ${{ inputs.key }}-${{ hashFiles('**/CMakeLists.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }} | ||
${{ inputs.restore_key != '' && inputs.restore_key || inputs.key }} | ||
- name: Cache conan | ||
uses: actions/[email protected] | ||
with: | ||
path: ~/.conan2/p | ||
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.developer_mode }}-${{ hashFiles('conanfile.py', 'conanfile.txt') }} | ||
key: ${{ inputs.key }}-${{ hashFiles('conanfile.py', 'conanfile.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }} | ||
${{ inputs.restore_key != '' && inputs.restore_key || inputs.key }} |
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
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 |
---|---|---|
|
@@ -66,52 +66,52 @@ jobs: | |
developer_mode: ON | ||
|
||
include: | ||
# Inject gcov_executable variable | ||
- compiler: llvm | ||
gcov_executable: "llvm-cov gcov" | ||
- compiler: llvm-16.0.6 | ||
gcov_executable: "llvm-cov gcov" | ||
- compiler: gcc-13 | ||
gcov_executable: gcov-13 | ||
|
||
# Enable package for release build | ||
- build_type: Release | ||
developer_mode: OFF | ||
package_generator: ZIP | ||
|
||
steps: | ||
- name: Linux - Maximize build disk space | ||
uses: easimon/maximize-build-space@v10 | ||
if: runner.os == 'Linux' | ||
with: | ||
root-reserve-mb: 30720 | ||
swap-size-mb: 1024 | ||
remove-android: "true" | ||
remove-docker-images: "true" | ||
remove-dotnet: "true" | ||
# Use this if a fairly large library is requried, like building and using llvm as a library. | ||
# - name: Linux - Maximize build disk space | ||
# uses: easimon/maximize-build-space@v10 | ||
# if: runner.os == 'Linux' | ||
# with: | ||
# root-reserve-mb: 30720 | ||
# swap-size-mb: 1024 | ||
# remove-android: "true" | ||
# remove-docker-images: "true" | ||
# remove-dotnet: "true" | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Parse environment | ||
id: parsed | ||
uses: ./.github/actions/parse_environment | ||
with: | ||
os: ${{ matrix.os }} | ||
compiler: ${{ matrix.compiler }} | ||
|
||
- name: Setup cache | ||
uses: ./.github/actions/setup_cache | ||
with: | ||
compiler: ${{ matrix.compiler }} | ||
build_type: ${{ matrix.build_type }} | ||
developer_mode: ${{ matrix.developer_mode }} | ||
key: ${{ steps.parsed.outputs.os_name }}-${{ steps.parsed.outputs.os_version }}-${{ steps.parsed.outputs.compiler_name }}-${{ steps.parsed.outputs.compiler_version }}-${{ matrix.build_type }}-${{ matrix.developer_mode }} | ||
restore_key: ${{ steps.parsed.outputs.os_name }}-${{ steps.parsed.outputs.os_version }}-${{ steps.parsed.outputs.compiler_name }}-${{ steps.parsed.outputs.compiler_version }}-${{ matrix.build_type }} | ||
|
||
- name: Setup cpp | ||
uses: aminya/[email protected] | ||
with: | ||
compiler: ${{ matrix.compiler }} | ||
vcvarsall: ${{ contains(matrix.os, 'windows') }} | ||
vcvarsall: ${{ runner.os == 'Windows' }} | ||
|
||
cmake: true | ||
ninja: true | ||
ccache: true | ||
python: true | ||
|
||
# llvm and clang-tidy version should match according to https://github.com/aminya/setup-cpp/issues/249 | ||
clangtidy: ${{ startsWith(matrix.compiler, 'llvm-') && steps.parsed.outputs.compiler_version || 'true' }} | ||
cppcheck: true | ||
clangtidy: true | ||
|
||
gcovr: 7.2 # The default version 5.2 stucks on macos gcc | ||
opencppcoverage: true | ||
|
@@ -120,44 +120,46 @@ jobs: | |
uses: ./.github/actions/setup_conan | ||
id: conan | ||
with: | ||
os: ${{ matrix.os }} | ||
arch: x86_64 | ||
compiler: ${{ matrix.compiler }} | ||
os_name: ${{ steps.parsed.outputs.os_name }} | ||
os_version: ${{ steps.parsed.outputs.os_version }} | ||
arch: ${{ steps.parsed.outputs.arch }} | ||
compiler_name: ${{ steps.parsed.outputs.compiler_name }} | ||
compiler_version: ${{ steps.parsed.outputs.compiler_version }} | ||
build_type: ${{ matrix.build_type }} | ||
|
||
- name: Configure cmake | ||
run: | | ||
cmake --preset ${{ steps.conan.outputs.compiler_name }} ${{ steps.conan.outputs.compiler_name == 'msvc' && '-A x64 -T v143' || '' }} -D ENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -D OPT_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} | ||
cmake --preset ${{ steps.parsed.outputs.compiler_name }} ${{ steps.parsed.outputs.compiler_name == 'msvc' && '-A x64 -T v143' || '' }} -D ENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -D OPT_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} | ||
- name: Build and test | ||
run: | | ||
conan build . ${{ steps.conan.outputs.args }} | ||
- name: Unix - Coverage | ||
if: runner.os != 'Windows' | ||
working-directory: build/${{ steps.conan.outputs.compiler_name }} | ||
working-directory: build/${{ steps.parsed.outputs.compiler_name }} | ||
run: | | ||
ctest -C ${{ matrix.build_type }} | ||
gcovr -j ${{ env.nproc }} --delete --root ../../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}' | ||
gcovr -j ${{ env.nproc }} --delete --root ../../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ steps.parsed.outputs.gcov_executable }}' | ||
- name: Windows - Coverage | ||
if: runner.os == 'Windows' | ||
working-directory: build/${{ steps.conan.outputs.compiler_name }} | ||
working-directory: build/${{ steps.parsed.outputs.compiler_name }} | ||
run: | | ||
OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{ matrix.build_type }} | ||
- name: Publish to codecov | ||
uses: codecov/[email protected] | ||
with: | ||
files: ./build/${{ steps.conan.outputs.compiler_name }}/coverage.xml | ||
files: ./build/${{ steps.parsed.outputs.compiler_name }}/coverage.xml | ||
flags: ${{ runner.os }} | ||
name: ${{ runner.os }}-coverage | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: true | ||
|
||
- name: CPack | ||
if: matrix.package_generator != '' | ||
working-directory: build/${{ steps.conan.outputs.compiler_name }} | ||
working-directory: build/${{ steps.parsed.outputs.compiler_name }} | ||
run: | | ||
cpack -C ${{ matrix.build_type }} -G ${{ matrix.package_generator }} -B _package -V | ||
|
@@ -166,4 +168,4 @@ jobs: | |
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.package_generator != '' }} | ||
with: | ||
files: | | ||
build/${{ steps.conan.outputs.compiler_name }}/_package/*.* | ||
build/${{ steps.parsed.outputs.compiler_name }}/_package/*.* |
Oops, something went wrong.