From 0c2b518b945e9c1069a1334466032601fcb42a54 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Tue, 3 Sep 2024 13:17:35 +0200 Subject: [PATCH 1/4] add ci --- .github/workflows/linux-nix-check.yml | 24 +++++++++++++++++++++ .github/workflows/mac-nix-check.yml | 26 +++++++++++++++++++++++ .github/workflows/pull-request.yml | 30 +++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 .github/workflows/linux-nix-check.yml create mode 100644 .github/workflows/mac-nix-check.yml create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/linux-nix-check.yml b/.github/workflows/linux-nix-check.yml new file mode 100644 index 0000000000..147f7fc2dd --- /dev/null +++ b/.github/workflows/linux-nix-check.yml @@ -0,0 +1,24 @@ +name: Build and Test on Linux Platforms + +on: + workflow_call: + +jobs: + build-and-test: + name: "Build and test Linux" + runs-on: [self-hosted, Linux, X64, aws_autoscaling] + steps: + # https://github.com/actions/checkout/issues/1552 + - name: Clean up after previous checkout + run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*; + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run checks + run: nix flake -L check + env: + NIX_CONFIG: | + cores = 6 diff --git a/.github/workflows/mac-nix-check.yml b/.github/workflows/mac-nix-check.yml new file mode 100644 index 0000000000..99fb449563 --- /dev/null +++ b/.github/workflows/mac-nix-check.yml @@ -0,0 +1,26 @@ +name: Crypto3 Build and Test on macOS Platforms + +on: + workflow_call: + +jobs: + build-and-test: + name: "Build and test macOS" + runs-on: [macos-14] + steps: + - name: Checkout Crypto3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # From https://github.com/DeterminateSystems/magic-nix-cache-action + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: DeterminateSystems/flake-checker-action@main + + - name: Run checks + run: nix flake -L check + env: + NIX_CONFIG: | + cores = 0 + max-jobs = 1 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000000..950321c399 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,30 @@ +name: PR Testing + +on: + pull_request: + push: + branches: + - master + +concurrency: + # In master we want to run for every commit, in other branches — only for the last one + group: ${{ + ( github.ref == 'refs/heads/master' && format('{0}/{1}/{2}', github.workflow, github.ref, github.sha) ) + || + format('{0}/{1}', github.workflow, github.ref) }} + cancel-in-progress: true + +jobs: + test-linux: + name: Linux Crypto3 Testing + uses: ./.github/workflows/linux-nix-check.yml + if: | + always() && !cancelled() + secrets: inherit + + test-mac: + name: macOS Crypto3 Testing + uses: ./.github/workflows/mac-nix-check.yml + if: | + always() && !cancelled() + secrets: inherit From 9fe40a037e4ed808d4c3cbcef4a65131f4e81bb0 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Tue, 3 Sep 2024 18:07:33 +0200 Subject: [PATCH 2/4] Implement placeholder CI --- .github/workflows/linux-nix-check.yml | 4 +- .github/workflows/mac-nix-check.yml | 2 +- crypto3/crypto3.nix | 9 +- crypto3/flake.lock | 84 ------------- crypto3/flake.nix | 59 ---------- .../test/verifiers/placeholder/verifier.cpp | 1 + .../blueprint/test/zkevm/opcodes/iszero.cpp | 3 +- .../libs/blueprint/test/zkevm/opcodes/mul.cpp | 5 +- .../libs/containers/test/merkle/merkle.cpp | 13 +- crypto3/libs/hash/test/crc.cpp | 14 +-- crypto3/libs/hash/test/tiger.cpp | 14 +-- .../curve_element_fixed_size_container.cpp | 1 + crypto3/libs/random/test/rfc6979.cpp | 1 + evm-assigner/flake.lock | 111 ------------------ evm-assigner/flake.nix | 80 ------------- .../lib/assigner/evmone/instructions.hpp | 3 +- .../lib/assigner/test/assigner_test.cpp | 1 + flake.lock | 6 +- flake.nix | 55 +++++++-- 19 files changed, 88 insertions(+), 378 deletions(-) delete mode 100644 crypto3/flake.lock delete mode 100644 crypto3/flake.nix delete mode 100644 evm-assigner/flake.lock delete mode 100644 evm-assigner/flake.nix diff --git a/.github/workflows/linux-nix-check.yml b/.github/workflows/linux-nix-check.yml index 147f7fc2dd..87eb515db4 100644 --- a/.github/workflows/linux-nix-check.yml +++ b/.github/workflows/linux-nix-check.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 0 - name: Run checks - run: nix flake -L check + run: nix build -L .?#checks.x86_64-linux.all-gcc env: NIX_CONFIG: | - cores = 6 + cores = 4 diff --git a/.github/workflows/mac-nix-check.yml b/.github/workflows/mac-nix-check.yml index 99fb449563..ff90d4bc42 100644 --- a/.github/workflows/mac-nix-check.yml +++ b/.github/workflows/mac-nix-check.yml @@ -19,7 +19,7 @@ jobs: - uses: DeterminateSystems/flake-checker-action@main - name: Run checks - run: nix flake -L check + run: nix build -L .?checks.aarch64-darwin.all-gcc env: NIX_CONFIG: | cores = 0 diff --git a/crypto3/crypto3.nix b/crypto3/crypto3.nix index ea2394e694..c6a05331fc 100644 --- a/crypto3/crypto3.nix +++ b/crypto3/crypto3.nix @@ -3,13 +3,11 @@ ninja, pkg-config, cmake, - boost183, - # We'll use boost183 by default, but you can override it - boost_lib ? boost183, + boost, gdb, cmake_modules, enableDebugging, - enableDebug ? true, + enableDebug ? false, runTests ? false, }: let @@ -22,7 +20,7 @@ in stdenv.mkDerivation { nativeBuildInputs = [ cmake ninja pkg-config ] ++ (lib.optional (!stdenv.isDarwin) gdb); # enableDebugging will keep debug symbols in boost - propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost_lib) else boost_lib) ]; + propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost) else boost) ]; buildInputs = [cmake_modules]; @@ -33,6 +31,7 @@ in stdenv.mkDerivation { (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") (if enableDebug then "-DCMAKE_CXX_FLAGS=-ggdb" else "") (if enableDebug then "-DCMAKE_CXX_FLAGS=-O0" else "") + "-G Ninja" ]; doCheck = runTests; # tests are inside crypto3-tests derivation diff --git a/crypto3/flake.lock b/crypto3/flake.lock deleted file mode 100644 index 0f8cdca1ac..0000000000 --- a/crypto3/flake.lock +++ /dev/null @@ -1,84 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nix-3rdparty": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1717519917, - "narHash": "sha256-GqzEqEW4Uz9Z7uDZwers0t9seWRNbRWPNE3OJnjE1Uw=", - "owner": "NilFoundation", - "repo": "nix-3rdparty", - "rev": "a2e45429aa25a4a6e8e362ef17df6f197312f224", - "type": "github" - }, - "original": { - "owner": "NilFoundation", - "repo": "nix-3rdparty", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1720038964, - "narHash": "sha256-im/eyMVgBg5ZXT3QxyE9TM534OG0+D8CtiFbMrf0GpY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "26d9cafa3461c8ec55a6aa7e76ec0f8db0737ff9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nix-3rdparty": "nix-3rdparty", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/crypto3/flake.nix b/crypto3/flake.nix deleted file mode 100644 index 973f5e4dc5..0000000000 --- a/crypto3/flake.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ - description = - "Nix flake for Crypto3 header-only C++ library by Nil; Foundation"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs"; - flake-utils.url = "github:numtide/flake-utils"; - nix-3rdparty = { - url = "github:NilFoundation/nix-3rdparty"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; - }; - }; - - outputs = { self, nixpkgs, flake-utils, nix-3rdparty, ... }: - (flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ nix-3rdparty.overlays.${system}.default ]; - }; - in { - packages = rec { - crypto3 = (pkgs.callPackage ./crypto3.nix { src_repo = self; }); - crypto3-debug = (pkgs.callPackage ./crypto3.nix { - src_repo = self; - enableDebug = true; - }); - crypto3-debug-tests = (pkgs.callPackage ./crypto3.nix { - src_repo = self; - enableDebug = true; - runTests = true; - }); - default = crypto3-debug-tests; - }; - checks = rec { - gcc = (pkgs.callPackage ./crypto3.nix { - src_repo = self; - runTests = true; - }); - clang = (pkgs.callPackage ./crypto3.nix { - stdenv = pkgs.llvmPackages_18.stdenv; - src_repo = self; - runTests = true; - }); - all = pkgs.symlinkJoin { - name = "all"; - paths = [ gcc clang ]; - }; - default = all; - }; - })); -} - -# `nix flake -L check` to run all tests (-L to output build logs) -# `nix flake show` to show derivations tree -# If build fails due to OOM, run `export NIX_CONFIG="cores = 2"` to set desired parallel level diff --git a/crypto3/libs/blueprint/test/verifiers/placeholder/verifier.cpp b/crypto3/libs/blueprint/test/verifiers/placeholder/verifier.cpp index 9e2f757347..535e95cc23 100644 --- a/crypto3/libs/blueprint/test/verifiers/placeholder/verifier.cpp +++ b/crypto3/libs/blueprint/test/verifiers/placeholder/verifier.cpp @@ -25,6 +25,7 @@ #include #include +#include #include diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/iszero.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/iszero.cpp index 8ae2fbd3ea..2b84114ba1 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/iszero.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/iszero.cpp @@ -26,6 +26,7 @@ #include +#include #include #include @@ -34,8 +35,6 @@ #include #include "../opcode_tester.hpp" -#include - using namespace nil::blueprint; using namespace nil::crypto3::algebra; diff --git a/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp b/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp index 4f7fa4a0af..2858049a28 100644 --- a/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp +++ b/crypto3/libs/blueprint/test/zkevm/opcodes/mul.cpp @@ -33,10 +33,11 @@ #include #include -#include "../opcode_tester.hpp" - +#include #include +#include "../opcode_tester.hpp" + using namespace nil::blueprint; using namespace nil::crypto3::algebra; diff --git a/crypto3/libs/containers/test/merkle/merkle.cpp b/crypto3/libs/containers/test/merkle/merkle.cpp index f3d8dc2d5d..7db3a093f4 100644 --- a/crypto3/libs/containers/test/merkle/merkle.cpp +++ b/crypto3/libs/containers/test/merkle/merkle.cpp @@ -26,6 +26,12 @@ #define BOOST_TEST_MODULE containter_merkletree_test +#include +#include +#include +#include +#include + #include #include #include @@ -35,6 +41,7 @@ #include #include #include +#include #include #include @@ -43,12 +50,6 @@ #include #include -#include -#include -#include -#include -#include - using namespace nil::crypto3; using namespace nil::crypto3::containers; diff --git a/crypto3/libs/hash/test/crc.cpp b/crypto3/libs/hash/test/crc.cpp index 8258c917a5..b057e61be9 100644 --- a/crypto3/libs/hash/test/crc.cpp +++ b/crypto3/libs/hash/test/crc.cpp @@ -8,8 +8,13 @@ #define BOOST_TEST_MODULE crc_test -#include +#include +#include +#include +#include +#include +#include #include #include @@ -19,11 +24,6 @@ #include #include -#include -#include -#include -#include - using namespace nil::crypto3; using namespace nil::crypto3::hashes; using namespace nil::crypto3::accumulators; @@ -130,4 +130,4 @@ BOOST_AUTO_TEST_CASE(crc_stateful_hash3) { BOOST_CHECK_EQUAL(d, "a7943e77"); } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/crypto3/libs/hash/test/tiger.cpp b/crypto3/libs/hash/test/tiger.cpp index 54c5dad6c6..cbc1a69469 100644 --- a/crypto3/libs/hash/test/tiger.cpp +++ b/crypto3/libs/hash/test/tiger.cpp @@ -25,6 +25,12 @@ #define BOOST_TEST_MODULE tiger_test +#include +#include +#include +#include +#include + #include #include @@ -39,12 +45,6 @@ #include -#include -#include -#include - -#include - using namespace nil::crypto3; using namespace nil::crypto3::accumulators; @@ -155,4 +155,4 @@ BOOST_AUTO_TEST_CASE(tiger_iterator_hash7) { BOOST_CHECK_EQUAL("1c14795529fd9f207a958f84c52f11e887fa0cabdfd91bfd", out); } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/crypto3/libs/marshalling/algebra/test/curve_element_fixed_size_container.cpp b/crypto3/libs/marshalling/algebra/test/curve_element_fixed_size_container.cpp index d94c0cf3f5..f08df42607 100644 --- a/crypto3/libs/marshalling/algebra/test/curve_element_fixed_size_container.cpp +++ b/crypto3/libs/marshalling/algebra/test/curve_element_fixed_size_container.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/crypto3/libs/random/test/rfc6979.cpp b/crypto3/libs/random/test/rfc6979.cpp index baf665545f..d69bdceca2 100644 --- a/crypto3/libs/random/test/rfc6979.cpp +++ b/crypto3/libs/random/test/rfc6979.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include diff --git a/evm-assigner/flake.lock b/evm-assigner/flake.lock deleted file mode 100644 index 295daa4406..0000000000 --- a/evm-assigner/flake.lock +++ /dev/null @@ -1,111 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nil-crypto3": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nix-3rdparty": [ - "nix-3rdparty" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1724068894, - "narHash": "sha256-sTg66s+8BlhKs5HmnEJFw5hjwi8+dEXMFGwU4aS3juM=", - "ref": "refs/heads/master", - "rev": "e4772b04564ef76c413136d3798c6caf7d99e195", - "revCount": 10446, - "type": "git", - "url": "https://github.com/NilFoundation/crypto3" - }, - "original": { - "type": "git", - "url": "https://github.com/NilFoundation/crypto3" - } - }, - "nix-3rdparty": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1721822436, - "narHash": "sha256-AQidmv80fA72FFHgyjCq9Psc04w9aaHedJpoVgnLb6M=", - "owner": "NilFoundation", - "repo": "nix-3rdparty", - "rev": "d14a2a3c4b9498b297400b225fc09570bfe0a9a1", - "type": "github" - }, - "original": { - "owner": "NilFoundation", - "repo": "nix-3rdparty", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1724099983, - "narHash": "sha256-KUCIVWPXs+F1Elzwczns/arptrLTiB0FyjeTNTLiRFQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "975ba1bed8410267a8866f26f6d79af8d9232aee", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nil-crypto3": "nil-crypto3", - "nix-3rdparty": "nix-3rdparty", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/evm-assigner/flake.nix b/evm-assigner/flake.nix deleted file mode 100644 index 9e508cacbe..0000000000 --- a/evm-assigner/flake.nix +++ /dev/null @@ -1,80 +0,0 @@ -{ - description = "Nix flake for evm-assigner"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs"; - flake-utils.url = "github:numtide/flake-utils"; - nix-3rdparty = { - url = "github:NilFoundation/nix-3rdparty"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; - }; - nil-crypto3 = { - url = "https://github.com/NilFoundation/crypto3"; - type = "git"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - nix-3rdparty.follows = "nix-3rdparty"; - }; - }; - }; - - outputs = { self, nixpkgs, nil-crypto3, flake-utils, nix-3rdparty }: - (flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - stdenv = pkgs.llvmPackages_16.stdenv; - crypto3 = nil-crypto3.packages.${system}.crypto3; - intx = nix-3rdparty.packages.${system}.intx; - - in { - packages = rec { - evm-assigner = (pkgs.callPackage ./evm-assigner.nix { - src_repo = self; - crypto3 = crypto3; - intx = intx; - }); - evm-assigner-debug = (pkgs.callPackage ./evm-assigner.nix { - src_repo = self; - crypto3 = crypto3; - intx = intx; - enableDebug = true; - }); - evm-assigner-debug-tests = (pkgs.callPackage ./evm-assigner.nix { - src_repo = self; - crypto3 = crypto3; - intx = intx; - enableDebug = true; - runTests = true; - }); - default = evm-assigner-debug-tests; - }; - checks = rec { - gcc = (pkgs.callPackage ./evm-assigner.nix { - src_repo = self; - crypto3 = crypto3; - intx = intx; - runTests = true; - }); - clang = (pkgs.callPackage ./evm-assigner.nix { - stdenv = pkgs.llvmPackages_18.stdenv; - src_repo = self; - crypto3 = crypto3; - intx = intx; - runTests = true; - }); - all = pkgs.symlinkJoin { - name = "all"; - paths = [ gcc clang ]; - }; - default = all; - }; - })); -} - -# `nix flake -L check` to run all tests (-L to output build logs) -# `nix flake show` to show derivations tree -# If build fails due to OOM, run `export NIX_CONFIG="cores = 2"` to set desired parallel level diff --git a/evm-assigner/lib/assigner/evmone/instructions.hpp b/evm-assigner/lib/assigner/evmone/instructions.hpp index 8990cad666..f5402e16f9 100644 --- a/evm-assigner/lib/assigner/evmone/instructions.hpp +++ b/evm-assigner/lib/assigner/evmone/instructions.hpp @@ -3,12 +3,13 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#include +#include #include "eof.hpp" #include "execution_state.hpp" #include "instructions_traits.hpp" #include "instructions_xmacro.hpp" #include -#include namespace evmone { diff --git a/evm-assigner/lib/assigner/test/assigner_test.cpp b/evm-assigner/lib/assigner/test/assigner_test.cpp index 6d9d60a703..2f0bc39ec0 100644 --- a/evm-assigner/lib/assigner/test/assigner_test.cpp +++ b/evm-assigner/lib/assigner/test/assigner_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/flake.lock b/flake.lock index 135cede629..9b7fd0396f 100644 --- a/flake.lock +++ b/flake.lock @@ -43,11 +43,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725283960, - "narHash": "sha256-oPBXLsHf6017Nvx5+VDh0Wc1gF5tE0SRQDw7+FPLrbM=", + "lastModified": 1725384028, + "narHash": "sha256-PZWvS483pAZAVKBrS/caLZYQAlHwOKrP72w2UejfMdg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "afefcacba65525aac7f9d1009c9666f76aac227f", + "rev": "0bf3a8e9889cd7b430d2416d606beda9d333b5d7", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c775a92dcf..4b4c886045 100644 --- a/flake.nix +++ b/flake.nix @@ -23,34 +23,73 @@ in { packages = rec { crypto3 = (pkgs.callPackage ./crypto3/crypto3.nix { }); + crypto3-tests = (pkgs.callPackage ./crypto3/crypto3.nix { + runTests = true; + enableDebug = false; + }); + crypto3-debug-tests = (pkgs.callPackage ./crypto3/crypto3.nix { + enableDebug = true; + runTests = true; + }); + evm-assigner = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { crypto3 = crypto3; + enableDebug = false; + }); + evm-assigner-tests = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + runTests = true; + enableDebug = false; + crypto3 = crypto3; + }); + evm-assigner-debug-tests = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + enableDebug = true; + runTests = true; + crypto3 = crypto3; }); # The "all" package will build all packages. Convenient for CI, # so that "nix build" will check that all packages are correct. # The packages that have no changes will not be rebuilt, and instead # fetched from the cache. - #all = pkgs.symlinkJoin { - # name = "all"; - # paths = [ crypto3 parallel-crypto3 ]; - #}; - default = crypto3; #TODO + all = pkgs.symlinkJoin { + name = "all"; + paths = [ crypto3 evm-assigner ]; + }; + default = all; }; checks = rec { crypto3-gcc = (pkgs.callPackage ./crypto3/crypto3.nix { runTests = true; + enableDebug = false; }); crypto3-clang = (pkgs.callPackage ./crypto3/crypto3.nix { stdenv = pkgs.llvmPackages_18.stdenv; runTests = true; + enableDebug = false; }); - all = pkgs.symlinkJoin { + + evm-assigner-gcc = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + runTests = true; + enableDebug = false; + crypto3 = crypto3-gcc; + }); + evm-assigner-clang = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + stdenv = pkgs.llvmPackages_18.stdenv; + runTests = true; + enableDebug = false; + crypto3 = crypto3-clang; + }); + + all-clang = pkgs.symlinkJoin { + name = "all"; + paths = [ crypto3-clang evm-assigner-clang ]; + }; + all-gcc = pkgs.symlinkJoin { name = "all"; - paths = [ crypto3-gcc crypto3-clang]; + paths = [ crypto3-gcc evm-assigner-gcc ]; }; - default = all; + default = all-gcc; }; })); } From d1b7165714429a769b69a9942e9ef74bb45e3a05 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Wed, 4 Sep 2024 14:42:02 +0200 Subject: [PATCH 3/4] remove mac build --- .github/workflows/mac-nix-check.yml | 26 -------------------------- .github/workflows/pull-request.yml | 6 ------ 2 files changed, 32 deletions(-) delete mode 100644 .github/workflows/mac-nix-check.yml diff --git a/.github/workflows/mac-nix-check.yml b/.github/workflows/mac-nix-check.yml deleted file mode 100644 index ff90d4bc42..0000000000 --- a/.github/workflows/mac-nix-check.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Crypto3 Build and Test on macOS Platforms - -on: - workflow_call: - -jobs: - build-and-test: - name: "Build and test macOS" - runs-on: [macos-14] - steps: - - name: Checkout Crypto3 - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # From https://github.com/DeterminateSystems/magic-nix-cache-action - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: DeterminateSystems/flake-checker-action@main - - - name: Run checks - run: nix build -L .?checks.aarch64-darwin.all-gcc - env: - NIX_CONFIG: | - cores = 0 - max-jobs = 1 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 950321c399..ed2496a0c8 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -22,9 +22,3 @@ jobs: always() && !cancelled() secrets: inherit - test-mac: - name: macOS Crypto3 Testing - uses: ./.github/workflows/mac-nix-check.yml - if: | - always() && !cancelled() - secrets: inherit From b0da6782d6132f34a8e101a2c15632e488b64daf Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Thu, 5 Sep 2024 10:53:11 +0200 Subject: [PATCH 4/4] create two jobs - for gcc and clang --- .github/workflows/clang-linux-nix-check.yml | 24 +++++++++++++++++++ ...-nix-check.yml => gcc-linux-nix-check.yml} | 2 +- .github/workflows/pull-request.yml | 13 +++++++--- crypto3/CMakeLists.txt | 4 ++++ crypto3/crypto3.nix | 3 --- evm-assigner/evm-assigner.nix | 2 -- evm-assigner/lib/assigner/CMakeLists.txt | 4 ++++ 7 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/clang-linux-nix-check.yml rename .github/workflows/{linux-nix-check.yml => gcc-linux-nix-check.yml} (93%) diff --git a/.github/workflows/clang-linux-nix-check.yml b/.github/workflows/clang-linux-nix-check.yml new file mode 100644 index 0000000000..43f37fa63f --- /dev/null +++ b/.github/workflows/clang-linux-nix-check.yml @@ -0,0 +1,24 @@ +name: Build and Test on Linux Platforms + +on: + workflow_call: + +jobs: + build-and-test: + name: "Build and test Linux with clang" + runs-on: [self-hosted, Linux, X64, aws_autoscaling] + steps: + # https://github.com/actions/checkout/issues/1552 + - name: Clean up after previous checkout + run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*; + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run checks + run: nix build -L .?#checks.x86_64-linux.all-clang + env: + NIX_CONFIG: | + cores = 4 diff --git a/.github/workflows/linux-nix-check.yml b/.github/workflows/gcc-linux-nix-check.yml similarity index 93% rename from .github/workflows/linux-nix-check.yml rename to .github/workflows/gcc-linux-nix-check.yml index 87eb515db4..43af748ee2 100644 --- a/.github/workflows/linux-nix-check.yml +++ b/.github/workflows/gcc-linux-nix-check.yml @@ -5,7 +5,7 @@ on: jobs: build-and-test: - name: "Build and test Linux" + name: "Build and test Linux with gcc" runs-on: [self-hosted, Linux, X64, aws_autoscaling] steps: # https://github.com/actions/checkout/issues/1552 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index ed2496a0c8..7f2f09e15c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -15,9 +15,16 @@ concurrency: cancel-in-progress: true jobs: - test-linux: - name: Linux Crypto3 Testing - uses: ./.github/workflows/linux-nix-check.yml + test-linux-gcc: + name: Linux Crypto3 Testing with gcc + uses: ./.github/workflows/gcc-linux-nix-check.yml + if: | + always() && !cancelled() + secrets: inherit + + test-linux-clang: + name: Linux Crypto3 Testing with clang + uses: ./.github/workflows/clang-linux-nix-check.yml if: | always() && !cancelled() secrets: inherit diff --git a/crypto3/CMakeLists.txt b/crypto3/CMakeLists.txt index 849f8b7c26..927c94dd7e 100644 --- a/crypto3/CMakeLists.txt +++ b/crypto3/CMakeLists.txt @@ -22,6 +22,10 @@ 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) +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "-ggdb -O0") +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 c6a05331fc..dd992e7c72 100644 --- a/crypto3/crypto3.nix +++ b/crypto3/crypto3.nix @@ -27,10 +27,7 @@ in stdenv.mkDerivation { cmakeFlags = [ (if runTests then "-DBUILD_TESTS=TRUE" else "") - (if runTests then "-DCMAKE_ENABLE_TESTS=TRUE" else "") (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") - (if enableDebug then "-DCMAKE_CXX_FLAGS=-ggdb" else "") - (if enableDebug then "-DCMAKE_CXX_FLAGS=-O0" else "") "-G Ninja" ]; diff --git a/evm-assigner/evm-assigner.nix b/evm-assigner/evm-assigner.nix index 9405a38005..cc65a3c3ab 100644 --- a/evm-assigner/evm-assigner.nix +++ b/evm-assigner/evm-assigner.nix @@ -32,10 +32,8 @@ in stdenv.mkDerivation rec { cmakeFlags = [ (if runTests then "-DBUILD_TESTS=TRUE" else "") - (if runTests then "-DCMAKE_ENABLE_TESTS=TRUE" else "") (if runTests then "-DBUILD_ASSIGNER_TESTS=TRUE" else "") (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") - (if enableDebug then "-DCMAKE_CXX_FLAGS=-ggdb" else "") "-G Ninja" ]; diff --git a/evm-assigner/lib/assigner/CMakeLists.txt b/evm-assigner/lib/assigner/CMakeLists.txt index c824cb9a2f..9618e328e7 100644 --- a/evm-assigner/lib/assigner/CMakeLists.txt +++ b/evm-assigner/lib/assigner/CMakeLists.txt @@ -5,6 +5,10 @@ cmake_policy(SET CMP0063 NEW) option(BUILD_ASSIGNER_TESTS "Build unit tests" FALSE) +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "-ggdb -O0") +endif() + set(evmone_sources ${CMAKE_CURRENT_SOURCE_DIR}/evmone/baseline.cpp ${CMAKE_CURRENT_SOURCE_DIR}/evmone/baseline_instruction_table.cpp