Skip to content

perf: optimize cpp target generation #668

perf: optimize cpp target generation

perf: optimize cpp target generation #668

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches:
- master
- beta
- alpha
- +([0-9])?(.{+([0-9]),x}).x
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: 3.11
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --hook-stage manual --all-files
consistency:
if: ${{ !cancelled() && ! failure() }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: 3.11
- name: Install copier
run: |
pip install pyyaml-include==1.4.1
pip install copier==9.1.0
- name: Generate the project with the default value
run: |
find . -maxdepth 1 ! -name '.' \
! -name 'template' \
! -name 'includes' \
! -name '.git' \
! -name 'copier.yml' \
-exec rm -r {} +
copier copy -r HEAD -f . .
rm .copier-answers.yml
- name: Test for consistency
run: |
echo "List inconsistent files:"
git status --porcelain
git diff --exit-code || ( \
echo "# :warning: Inconsistent files found" >> $GITHUB_STEP_SUMMARY && \
echo "The following files are inconsistent with the template:" >> $GITHUB_STEP_SUMMARY && \
git status --porcelain | while read file; do echo "- $file"; done >> $GITHUB_STEP_SUMMARY && \
echo "" >> $GITHUB_STEP_SUMMARY && \
echo "Please run 'copier copy -r HEAD -f . .' to fix them." >>$GITHUB_STEP_SUMMARY && \
exit 1 \
)
check-on-linux:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
triplet: [x64-linux]
compiler: [gcc-13, llvm-17]
std: [20]
build_type: [Debug, RelWithDebInfo]
name: check • ${{ matrix.triplet }} • ${{ matrix.compiler }} • c++${{ matrix.std }} • ${{ matrix.build_type }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
key: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
restore-keys: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
cmake: true
ninja: true
ccache: true
cppcheck: true
- name: Prepare for lcov
if: contains(matrix.compiler, 'gcc')
run: |
sudo apt-get update; sudo apt-get install lcov -y
gcc_compiler=${{ matrix.compiler }}
gcov_version=${gcc_compiler##*-}
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-$gcov_version 100
- name: Prepare for llvm-cov
if: contains(matrix.compiler, 'llvm')
run: |
llvm_compiler=${{ matrix.compiler }}
llvm_cov_version=${llvm_compiler##*-}
sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-$llvm_cov_version 100
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_STANDARD=${{ matrix.std }}
-DCMAKE_C_COMPILER=${{ contains(matrix.compiler, 'gcc') && 'gcc' || contains(matrix.compiler, 'llvm') && 'clang' }}
-DCMAKE_CXX_COMPILER=${{ contains(matrix.compiler, 'gcc') && 'g++' || contains(matrix.compiler, 'llvm') && 'clang++' }}
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DCODE_COVERAGE=ON
-DBUILD_TESTING=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
- name: Coverage
run: cmake --build out/build/default --target ccov-all
check-on-macos:
runs-on: macos-12
needs: [pre-commit, consistency]
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
triplet: [x64-osx]
compiler: [gcc-13, llvm@17]
std: [20]
build_type: [Debug, RelWithDebInfo]
name: check • ${{ matrix.triplet }} • ${{ matrix.compiler }} • c++${{ matrix.std }} • ${{ matrix.build_type }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
key: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
restore-keys: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: ${{ contains(matrix.compiler, 'gcc') && matrix.compiler || '' }}
cmake: true
ninja: true
ccache: true
cppcheck: true
- name: Install llvm through brew
if: contains(matrix.compiler, 'llvm')
run: |
brew install ${{ matrix.compiler }}
echo "CC=/usr/local/opt/${{ matrix.compiler }}/bin/clang" >> $GITHUB_ENV
echo "CXX=/usr/local/opt/${{ matrix.compiler }}/bin/clang++" >> $GITHUB_ENV
echo "PATH=/usr/local/opt/llvm/bin:$PATH" >> $GITHUB_ENV
- name: Prepare for lcov
if: contains(matrix.compiler, 'gcc')
run: |
curl -o /tmp/lcov.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/e92d2ae54954ebf485b484d8522104700b144fee/Formula/lcov.rb
HOMEBREW_NO_AUTO_UPDATE=1 brew install --formula /tmp/lcov.rb
brew pin lcov
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_STANDARD=${{ matrix.std }}
-DCMAKE_C_COMPILER="${CC}"
-DCMAKE_CXX_COMPILER="${CXX}"
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DCODE_COVERAGE=ON
-DBUILD_TESTING=ON
${{ contains(matrix.compiler, 'gcc') && '-DCODE_COVERAGE_GCOV=${GCOV}' }}
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
- name: Coverage
run: cmake --build out/build/default --target ccov-all
check-on-windows:
runs-on: windows-2022
needs: [pre-commit, consistency]
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
triplet: [x64-windows]
compiler: [msvc-2022, llvm-17]
std: [20]
build_type: [Debug, RelWithDebInfo]
name: check • ${{ matrix.triplet }} • ${{ matrix.compiler }} • c++${{ matrix.std }} • ${{ matrix.build_type }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
~/AppData/Local/vcpkg
key: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
restore-keys: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: true
cmake: true
ninja: true
ccache: true
opencppcoverage: true
- name: Configure CMake
run: >
cmake -S . --preset=default ${{ contains(matrix.compiler, 'llvm') && '-DVCPKG_PLATFORM_TOOLSET=ClangCL' || '' }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_STANDARD=${{ matrix.std }}
-DCMAKE_C_COMPILER=${{ contains(matrix.compiler, 'msvc') && '"cl"' || contains(matrix.compiler, 'llvm') && '"clang-cl.exe"' }}
-DCMAKE_CXX_COMPILER=${{ contains(matrix.compiler, 'msvc') && '"cl"' || contains(matrix.compiler, 'llvm') && '"clang-cl.exe"' }}
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DUSE_SANITIZER=${{ contains(matrix.compiler, 'llvm') && 'OFF' || 'ON' }}
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DCODE_COVERAGE=ON
-DBUILD_TESTING=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
- name: Coverage
run: cmake --build out/build/default --target ccov-all
check-mingw:
runs-on: windows-2022
needs: [pre-commit, consistency]
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
triplet: [x64-mingw-dynamic]
compiler: [mingw]
std: [20]
build_type: [Debug, RelWithDebInfo]
name: check • ${{ matrix.triplet }} • ${{ matrix.compiler }} • c++${{ matrix.std }} • ${{ matrix.build_type }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/pip
~/.cache/vcpkg
~/AppData/Local/vcpkg
key: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
restore-keys: ${{ matrix.triplet }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
cmake: true
ninja: true
ccache: true
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: 3.x
- name: Install docs dependencies
run: |
pip install gcovr==7.2
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_STANDARD=${{ matrix.std }}
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DUSE_SANITIZER=OFF
-DVCPKG_TARGET_TRIPLET=x64-mingw-dynamic
-DCODE_COVERAGE=ON
-DBUILD_TESTING=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
- name: Coverage
run: cmake --build out/build/default --target ccov-all
check-docs:
name: Docs build and checks
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/pip
~/.cache/vcpkg
key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: gcc-13
cmake: true
ninja: true
ccache: true
doxygen: true
graphviz: true
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: 3.x
- name: Install docs dependencies
run: |
pip install -r docs/requirements.txt
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DCMAKE_CXX_STANDARD=20
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DVCPKG_TARGET_TRIPLET=x64-linux
-DUSE_SANITIZER=OFF
-DCODE_COVERAGE=OFF
-DBUILD_TESTING=OFF
- name: Checks the docs with warnings as errors
run: cmake --build out/build/default --target ss-cpp-docs-check
- name: Checks the docs for broken links
run: cmake --build out/build/default --target ss-cpp-docs-linkcheck
codecov:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: gcc-13
cmake: true
ninja: true
ccache: true
cppcheck: true
- name: Prepare for lcov
run: |
sudo apt-get update; sudo apt-get install lcov -y
gcc_compiler=gcc-13
gcov_version=${gcc_compiler##*-}
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-$gcov_version 100
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_STANDARD=20
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DVCPKG_TARGET_TRIPLET=x64-linux
-DCODE_COVERAGE=ON
-DBUILD_TESTING=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Coverage
run: cmake --build out/build/default --target ccov-all
- name: Upload coverage report
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: out/build/default/code_coverage
files: ./coverage.info
check-export-mode:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: gcc-13
cmake: true
ninja: true
ccache: true
cppcheck: true
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_STANDARD=20
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DVCPKG_TARGET_TRIPLET=x64-linux
-DCODE_COVERAGE=OFF
-DBUILD_TESTING=ON
-DVCPKG_EXPORT_MODE=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
check-auto-vcpkg-install:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: gcc-13
cmake: true
ninja: true
ccache: true
cppcheck: true
- name: Disable preinstalled vcpkg in the runner to test vcpkg automatic installation
run: echo "VCPKG_INSTALLATION_ROOT=" >> $GITHUB_ENV
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_STANDARD=20
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DVCPKG_TARGET_TRIPLET=x64-linux
-DCODE_COVERAGE=OFF
-DBUILD_TESTING=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
check-auto-detect-triplet:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: gcc-13
cmake: true
ninja: true
ccache: true
cppcheck: true
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_STANDARD=20
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DCODE_COVERAGE=OFF
-DBUILD_TESTING=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
check-auto-build-type:
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/vcpkg
key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: gcc-13
cmake: true
ninja: true
ccache: true
cppcheck: true
- name: Configure CMake
run: >
cmake -S . --preset=default
-DCMAKE_CXX_STANDARD=20
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DVCPKG_TARGET_TRIPLET=x64-linux
-DCODE_COVERAGE=OFF
-DBUILD_TESTING=ON
- name: Build
run: cmake --build out/build/default --target all
- name: Test
run: cmake --build out/build/default --target test
- name: Install
run: cmake --build out/build/default --target install
- name: Uninstall
run: cmake --build out/build/default --target uninstall
pass:
if: always()
needs: [check-on-linux, check-on-macos, check-on-windows, check-mingw, check-docs, codecov, check-export-mode, check-auto-vcpkg-install, check-auto-detect-triplet, check-auto-build-type]
runs-on: ubuntu-22.04
timeout-minutes: 2
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
release:
name: release
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request'
permissions:
contents: write
id-token: write
issues: write
pull-requests: write
needs: [pass]
steps:
- name: Generate a bot token with BOT_APP_ID
id: bot_token
if: vars.BOT_APP_ID && env.BOT_PRIVATE_KEY != null
uses: actions/create-github-app-token@7bfa3a4717ef143a604ee0a99d859b8886a96d00 # v1
env:
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
with:
app-id: ${{ vars.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Warn if use GITHUB_TOKEN
if: env._GITHUB_TOKEN == env._TO_BE_VERIFIED_TOKEN
env:
_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
_TO_BE_VERIFIED_TOKEN: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}
run: |
echo "# :warning: GITHUB_TOKEN is used" >> $GITHUB_STEP_SUMMARY
echo "The GITHUB_TOKEN is used instead of a bot token or PAT that will not emit the released publish event for triggering a released workflow." >> $GITHUB_STEP_SUMMARY
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
token: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 20
- uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
semantic_version: 22
extra_plugins: |
@semantic-release/exec
@semantic-release/github
conventional-changelog-conventionalcommits
env:
GITHUB_TOKEN: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}