diff --git a/.github/workflows/clang-linux-nix-check.yml b/.github/workflows/clang-linux-nix-check.yml index 43f37fa63f..cf112ad928 100644 --- a/.github/workflows/clang-linux-nix-check.yml +++ b/.github/workflows/clang-linux-nix-check.yml @@ -18,7 +18,19 @@ jobs: fetch-depth: 0 - name: Run checks - run: nix build -L .?#checks.x86_64-linux.all-clang + run: | + nix build -L .?#checks.x86_64-linux.all-clang + mkdir results + cp result/test-logs/*_test.xml results/ env: NIX_CONFIG: | cores = 4 + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + with: + check_name: "Clang Test Results" + files: "results/*.xml" + comment_mode: ${{ github.event.pull_request.head.repo.fork && 'off' || 'always' }} # Don't create PR comment from fork runs + action_fail_on_inconclusive: true # fail, if no reports + diff --git a/.github/workflows/gcc-linux-nix-check.yml b/.github/workflows/gcc-linux-nix-check.yml index 43af748ee2..e6394c0c05 100644 --- a/.github/workflows/gcc-linux-nix-check.yml +++ b/.github/workflows/gcc-linux-nix-check.yml @@ -18,7 +18,19 @@ jobs: fetch-depth: 0 - name: Run checks - run: nix build -L .?#checks.x86_64-linux.all-gcc + run: | + nix build -L .?#checks.x86_64-linux.all-gcc + mkdir results + cp result/test-logs/*_test.xml results/ env: NIX_CONFIG: | cores = 4 + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + with: + check_name: "Gcc Test Results" + files: "results/*.xml" + comment_mode: ${{ github.event.pull_request.head.repo.fork && 'off' || 'always' }} # Don't create PR comment from fork runs + action_fail_on_inconclusive: true # fail, if no reports + diff --git a/crypto3/CMakeLists.txt b/crypto3/CMakeLists.txt index 442ea362f0..f2a775346f 100644 --- a/crypto3/CMakeLists.txt +++ b/crypto3/CMakeLists.txt @@ -21,11 +21,17 @@ option(Boost_USE_STATIC_LIBS "Use static libraries for Boost" OFF) option(CMAKE_ENABLE_TESTS "Enable tests" FALSE) # used by CMTest module option(BUILD_BENCH_TESTS "Build performance benchmark tests" FALSE) option(BUILD_DOCS "Build with configuring Doxygen documentation compiler" FALSE) +option(SANITIZE "Build sanitizers" FALSE) if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_CXX_FLAGS "-ggdb -O0") endif() +if(${SANITIZE}) + add_compile_options(-fsanitize=undefined,address,leak) + add_link_options(-fsanitize=undefined,address,leak) +endif() + # This is useful due to some build systems (Ninja in particular) are piping # compiler output and compiler switches it's output to plain text option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE) diff --git a/crypto3/crypto3.nix b/crypto3/crypto3.nix index ce093e40d4..7494015b8b 100644 --- a/crypto3/crypto3.nix +++ b/crypto3/crypto3.nix @@ -9,6 +9,7 @@ enableDebugging, enableDebug ? false, runTests ? false, + sanitize ? false, }: let inherit (lib) optional; @@ -28,11 +29,20 @@ in stdenv.mkDerivation { [ (if runTests then "-DBUILD_TESTS=TRUE" else "-DBUILD_TESTS=False") (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") + (if sanitize then "-DSANITIZE=ON" else "-DSANITIZE=OFF") "-G Ninja" ]; doCheck = runTests; # tests are inside crypto3-tests derivation + checkPhase = '' + # JUNIT file without explicit file name is generated after the name of the master test suite inside `CMAKE_CURRENT_SOURCE_DIR` + export BOOST_TEST_LOGGER=JUNIT:HRF + ctest --verbose --output-on-failure -R + mkdir -p ${placeholder "out"}/test-logs + find .. -type f -name '*_test.xml' -exec cp {} ${placeholder "out"}/test-logs \; + ''; + shellHook = '' PS1="\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ " echo "Welcome to Crypto3 development environment!" diff --git a/flake.nix b/flake.nix index 6741d0f3d3..18d12df041 100644 --- a/flake.nix +++ b/flake.nix @@ -34,6 +34,11 @@ enableDebug = true; runTests = true; }); + crypto3-sanitize = (pkgs.callPackage ./crypto3/crypto3.nix { + enableDebug = true; + runTests = true; + sanitize = true; + }); parallel-crypto3 = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { runTests = false; @@ -145,6 +150,12 @@ runTests = true; enableDebug = false; }); + crypto3-clang-sanitize = (pkgs.callPackage ./crypto3/crypto3.nix { + stdenv = pkgs.llvmPackages_18.stdenv; + runTests = true; + enableDebug = false; + sanitize = true; + }); parallel-crypto3-gcc = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { runTests = true; @@ -209,6 +220,10 @@ name = "all"; paths = [ crypto3-clang parallel-crypto3-clang evm-assigner-clang transpiler-clang proof-producer-clang ]; }; + all-sanitizers = pkgs.symlinkJoin { + name = "all"; + paths = [ crypto3-clang-sanitize ]; + }; all-gcc = pkgs.symlinkJoin { name = "all"; paths = [ crypto3-gcc parallel-crypto3-gcc evm-assigner-gcc zkevm-framework-gcc transpiler-gcc proof-producer-gcc ];