diff --git a/.github/changed-files.yml b/.github/changed-files.yml index 0072913b..47968a0f 100644 --- a/.github/changed-files.yml +++ b/.github/changed-files.yml @@ -2,13 +2,12 @@ golang: - goicicle/**/*.go' - go.mod rust: - - src/**/*.rs - - build.rs - - Cargo.toml + - wrappers/rust cpp: - icicle/**/*.cu - icicle/**/*.cuh - icicle/**/*.cpp - icicle/**/*.hpp - icicle/**/*.c - - icicle/**/*.h \ No newline at end of file + - icicle/**/*.h + - icicle/CMakeLists.txt \ No newline at end of file diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index fe2e37ae..59c11eed 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -46,7 +46,9 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 - name: Build Rust + working-directory: ./wrappers/rust if: needs.check-changed-files.outputs.rust == 'true' || needs.check-changed-files.outputs.cpp_cuda == 'true' + # Building from the root workspace will build all members of the workspace by default run: cargo build --release --verbose build-rust-windows: @@ -65,9 +67,11 @@ jobs: # https://docs.nvidia.com/cuda/archive/12.0.0/cuda-installation-guide-microsoft-windows/index.html sub-packages: '["cudart", "nvcc", "thrust", "visual_studio_integration"]' - name: Build Rust Targets + working-directory: ./wrappers/rust if: needs.check-changed-files.outputs.rust == 'true' || needs.check-changed-files.outputs.cpp_cuda == 'true' env: CUDA_PATH: ${{steps.cuda-toolkit.outputs.CUDA_PATH}} + # Building from the root workspace will build all members of the workspace by default run: cargo build --release --verbose build-golang-linux: diff --git a/.github/workflows/main-format.yml b/.github/workflows/main-format.yml index 646d0221..8bc081a6 100644 --- a/.github/workflows/main-format.yml +++ b/.github/workflows/main-format.yml @@ -13,6 +13,7 @@ jobs: formatting-rust: name: Check Rust Code Formatting runs-on: ubuntu-22.04 + working-directory: ./wrappers/rust steps: - name: Checkout uses: actions/checkout@v3 @@ -37,5 +38,4 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Check clang-format - run: unformatted_files=$(find ./ -path ./icicle/build -prune -o -path ./target -prune -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -ferror-limit=1 -style=file >&2); if [[ $unformatted_files ]]; then echo $unformatted_files; echo "Please run clang-format"; exit 1; fi - + run: if [[ $(find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -ferror-limit=1 -style=file 2>&1) ]]; then echo "Please run clang-format"; exit 1; fi diff --git a/.github/workflows/main-test.yml b/.github/workflows/main-test.yml index 4bc2e2c6..8eef45fc 100644 --- a/.github/workflows/main-test.yml +++ b/.github/workflows/main-test.yml @@ -46,13 +46,19 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 - name: Run Rust Tests + working-directory: ./wrappers/rust if: needs.check-changed-files.outputs.rust == 'true' || needs.check-changed-files.outputs.cpp_cuda == 'true' + # Running tests from the root workspace will run all workspace members' tests by default + #TODO: remove test-threads once thread safety is finalized run: cargo test --release --verbose -- --test-threads=1 test-cpp-linux: name: Test C++ on Linux runs-on: [self-hosted, Linux, X64, icicle] needs: check-changed-files + strategy: + matrix: + curve: [bn254, bls12_381, bls12_377, bw6_671] steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -61,7 +67,7 @@ jobs: if: needs.check-changed-files.outputs.cpp_cuda == 'true' run: | mkdir -p build - cmake -DBUILD_TESTS=ON -S . -B build + cmake -DBUILD_TESTS=ON -DCURVE=${{ matrix.curve }} -S . -B build cmake --build build - name: Run C++ Tests working-directory: ./icicle/build diff --git a/scripts/hooks/pre-push b/scripts/hooks/pre-push index f26b8bbc..1681fe9b 100755 --- a/scripts/hooks/pre-push +++ b/scripts/hooks/pre-push @@ -3,15 +3,15 @@ status=0 # Run clang-format on CUDA, C, and CPP files # clang-format writes to stderr in dry-run mode. In order to capture the output to detect if there are changes needed we redirect stderr to stdin -# to print list of files -unformatted_files=$(find ./ -path ./icicle/build -prune -o -path ./target -prune -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -ferror-limit=1 -style=file 2>&1) - -if [[ $unformatted_files ]]; +if [[ $(find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -ferror-limit=1 -style=file 2>&1) ]]; then echo "🚨 There are files in Icicle Core that need formatting." - echo $unformatted_files + echo "" echo "Please format all .c, .cpp, .h, .cu, .cuh files using the following command:" - echo "find ./ -path ./icicle/build -prune -o -path ./target -prune -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format -i -style=file" + echo "find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format -i -style=file" + echo "" + echo "If you only want to see what formatting is required please run:" + echo "find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -style=file" status=1 fi @@ -24,10 +24,11 @@ then fi # Run cargo fmt on Rust files +cd wrappers/rust if [[ $(cargo fmt --check) ]]; then echo "🚨 There are Rust files that need formatting." - echo "Please format the Rust files using 'cargo fmt'" + echo "Please format the Rust files using 'cargo fmt' from the wrappers/rust directory" status=1 fi diff --git a/wrappers/rust/Cargo.toml b/wrappers/rust/Cargo.toml index d1e7a4a3..d560923d 100644 --- a/wrappers/rust/Cargo.toml +++ b/wrappers/rust/Cargo.toml @@ -1,3 +1,7 @@ [workspace] resolver = "2" -members = ["icicle-cuda-runtime", "icicle-core", "icicle-curves/icicle-bn254"] \ No newline at end of file +members = [ + "icicle-cuda-runtime", + "icicle-core", + "icicle-curves/icicle-bn254" +] diff --git a/wrappers/rust/icicle-cuda-runtime/src/bindings.rs b/wrappers/rust/icicle-cuda-runtime/src/bindings.rs new file mode 100644 index 00000000..e06ab65b --- /dev/null +++ b/wrappers/rust/icicle-cuda-runtime/src/bindings.rs @@ -0,0 +1,2 @@ +// Empty mod file - This is necessary for cargo fmt to operate correctly in CI +// All content in this file will be overwritten when building the crate