Files

385 lines
11 KiB
YAML

version: 2.1
orbs:
codecov: codecov/[email protected]
win: circleci/[email protected]
executors:
linux-gcc-latest:
docker:
- image: ethereum/cpp-build-env:24-gcc-14
linux-clang-latest:
docker:
- image: ethereum/cpp-build-env:24-clang-20
macos:
macos:
xcode: 16.4.0
commands:
install_cmake:
parameters:
version:
type: string
steps:
- run:
name: "Install CMake <<parameters.version>>"
working_directory: /usr/local
command: |
curl -L https://github.com/Kitware/CMake/releases/download/v<<parameters.version>>/cmake-<<parameters.version>>-linux-x86_64.tar.gz | sudo tar -xz --strip=1
install_deps:
description: "Install dependencies"
steps:
- run:
name: "Install dependencies"
command: |
sudo apt -q update
sudo apt install -qy libgmp-dev
install_powerpc64:
steps:
- run:
name: "Install powerpc64 toolchain"
command: |
sudo apt -q update
sudo apt -qy install g++-powerpc64-linux-gnu
check_code_format:
steps:
- run:
name: "Check code format"
command: |
clang-format --version
git ls-files '*.hpp' '*.cpp' '*.h' '*.c' | xargs clang-format -i
git diff --color --exit-code
build_and_test:
description: "Build & Test"
steps:
- run:
name: "Environment"
command: |
CC=${CC:-cc}
CXX=${CXX:-cpp}
echo CC: $CC
echo CXX: $CXX
$CC --version
$CXX --version
cmake --version
- checkout
- run:
name: "Configure"
command: cmake -B ~/build -DCMAKE_COMPILE_WARNING_AS_ERROR=TRUE -DCMAKE_INSTALL_PREFIX=~/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_OPTIONS
- run:
name: "Build"
command: |
cmake --build ~/build --parallel
cmake --build ~/build --target package
- run:
name: "Test"
working_directory: ~/build
command: |
ctest -j4 --output-on-failure --schedule-random -R ${TESTS_FILTER:-'.*'}
- run:
name: "Install"
command: cmake --build ~/build --target install
windows_build_and_test:
description: "Build & Test with MSVC on Windows"
parameters:
arch:
type: string
build_type:
type: string
steps:
- checkout
- run:
name: "Setup environment (bash)"
shell: bash
command: |
echo 'export PATH=$PATH:"/c/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin"' >> $BASH_ENV
- run:
name: 'Configure'
shell: powershell
command: |
$ErrorActionPreference = "Stop"
& 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1' -Arch <<parameters.arch>>
cmake --version
cmake -S . -B ~/build -G Ninja -DCMAKE_COMPILE_WARNING_AS_ERROR=TRUE -DCMAKE_INSTALL_PREFIX=C:\install -DCMAKE_BUILD_TYPE=<<parameters.build_type>> -DHUNTER_CONFIGURATION_TYPES=<<parameters.build_type>> -DINTX_BENCHMARKING=OFF
- run:
name: 'Build'
shell: powershell
command: |
$ErrorActionPreference = "Stop"
& 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1' -Arch <<parameters.arch>>
cmake --build ~/build
- run:
name: 'Test'
shell: powershell
working_directory: ~/build
command: |
$ErrorActionPreference = "Stop"
& 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1' -Arch <<parameters.arch>>
ctest -j4 --output-on-failure --schedule-random
benchmark:
description: "Benchmark"
steps:
- run:
name: "Benchmark"
working_directory: ~/build
command: test/intx-bench --benchmark_min_time=1x
collect_coverage_gcc:
description: "Collect coverage data (GCC)"
steps:
- run:
name: "Collect coverage data (GCC)"
working_directory: ~/build
# Use coveralls to eliminate branch stats (they need more work)
command: |
mkdir -p ~/coverage
gcovr --filter ~/project --coveralls coverage.json --html ~/coverage/coverage.html --html-nested ~/coverage/coverage.html
- store_artifacts:
path: ~/coverage
destination: coverage
upload_coverage:
description: "Upload coverage data"
parameters:
flags:
type: string
steps:
- codecov/upload:
plugins: noop
disable_search: true
files: ../build/coverage.json
flags: <<parameters.flags>>
jobs:
lint:
docker:
- image: ethereum/cpp-build-env:24-lint
steps:
- checkout
- check_code_format
build-minimal:
executor: linux-gcc-latest
steps:
- checkout
- run:
name: "Build package"
command: |
cmake -B ~/build -DCMAKE_COMPILE_WARNING_AS_ERROR=TRUE -DINTX_TESTING=OFF
cmake --build ~/build --target package
- run:
name: "Inspect package"
command: tar tvf ~/build/intx*.tar.gz
- run:
name: "Install conan"
command: |
sudo pip install --break-system-packages conan
conan profile detect
- run:
name: "Build conan package"
command: conan create . -s:a=compiler.cppstd=20
linux-gcc-coverage:
environment:
BUILD_TYPE: Coverage
TESTS_FILTER: unittests
executor: linux-gcc-latest
steps:
- install_deps
- build_and_test
- collect_coverage_gcc
- upload_coverage:
flags: gcc
linux-clang-coverage:
environment:
BUILD_TYPE: Coverage
TESTS_FILTER: unittests
executor: linux-clang-latest
steps:
- install_deps
- build_and_test
- run:
name: "Coverage"
working_directory: ~/build
command: |
mkdir coverage
find -name '*.profraw'
llvm-profdata merge *.profraw -o intx.profdata
llvm-cov report -use-color -instr-profile intx.profdata -Xdemangler llvm-cxxfilt test/intx-unittests
llvm-cov report -instr-profile intx.profdata -Xdemangler llvm-cxxfilt test/intx-unittests > coverage/report.txt
llvm-cov show -format=html -instr-profile intx.profdata -Xdemangler llvm-cxxfilt -region-coverage-lt=100 test/intx-unittests > coverage/missing.html
llvm-cov show -format=html -instr-profile intx.profdata -Xdemangler llvm-cxxfilt test/intx-unittests > coverage/full.html
llvm-cov export -instr-profile intx.profdata -format=lcov test/intx-unittests > coverage.lcov
- store_artifacts:
path: ~/build/coverage
destination: coverage
linux-clang-sanitizers:
environment:
BUILD_TYPE: RelWithDebInfo
CMAKE_OPTIONS: -DSANITIZE=address,undefined,implicit-conversion,nullability -DCMAKE_CXX_CLANG_TIDY=clang-tidy
UBSAN_OPTIONS: halt_on_error=1
executor: linux-clang-latest
steps:
- install_deps
- build_and_test
- benchmark
linux-gcc-sanitizers:
environment:
BUILD_TYPE: RelWithDebInfo
CMAKE_OPTIONS: -DSANITIZE=address,pointer-compare,pointer-subtract,leak,undefined
ASAN_OPTIONS: detect_invalid_pointer_pairs=2
UBSAN_OPTIONS: halt_on_error=1
executor: linux-gcc-latest
steps:
- install_deps
- build_and_test
- benchmark
powerpc64:
environment:
BUILD_TYPE: Release
CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=~/project/cmake/toolchains/powerpc64.cmake -DINTX_BENCHMARKING=OFF
executor: linux-gcc-latest
steps:
- install_powerpc64
- build_and_test
arm64:
environment:
BUILD_TYPE: Release
machine:
image: ubuntu-2204:2023.02.1
resource_class: arm.medium
steps:
- build_and_test
no-exceptions:
environment:
BUILD_TYPE: Release
CMAKE_OPTIONS: -DEXCEPTIONS=OFF -DRTTI=OFF
executor: linux-gcc-latest
steps:
- install_deps
- build_and_test
- benchmark
linux-32bit:
environment:
BUILD_TYPE: Release
CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=~/project/cmake/toolchains/32bit.cmake -DINTX_BENCHMARKING=OFF
docker:
- image: ethereum/cpp-build-env:24-gcc-14-multilib
steps:
- build_and_test
linux-32bit-coverage:
environment:
BUILD_TYPE: Coverage
CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=~/project/cmake/toolchains/32bit.cmake -DINTX_BENCHMARKING=OFF
TESTS_FILTER: unittests
docker:
- image: ethereum/cpp-build-env:24-gcc-14-multilib
steps:
- build_and_test
- collect_coverage_gcc
- upload_coverage:
flags: 32bit
fuzzing:
environment:
- BUILD_TYPE: Release
- CMAKE_OPTIONS: -DINTX_FUZZING=ON
executor: linux-clang-latest
steps:
- install_deps
- build_and_test
- benchmark
- restore_cache:
keys:
- corpus
- run:
name: "Fuzzing"
working_directory: ~/build
command: |
mkdir -p ~/corpus
test/intx-fuzzer ~/corpus -fork=4 -use_value_profile=1 -max_len=129 -runs=1000000
- save_cache:
key: corpus-{{ epoch }}
paths:
- ~/corpus
macos:
environment:
BUILD_TYPE: Release
executor: macos
steps:
- run:
name: "Install deps"
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake gmp
- build_and_test
- benchmark
windows-32bit:
executor: win/server-2022
steps:
- windows_build_and_test:
arch: x86
build_type: Release
windows-debug:
executor: win/server-2022
steps:
- windows_build_and_test:
arch: amd64
build_type: Debug
windows-release:
executor: win/server-2022
steps:
- windows_build_and_test:
arch: amd64
build_type: Release
cmake-min:
docker:
- image: cimg/base:current-22.04
steps:
- install_cmake:
version: 3.16.3
- install_deps
- build_and_test
workflows:
version: 2
intx:
jobs:
- lint
- build-minimal
- linux-gcc-coverage
- linux-clang-coverage
- linux-clang-sanitizers
- linux-gcc-sanitizers
- no-exceptions
- linux-32bit
- linux-32bit-coverage
- fuzzing
- macos
- cmake-min
- arm64
- powerpc64
- windows-32bit
- windows-debug
- windows-release