From 2fd953cd04475f372cf8d31c06b0a2c91f237394 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Wed, 28 Aug 2024 15:49:15 +0300 Subject: [PATCH 01/25] Add the test coverage data gathering and reports generation. --- .github/actions/codecov-shared/action.yml | 28 +++++++ .github/workflows/rust.yml | 82 +++++++++---------- CONTRIBUTING.md | 28 ++++--- Makefile | 99 +++++++++++++++++++++++ README.md | 41 +++++----- 5 files changed, 205 insertions(+), 73 deletions(-) create mode 100644 .github/actions/codecov-shared/action.yml create mode 100644 Makefile diff --git a/.github/actions/codecov-shared/action.yml b/.github/actions/codecov-shared/action.yml new file mode 100644 index 0000000000..460cbae69a --- /dev/null +++ b/.github/actions/codecov-shared/action.yml @@ -0,0 +1,28 @@ +name: "Shared Codecov reporting steps" +description: "Shared Codecov reporting steps" +inputs: + files: + description: "Files to upload to Codecov" + required: true + default: "./target/coverage/lcov" + flags: + description: "Flags to pass to Codecov" + required: false + default: "unittests" + name: + description: "The report name" + required: false + default: "proof-systems" +runs: + using: "composite" + steps: + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ inputs.files }} + flags: ${{ inputs.flags }} + name: ${{ inputs.name }} + verbose: true + handle_no_reports_found: true + fail_ci_if_error: false diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 04de561ae8..c140fe55c3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -25,16 +25,15 @@ jobs: uses: actions/checkout@v4.1.1 - name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }} - run: - | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo ${{ matrix.rust_toolchain_version }} > rust-toolchain + run: | + curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ + https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init + chmod +x ./rustup-init + ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default + rm ./rustup-init + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + # overwriting default rust-toolchain + echo ${{ matrix.rust_toolchain_version }} > rust-toolchain - name: Build the mdbook run: | @@ -53,20 +52,19 @@ jobs: uses: actions/checkout@v4.1.1 - name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }} - run: - | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo ${{ matrix.rust_toolchain_version }} > rust-toolchain + run: | + curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ + https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init + chmod +x ./rustup-init + ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default + rm ./rustup-init + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + # overwriting default rust-toolchain + echo ${{ matrix.rust_toolchain_version }} > rust-toolchain - name: Run cargo fmt run: | - cargo fmt -- --check + make format # We run only one of the matrix options on the toffee hetzner-1, # and also only in this configuration we enable heavy tests. @@ -77,7 +75,6 @@ jobs: steps: - run: echo no-op - run_checks: needs: [run-checks-setup] @@ -102,16 +99,15 @@ jobs: # as action-rs does not seem to be maintained anymore, building from # scratch the environment using rustup - name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }} - run: - | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo ${{ matrix.rust_toolchain_version }} > rust-toolchain + run: | + curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ + https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init + chmod +x ./rustup-init + ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default + rm ./rustup-init + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + # overwriting default rust-toolchain + echo ${{ matrix.rust_toolchain_version }} > rust-toolchain - name: Setup OCaml ${{ matrix.ocaml_version }} uses: ocaml/setup-ocaml@v2 @@ -157,11 +153,10 @@ jobs: # Coding guidelines # - - name: Lint (clippy) run: | eval $(opam env) - cargo clippy --all-features --all-targets --tests -- -W clippy::all -D warnings + make lint # # Build @@ -170,30 +165,31 @@ jobs: - name: Ensure that everything builds run: | eval $(opam env) - cargo build --release --all-targets --all-features + make all # # Tests # - # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions - - name: Install nextest 0.9.67 + - name: Install test dependencies run: | - eval $(opam env) - # FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72. - cargo install cargo-nextest@=0.9.67 --locked + make install-test-deps - name: Run non-heavy tests run: | eval $(opam env) - cargo nextest run --all-features --release --profile ci -E "not test(heavy)" + make nextest-with-coverage + - name: Use shared Codecov reporting steps + uses: ./.github/actions/codecov-shared - name: Run heavy tests if: ${{ matrix.rust_toolchain_version == '1.74' }} run: | eval $(opam env) - cargo nextest run --all-features --release --profile ci -E "test(heavy)" - + make nextest-heavy-with-coverage + - name: Use shared Codecov reporting steps + if: ${{ matrix.rust_toolchain_version == '1.74' }} + uses: ./.github/actions/codecov-shared - name: Doc tests run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1e9c4940c6..93f062b120 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,9 +4,9 @@ Here's all you need to know to start contributing to kimchi. ## Navigating the project -* [The following video](https://www.youtube.com/watch?v=WUP54nqVedc) goes over the project organization. -* The [Mina book](https://o1-labs.github.io/proof-systems/) contains specifications, rust documentation, RFCs, and explainers on the different aspects of the system. -* The [Discussion page](https://github.com/o1-labs/proof-systems/discussions) can be used to start discussions or ask questions. +- [The following video](https://www.youtube.com/watch?v=WUP54nqVedc) goes over the project organization. +- The [Mina book](https://o1-labs.github.io/proof-systems/) contains specifications, rust documentation, RFCs, and explainers on the different aspects of the system. +- The [Discussion page](https://github.com/o1-labs/proof-systems/discussions) can be used to start discussions or ask questions. ## Finding a task @@ -16,7 +16,7 @@ We have a list of easy task to start contributing. [Start over there](https://gi Run -``` +```shell git submodule init git submodule update ``` @@ -25,19 +25,21 @@ to get the version of Optimism the zkVM has been developed for. ### Mac & Linux -* Follow these instructions to install OCaml: https://ocaml.org/docs/install.html -* Follow these instructions to install Rust: https://rustup.rs/ +- Follow these instructions to install OCaml: +- Follow these instructions to install Rust: ### Windows Development Windows development can be done using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/install). -* Install and open WSL -* Within WSL, install OCaml using your distro's package manager. For example: `apt install opam` -* Within WSL, navigate to the project directory and run `cargo test`. If there are no failures then everything is set up correctly. + +- Install and open WSL +- Within WSL, install OCaml using your distro's package manager. For example: `apt install opam` +- Within WSL, navigate to the project directory and run `cargo test`. If there are no failures then everything is set up correctly. ## Development To run tests: + ```bash cargo test --all-features --release ``` @@ -45,6 +47,7 @@ cargo test --all-features --release Takes about 5-8 minutes on a MacBook Pro (2019, 8-Core Intel Core i9, 32GB RAM). Without `--release`, more than an hour. To scan for lints: + ```bash cargo clippy --all-features --tests --all-targets -- -D warnings ``` @@ -52,6 +55,7 @@ cargo clippy --all-features --tests --all-targets -- -D warnings Note: cargo can automatically fix some lints. To do so, add `--fix` to the above command (as the first parameter). Finally, to check formatting: + ```bash cargo fmt ``` @@ -63,14 +67,14 @@ These are enforced by GitHub PR checks, so be sure to have any errors produced b Generally, proof-systems intends to be synchronized with the mina repository (see their [README-branching.md](https://github.com/MinaProtocol/mina/blob/develop/README-branching.md)), and so its branching policy is quite similar. However several important (some, temporary) distinctions exist: - `compatible`: - - Compatible with `rampup` in `mina`. - - Mina's `compatible`, similarly to mina's `master`, does not have `proof-systems`. + - Compatible with `rampup` in `mina`. + - Mina's `compatible`, similarly to mina's `master`, does not have `proof-systems`. - `berkley`: future hardfork release, will be going out to berkeley. - This is where hotfixes go. - `develop`: matches mina's `develop`, soft fork-compatibility. - Also used by `mina/o1js-main` and `o1js/main`. - `master`: future feature work development, containing breaking changes. Anything that does not need to be released alongside mina. - - Note that `mina`'s `master` does not depend on `proof-systems` at all. + - Note that `mina`'s `master` does not depend on `proof-systems` at all. - `izmir`: next hardfork release after berkeley. - In the future: - `master`/`develop` will reverse roles and become something like gitflow. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..6a3694c04c --- /dev/null +++ b/Makefile @@ -0,0 +1,99 @@ +# Variables +COVERAGE_ENV = CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE=$(shell pwd)/target/profraw/cargo-test-%p-%m.profraw + +# Install test dependencies +install-test-deps: + @echo "" + @echo "Installing the test dependencies." + @echo "" + rustup component add llvm-tools-preview + # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions + # FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72. + cargo install cargo-nextest@=0.9.67 --locked + cargo install grcov + @echo "" + @echo "Test dependencies installed." + @echo "" + +# Default target +all: clean release + +# Clean the project +clean: + cargo clean + +# Build the project +build: + cargo build --all-targets --all-features + +# Build the project in release mode +release: + cargo build --release --all-targets --all-features + +# Test the project with non-heavy tests and using native cargo test runner +test: + cargo test --all-features --release $(CARGO_EXTRA_ARGS) -- --nocapture --skip heavy $(BIN_EXTRA_ARGS) + +test-with-coverage: + $(COVERAGE_ENV) CARGO_EXTRA_ARGS="$(CARGO_EXTRA_ARGS)" BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) test + $(MAKE) generate-test-coverage-report + +# Test the project with heavy tests and using native cargo test runner +test-heavy: + cargo test --all-features --release $(CARGO_EXTRA_ARGS) -- --nocapture heavy $(BIN_EXTRA_ARGS) + +test-heavy-with-coverage: + $(COVERAGE_ENV) CARGO_EXTRA_ARGS="$(CARGO_EXTRA_ARGS)" BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) test-heavy + $(MAKE) generate-test-coverage-report + +# Test the project with all tests and using native cargo test runner +test-all: + cargo test --all-features --release $(CARGO_EXTRA_ARGS) -- --nocapture $(BIN_EXTRA_ARGS) + +test-all-with-coverage: + $(COVERAGE_ENV) CARGO_EXTRA_ARGS="$(CARGO_EXTRA_ARGS)" BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) test-all + $(MAKE) generate-test-coverage-report + +# Test the project with non-heavy tests and using nextest test runner +nextest: + cargo nextest run --all-features --release --profile ci -E "not test(heavy)" $(BIN_EXTRA_ARGS) + +nextest-with-coverage: + $(COVERAGE_ENV) BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) nextest + $(MAKE) generate-test-coverage-report + +# Test the project with heavy tests and using nextest test runner +nextest-heavy: + cargo nextest run --all-features --release --profile ci -E "test(heavy)" $(BIN_EXTRA_ARGS) + +nextest-heavy-with-coverage: + $(COVERAGE_ENV) BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) nextest-heavy + $(MAKE) generate-test-coverage-report + +# Test the project with all tests and using nextest test runner +nextest-all: + cargo nextest run --all-features --release --profile ci $(BIN_EXTRA_ARGS) + +nextest-all-with-coverage: + $(COVERAGE_ENV) BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) nextest-all + $(MAKE) generate-test-coverage-report + +# Format the code +format: + cargo fmt -- --check + +# Lint the code +lint: + cargo clippy --all-features --all-targets --tests -- -W clippy::all -D warnings + +generate-test-coverage-report: + @echo "" + @echo "Generating the test coverage report." + @echo "" + mkdir -p ./target/coverage + grcov ./target/profraw --binary-path ./target/release/deps/ -s . -t html,lcov --branch --ignore-not-existing --ignore "**/tests/**" -o ./target/coverage + @echo "" + @echo "Test coverage report is available at: ./target/coverage/html" + @echo "" + +.PHONY: install-test-deps all clean build release test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report diff --git a/README.md b/README.md index 37adb0b5ce..7bf68338a0 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ +# Kimchi + +[![codecov](https://codecov.io/gh/o1-labs/proof-systems/graph/badge.svg?token=pl6W1FDfV0)](https://codecov.io/gh/o1-labs/proof-systems) [![CI](https://github.com/o1-labs/proof-systems/actions/workflows/rust.yml/badge.svg)](https://github.com/o1-labs/proof-systems/actions/workflows/rust.yml) [![dependency status](https://deps.rs/repo/github/o1-labs/proof-systems/status.svg?style=flat-square)](https://deps.rs/repo/github/o1-labs/proof-systems) -# Kimchi - This repository contains **kimchi**, a general-purpose zero-knowledge proof system for proving the correct execution of programs. You can read more about this project on the [Kimchi book](https://o1-labs.github.io/proof-systems), or for a lighter introduction in this [blogpost](https://minaprotocol.com/blog/kimchi-the-latest-update-to-minas-proof-system). @@ -11,7 +12,7 @@ You can read more about this project on the [Kimchi book](https://o1-labs.github ## User Warning -This project comes as is. We provide no guarantee of stability or support, as the crates closely follow the needs of the [Mina]([https://](https://github.com/minaprotocol/mina)) project. +This project comes as is. We provide no guarantee of stability or support, as the crates closely follow the needs of the [Mina](<[https://](https://github.com/minaprotocol/mina)>) project. If you use this project in a production environment, it is your responsibility to perform a security audit to ensure that the software meets your requirements. @@ -19,7 +20,7 @@ If you use this project in a production environment, it is your responsibility t At the time of this writing: -**Proving time** +### Proving time | number of gates | seconds | | :-------------: | :-----: | @@ -27,14 +28,14 @@ At the time of this writing: | 2^15 | 3.3s | | 2^16 | 6.3s | -**Verification time** +### Verification time | number of gates | seconds | | :-------------: | :-----: | | 2^15 | 0.1s | | 2^16 | 0.1s | -**Proof size** +### Proof size | number of gates | bytes | | :-------------: | :---: | @@ -45,17 +46,17 @@ At the time of this writing: The project is organized in the following way: -* [book/](book/). The mina book, RFCs, and specifications. [Available here in HTML](https://o1-labs.github.io/proof-systems). -* [curves/](curves/). The elliptic curves we use (for now just the pasta curves). -* [groupmap/](groupmap/). Used to convert elliptic curve elements to field elements. -* [hasher/](hasher/). Interfaces for mina hashing. -* [kimchi/](kimchi/). Our proof system based on PLONK. -* [poly-commitment/](poly-commitment/). Polynomial commitment code. -* [poseidon/](poseidon/). Implementation of the poseidon hash function. -* [signer/](signer/). Interfaces for mina signature schemes. -* [tools/](tools/). Various tooling to help us work on kimchi. -* [turshi/](turshi/). A Cairo runner written in rust. -* [utils/](utils/). Collection of useful functions and traits. +- [book/](book/). The mina book, RFCs, and specifications. [Available here in HTML](https://o1-labs.github.io/proof-systems). +- [curves/](curves/). The elliptic curves we use (for now just the pasta curves). +- [groupmap/](groupmap/). Used to convert elliptic curve elements to field elements. +- [hasher/](hasher/). Interfaces for mina hashing. +- [kimchi/](kimchi/). Our proof system based on PLONK. +- [poly-commitment/](poly-commitment/). Polynomial commitment code. +- [poseidon/](poseidon/). Implementation of the poseidon hash function. +- [signer/](signer/). Interfaces for mina signature schemes. +- [tools/](tools/). Various tooling to help us work on kimchi. +- [turshi/](turshi/). A Cairo runner written in rust. +- [utils/](utils/). Collection of useful functions and traits. ## Contributing @@ -65,8 +66,10 @@ Check [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in contributing t An effort is made to have the documentation being self-contained, referring to the mina book for more details when necessary. You can build the rust documentation with + -``` + +```shell rustup install nightly RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --all --no-deps ``` @@ -76,7 +79,9 @@ You can visualize the documentation by opening the file `target/doc/index.html`. ## CI + The CI will build different targets. + - [Deploy Specifications & Docs to GitHub Pages](.github/workflows/gh-page.yml). When CI passes on master, the documentation built from the rust code will be available [here](https://o1-labs.github.io/proof-systems/rustdoc) and the book From 707496ac3a41466dbb6ebaa8fcc3a736c272e474 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Wed, 28 Aug 2024 18:42:49 +0300 Subject: [PATCH 02/25] Let's try with the grcov@=0.8.13 (for rustc 1.71). --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6a3694c04c..55754aeb06 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ install-test-deps: # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions # FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72. cargo install cargo-nextest@=0.9.67 --locked - cargo install grcov + # FIXME: latest 0.8.19+ requires rustc 1.74+ + cargo install grcov@=0.8.13 --locked @echo "" @echo "Test dependencies installed." @echo "" From cdc33c90f670496c6df4e95e350ccc24822ee924 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Wed, 28 Aug 2024 20:20:52 +0300 Subject: [PATCH 03/25] Another grcov@=0.8.13 fix (-t CLI argument). --- .github/actions/codecov-shared/action.yml | 4 ++-- Makefile | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/actions/codecov-shared/action.yml b/.github/actions/codecov-shared/action.yml index 460cbae69a..766bd6b686 100644 --- a/.github/actions/codecov-shared/action.yml +++ b/.github/actions/codecov-shared/action.yml @@ -3,8 +3,8 @@ description: "Shared Codecov reporting steps" inputs: files: description: "Files to upload to Codecov" - required: true - default: "./target/coverage/lcov" + required: false + default: "./target/coverage/lcov.info" flags: description: "Flags to pass to Codecov" required: false diff --git a/Makefile b/Makefile index 55754aeb06..0d219323c4 100644 --- a/Makefile +++ b/Makefile @@ -92,9 +92,10 @@ generate-test-coverage-report: @echo "Generating the test coverage report." @echo "" mkdir -p ./target/coverage - grcov ./target/profraw --binary-path ./target/release/deps/ -s . -t html,lcov --branch --ignore-not-existing --ignore "**/tests/**" -o ./target/coverage + grcov ./target/profraw --binary-path ./target/release/deps/ -s . -t html --branch --ignore-not-existing --ignore "**/tests/**" -o ./target/coverage + grcov ./target/profraw --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore "**/tests/**" -o ./target/coverage/lcov.info @echo "" - @echo "Test coverage report is available at: ./target/coverage/html" + @echo "The test coverage report is available at: ./target/coverage" @echo "" .PHONY: install-test-deps all clean build release test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report From ffbd024ce27784ee18921f9d439aafa327205f7f Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Wed, 28 Aug 2024 20:39:02 +0300 Subject: [PATCH 04/25] Refactoring. --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0d219323c4..dab63d6d8d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ # Variables COVERAGE_ENV = CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE=$(shell pwd)/target/profraw/cargo-test-%p-%m.profraw +# FIXME: In latest 0.8.19+ -t CLI argument can accept comma separated list of custom output types, hence, no need in double invocation +GRCOV_CALL = grcov ./target/profraw --binary-path ./target/release/deps/ -s . --branch --ignore-not-existing --ignore "**/tests/**" # Install test dependencies install-test-deps: @@ -92,8 +94,11 @@ generate-test-coverage-report: @echo "Generating the test coverage report." @echo "" mkdir -p ./target/coverage - grcov ./target/profraw --binary-path ./target/release/deps/ -s . -t html --branch --ignore-not-existing --ignore "**/tests/**" -o ./target/coverage - grcov ./target/profraw --binary-path ./target/release/deps/ -s . -t lcov --branch --ignore-not-existing --ignore "**/tests/**" -o ./target/coverage/lcov.info + GRCOV_OUTPUT_TYPE=html GRCOV_OUTPUT_PATH=./target/coverage + $(eval GRCOV_HTML_CMD=$(GRCOV_CALL) -t html -o ./target/coverage) + $(GRCOV_HTML_CMD) + $(eval GRCOV_LCOV_CMD=$(GRCOV_CALL) -t lcov -o ./target/coverage/lcov.info) + $(GRCOV_LCOV_CMD) @echo "" @echo "The test coverage report is available at: ./target/coverage" @echo "" From 59ffc8006dcf1b8da9baec43c474f046352c9e39 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Wed, 28 Aug 2024 21:50:17 +0300 Subject: [PATCH 05/25] The workaround of the composite actions limitations (secrets). --- .github/actions/codecov-shared/action.yml | 5 ++++- .github/workflows/rust.yml | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/actions/codecov-shared/action.yml b/.github/actions/codecov-shared/action.yml index 766bd6b686..94fbc4db33 100644 --- a/.github/actions/codecov-shared/action.yml +++ b/.github/actions/codecov-shared/action.yml @@ -1,6 +1,9 @@ name: "Shared Codecov reporting steps" description: "Shared Codecov reporting steps" inputs: + token: + description: "Codecov token" + required: true files: description: "Files to upload to Codecov" required: false @@ -19,7 +22,7 @@ runs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} + token: ${{ inputs.token }} files: ${{ inputs.files }} flags: ${{ inputs.flags }} name: ${{ inputs.name }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c140fe55c3..dff8cc3efe 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -181,6 +181,8 @@ jobs: make nextest-with-coverage - name: Use shared Codecov reporting steps uses: ./.github/actions/codecov-shared + with: + token: ${{ secrets.CODECOV_TOKEN }} - name: Run heavy tests if: ${{ matrix.rust_toolchain_version == '1.74' }} @@ -190,6 +192,8 @@ jobs: - name: Use shared Codecov reporting steps if: ${{ matrix.rust_toolchain_version == '1.74' }} uses: ./.github/actions/codecov-shared + with: + token: ${{ secrets.CODECOV_TOKEN }} - name: Doc tests run: | From fc56510b561b8f78b44cbe9e8210f0096d66b642 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 11:02:10 +0300 Subject: [PATCH 06/25] Make default target to be 'release' (no clean), don't run heavy tests with coverage as part of regular checks, remove flag from coverage uploading to see if it helps with diff processing. --- .github/actions/codecov-shared/action.yml | 2 +- .github/workflows/rust.yml | 7 +------ Makefile | 6 +++--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/actions/codecov-shared/action.yml b/.github/actions/codecov-shared/action.yml index 94fbc4db33..886136488f 100644 --- a/.github/actions/codecov-shared/action.yml +++ b/.github/actions/codecov-shared/action.yml @@ -11,7 +11,7 @@ inputs: flags: description: "Flags to pass to Codecov" required: false - default: "unittests" + default: "" name: description: "The report name" required: false diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index dff8cc3efe..393c34361e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -188,12 +188,7 @@ jobs: if: ${{ matrix.rust_toolchain_version == '1.74' }} run: | eval $(opam env) - make nextest-heavy-with-coverage - - name: Use shared Codecov reporting steps - if: ${{ matrix.rust_toolchain_version == '1.74' }} - uses: ./.github/actions/codecov-shared - with: - token: ${{ secrets.CODECOV_TOKEN }} + make nextest-heavy - name: Doc tests run: | diff --git a/Makefile b/Makefile index dab63d6d8d..5222d30342 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ COVERAGE_ENV = CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFIL # FIXME: In latest 0.8.19+ -t CLI argument can accept comma separated list of custom output types, hence, no need in double invocation GRCOV_CALL = grcov ./target/profraw --binary-path ./target/release/deps/ -s . --branch --ignore-not-existing --ignore "**/tests/**" +# Default target +all: release + # Install test dependencies install-test-deps: @echo "" @@ -18,9 +21,6 @@ install-test-deps: @echo "Test dependencies installed." @echo "" -# Default target -all: clean release - # Clean the project clean: cargo clean From 592fffa2f3df7eb1f93f87ebbae8f72b81bb8d72 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 16:45:09 +0300 Subject: [PATCH 07/25] Actions refactoring. --- .github/actions/ocaml-shared/action.yml | 20 +++++ .github/actions/toolchain-shared/action.yml | 26 ++++++ .github/workflows/ci-nightly.yml | 63 ++++++++++++++ .github/workflows/{rust.yml => ci.yml} | 94 +++++++-------------- .github/workflows/coverage.yml.disabled | 44 ---------- 5 files changed, 141 insertions(+), 106 deletions(-) create mode 100644 .github/actions/ocaml-shared/action.yml create mode 100644 .github/actions/toolchain-shared/action.yml create mode 100644 .github/workflows/ci-nightly.yml rename .github/workflows/{rust.yml => ci.yml} (53%) delete mode 100644 .github/workflows/coverage.yml.disabled diff --git a/.github/actions/ocaml-shared/action.yml b/.github/actions/ocaml-shared/action.yml new file mode 100644 index 0000000000..8a04bf75c1 --- /dev/null +++ b/.github/actions/ocaml-shared/action.yml @@ -0,0 +1,20 @@ +name: "Shared OCaml setting up steps" +description: "Shared OCaml setting up steps" +inputs: + ocaml_version: + description: "OCaml version" + required: true + shell: + description: "Shell to use" + required: false + default: "bash" +runs: + using: "composite" + steps: + - name: Setup OCaml ${{ inputs.ocaml_version }} + uses: ocaml/setup-ocaml@v2 + with: + ocaml-compiler: ${{ inputs.ocaml_version }} + # https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386 + # disable-cache: true + shell: ${{ inputs.shell }} diff --git a/.github/actions/toolchain-shared/action.yml b/.github/actions/toolchain-shared/action.yml new file mode 100644 index 0000000000..5757d14c88 --- /dev/null +++ b/.github/actions/toolchain-shared/action.yml @@ -0,0 +1,26 @@ +name: "Shared Rust toolchain setting up steps" +description: "Shared Rust toolchain setting up steps" +inputs: + rust_toolchain_version: + description: "Rust toolchain version" + required: true + shell: + description: "Shell to use" + required: false + default: "bash" +runs: + using: "composite" + steps: + # As action-rs does not seem to be maintained anymore, building from + # scratch the environment using rustup + - name: Setup Rust toolchain ${{ inputs.rust_toolchain_version }} + run: | + curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ + https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init + chmod +x ./rustup-init + ./rustup-init -y --default-toolchain "${{ inputs.rust_toolchain_version }}" --profile default + rm ./rustup-init + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + # overwriting default rust-toolchain + echo ${{ inputs.rust_toolchain_version }} > rust-toolchain + shell: ${{ inputs.shell }} diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml new file mode 100644 index 0000000000..9f511a2356 --- /dev/null +++ b/.github/workflows/ci-nightly.yml @@ -0,0 +1,63 @@ +# +# This workflow is triggered nightly (or on-demand) to run all the tests with the code coverage enabled and using the self-hosted GitHub runner. +# + +name: Nightly tests with code coverage + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: {} + +env: + # https://doc.rust-lang.org/cargo/reference/profiles.html#release + RUSTFLAGS: -Coverflow-checks=y -Cdebug-assertions=y + # https://doc.rust-lang.org/cargo/reference/profiles.html#incremental + CARGO_INCREMENTAL: 1 + # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions + CARGO_TERM_COLOR: always + RUST_MIN_STACK: 31457280 + # 30 MB of stack for Keccak tests + +jobs: + run_tests: + name: Run all tests with the code coverage + runs-on: ${{ matrix.os }} + strategy: + matrix: + # FIXME: use the latest version of cargo nextest when we get rid of 1.71 + # and 1.72 + rust_toolchain_version: ["1.74"] + # FIXME: currently not available for 5.0.0. + # It might be related to boxroot dependency, and we would need to bump + # up the ocaml-rs dependency + ocaml_version: ["4.14"] + os: ["hetzner-1"] + steps: + - name: Checkout PR + uses: actions/checkout@v4.1.1 + + - name: Use shared Rust toolchain setting up steps + uses: ./.github/actions/toolchain-shared + with: + rust_toolchain_version: ${{ matrix.rust_toolchain_version }} + + - name: Use shared OCaml setting up steps + uses: ./.github/actions/ocaml-shared + with: + ocaml_version: ${{ matrix.ocaml_version }} + + - name: Install test dependencies + run: | + make install-test-deps + + - name: Run all tests + if: ${{ matrix.rust_toolchain_version == '1.74' }} + run: | + eval $(opam env) + make nextest-all-with-coverage + + - name: Use shared Codecov reporting steps + uses: ./.github/actions/codecov-shared + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/rust.yml b/.github/workflows/ci.yml similarity index 53% rename from .github/workflows/rust.yml rename to .github/workflows/ci.yml index 393c34361e..54002524c4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/ci.yml @@ -24,16 +24,10 @@ jobs: - name: Checkout PR uses: actions/checkout@v4.1.1 - - name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }} - run: | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo ${{ matrix.rust_toolchain_version }} > rust-toolchain + - name: Use shared Rust toolchain setting up steps + uses: ./.github/actions/toolchain-shared + with: + rust_toolchain_version: ${{ matrix.rust_toolchain_version }} - name: Build the mdbook run: | @@ -51,33 +45,20 @@ jobs: - name: Checkout PR uses: actions/checkout@v4.1.1 - - name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }} - run: | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo ${{ matrix.rust_toolchain_version }} > rust-toolchain + - name: Use shared Rust toolchain setting up steps + uses: ./.github/actions/toolchain-shared + with: + rust_toolchain_version: ${{ matrix.rust_toolchain_version }} - name: Run cargo fmt run: | make format - # We run only one of the matrix options on the toffee hetzner-1, - # and also only in this configuration we enable heavy tests. - run-checks-setup: - runs-on: ubuntu-latest - outputs: - runners: '{"1.71":"ubuntu-latest", "1.72": "ubuntu-latest", "1.73": "ubuntu-latest", "1.74": "hetzner-1"}' - steps: - - run: echo no-op - run_checks: - needs: [run-checks-setup] - + name: Run some basic checks and tests + runs-on: ${{ matrix.os }} + env: + RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74" strategy: matrix: # FIXME: use the latest version of cargo nextest when we get rid of 1.71 @@ -87,34 +68,20 @@ jobs: # It might be related to boxroot dependency, and we would need to bump # up the ocaml-rs dependency ocaml_version: ["4.14"] - - # See run-checks-setup - runs-on: ${{ fromJSON(needs.run-checks-setup.outputs.runners)[matrix.rust_toolchain_version] }} - - name: Run some basic checks and tests + os: ["ubuntu-latest"] steps: - name: Checkout PR uses: actions/checkout@v4.1.1 - # as action-rs does not seem to be maintained anymore, building from - # scratch the environment using rustup - - name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }} - run: | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo ${{ matrix.rust_toolchain_version }} > rust-toolchain - - - name: Setup OCaml ${{ matrix.ocaml_version }} - uses: ocaml/setup-ocaml@v2 + - name: Use shared Rust toolchain setting up steps + uses: ./.github/actions/toolchain-shared + with: + rust_toolchain_version: ${{ matrix.rust_toolchain_version }} + + - name: Use shared OCaml setting up steps + uses: ./.github/actions/ocaml-shared with: - ocaml-compiler: ${{ matrix.ocaml_version }} - # https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386 - # disable-cache: true + ocaml_version: ${{ matrix.ocaml_version }} - name: Install markdownlint run: | @@ -165,7 +132,7 @@ jobs: - name: Ensure that everything builds run: | eval $(opam env) - make all + make # # Tests @@ -175,21 +142,24 @@ jobs: run: | make install-test-deps - - name: Run non-heavy tests + - name: Run non-heavy tests without the code coverage + if: ${{ matrix.rust_toolchain_version != env.RUST_TOOLCHAIN_COVERAGE_VERSION }} + run: | + eval $(opam env) + make nextest + + - name: Run non-heavy tests with the code coverage + if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) make nextest-with-coverage + - name: Use shared Codecov reporting steps + if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} uses: ./.github/actions/codecov-shared with: token: ${{ secrets.CODECOV_TOKEN }} - - name: Run heavy tests - if: ${{ matrix.rust_toolchain_version == '1.74' }} - run: | - eval $(opam env) - make nextest-heavy - - name: Doc tests run: | eval $(opam env) diff --git a/.github/workflows/coverage.yml.disabled b/.github/workflows/coverage.yml.disabled deleted file mode 100644 index 837124ea24..0000000000 --- a/.github/workflows/coverage.yml.disabled +++ /dev/null @@ -1,44 +0,0 @@ -name: Coverage - -on: - workflow_dispatch: - pull_request: - branches: - - master - push: - branches: - - master - -jobs: - - coverage: - name: Coverage (+nightly) - # The large timeout is to accommodate nightly builds - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.1.1 - with: - persist-credentials: false - - - uses: actions-rs/toolchain@v1.0.7 - with: - toolchain: nightly - override: true - profile: minimal - components: llvm-tools-preview - - - name: Install cargo-llvm-cov cargo command - run: cargo install cargo-llvm-cov - - - name: Setup OCaml (because of ocaml-gen) - run: sudo apt update && sudo apt install ocaml - - - name: Generate code coverage - env: - ZEBRA_SKIP_NETWORK_TESTS: 1 - CARGO_INCREMENTAL: 0 - run: cargo llvm-cov --lcov > lcov.info - - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v2.0.3 From 908e69e7292b70476b45ada2e9a70620b55daf5d Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 16:49:47 +0300 Subject: [PATCH 08/25] Actions refactoring. --- .github/actions/ocaml-shared/action.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/actions/ocaml-shared/action.yml b/.github/actions/ocaml-shared/action.yml index 8a04bf75c1..37351b6a4c 100644 --- a/.github/actions/ocaml-shared/action.yml +++ b/.github/actions/ocaml-shared/action.yml @@ -4,10 +4,6 @@ inputs: ocaml_version: description: "OCaml version" required: true - shell: - description: "Shell to use" - required: false - default: "bash" runs: using: "composite" steps: @@ -17,4 +13,3 @@ runs: ocaml-compiler: ${{ inputs.ocaml_version }} # https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386 # disable-cache: true - shell: ${{ inputs.shell }} From efbfd56b4bee90312a4fadc51999e81ba0b71f78 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 16:57:03 +0300 Subject: [PATCH 09/25] Comments refactoring. --- .github/workflows/ci-nightly.yml | 2 -- .github/workflows/ci.yml | 2 -- Makefile | 6 +++--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index 9f511a2356..1cc1ef3641 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -25,8 +25,6 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # FIXME: use the latest version of cargo nextest when we get rid of 1.71 - # and 1.72 rust_toolchain_version: ["1.74"] # FIXME: currently not available for 5.0.0. # It might be related to boxroot dependency, and we would need to bump diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54002524c4..b5ccf71080 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,8 +61,6 @@ jobs: RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74" strategy: matrix: - # FIXME: use the latest version of cargo nextest when we get rid of 1.71 - # and 1.72 rust_toolchain_version: ["1.71", "1.72", "1.73", "1.74"] # FIXME: currently not available for 5.0.0. # It might be related to boxroot dependency, and we would need to bump diff --git a/Makefile b/Makefile index 5222d30342..fa79d7b25c 100644 --- a/Makefile +++ b/Makefile @@ -7,15 +7,15 @@ GRCOV_CALL = grcov ./target/profraw --binary-path ./target/release/deps/ -s . -- all: release # Install test dependencies +# https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions +# FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72. +# FIXME: latest 0.8.19+ requires rustc 1.74+ install-test-deps: @echo "" @echo "Installing the test dependencies." @echo "" rustup component add llvm-tools-preview - # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions - # FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72. cargo install cargo-nextest@=0.9.67 --locked - # FIXME: latest 0.8.19+ requires rustc 1.74+ cargo install grcov@=0.8.13 --locked @echo "" @echo "Test dependencies installed." From 18b12752f2e4d87b2448e3fb0563bbe6f1f32946 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 17:20:12 +0300 Subject: [PATCH 10/25] Cleaning step. --- .github/workflows/ci-nightly.yml | 1 + .github/workflows/ci.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index 1cc1ef3641..5ff9c2f361 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -53,6 +53,7 @@ jobs: if: ${{ matrix.rust_toolchain_version == '1.74' }} run: | eval $(opam env) + make clean make nextest-all-with-coverage - name: Use shared Codecov reporting steps diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5ccf71080..58c8b901c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -144,12 +144,14 @@ jobs: if: ${{ matrix.rust_toolchain_version != env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) + make clean make nextest - name: Run non-heavy tests with the code coverage if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) + make clean make nextest-with-coverage - name: Use shared Codecov reporting steps From e5d4e08d5f5c72cdc8cfa9ad9276581ee2251c8f Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 17:21:24 +0300 Subject: [PATCH 11/25] Nightly condition fix. --- .github/workflows/ci-nightly.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index 5ff9c2f361..7d2d6c9f46 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -49,8 +49,7 @@ jobs: run: | make install-test-deps - - name: Run all tests - if: ${{ matrix.rust_toolchain_version == '1.74' }} + - name: Run all tests with the code coverage run: | eval $(opam env) make clean From 14dc1cf6afc13368995bbce6a1b414fbad2f5ff0 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 18:32:55 +0300 Subject: [PATCH 12/25] Add debug logging. --- .github/workflows/ci-nightly.yml | 2 +- .github/workflows/ci.yml | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index 7d2d6c9f46..14e565ceb8 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -32,7 +32,7 @@ jobs: ocaml_version: ["4.14"] os: ["hetzner-1"] steps: - - name: Checkout PR + - name: Checkout repository uses: actions/checkout@v4.1.1 - name: Use shared Rust toolchain setting up steps diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58c8b901c5..28b6b28d72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: matrix: rust_toolchain_version: ["1.72"] steps: - - name: Checkout PR + - name: Checkout repository uses: actions/checkout@v4.1.1 - name: Use shared Rust toolchain setting up steps @@ -42,7 +42,7 @@ jobs: matrix: rust_toolchain_version: ["nightly"] steps: - - name: Checkout PR + - name: Checkout repository uses: actions/checkout@v4.1.1 - name: Use shared Rust toolchain setting up steps @@ -68,7 +68,7 @@ jobs: ocaml_version: ["4.14"] os: ["ubuntu-latest"] steps: - - name: Checkout PR + - name: Checkout repo uses: actions/checkout@v4.1.1 - name: Use shared Rust toolchain setting up steps @@ -86,6 +86,19 @@ jobs: # FIXME: 0.39.0 makes the CI fail npm install -g markdownlint-cli@0.38.0 + # TODO: Remove debug logging + - name: Echo tollchain version and environment + run: | + echo rustc --version + echo "" + echo $GITHUB_PATH + echo "" + echo $PATH + echo "" + echo $CARGO_HOME + echo "" + env + # # Doc & Spec # From 2b8ca450a77fcc9051b0bda25d3b5628f1d4e73c Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 18:53:29 +0300 Subject: [PATCH 13/25] Additional workflows refactoring and more debug logging to track the issue. --- .github/workflows/benches.yml | 40 ++++++++++++----------------------- .github/workflows/ci.yml | 6 +++++- .github/workflows/gh-page.yml | 27 +++++++---------------- 3 files changed, 27 insertions(+), 46 deletions(-) diff --git a/.github/workflows/benches.yml b/.github/workflows/benches.yml index 7fd1fe8e2e..aff0c4941b 100644 --- a/.github/workflows/benches.yml +++ b/.github/workflows/benches.yml @@ -9,47 +9,35 @@ env: OCAML_VERSION: "4.14.0" RUST_TOOLCHAIN_VERSION: "1.71" - jobs: bench: runs-on: ubuntu-latest name: Run benchmarks if: github.event.label.name == 'benchmark' steps: - - name: Checkout PR + - name: Checkout repository uses: actions/checkout@v4.1.1 - # as action-rs does not seem to be maintained anymore, building from - # scratch the environment using rustup - - name: Setup Rust toolchain $RUST_TOOLCHAIN_VERSION - run: - | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "$RUST_TOOLCHAIN_VERSION" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo $RUST_TOOLCHAIN_VERSION > rust-toolchain + - name: Use shared Rust toolchain setting up steps + uses: ./.github/actions/toolchain-shared + with: + rust_toolchain_version: ${{ env.RUST_TOOLCHAIN_VERSION }} - name: Install dependencies run: | set -x - cargo install cargo-criterion # criterion + cargo install cargo-criterion - - name: Setup OCaml ${{ env.OCAML_VERSION }} - uses: ocaml/setup-ocaml@v2 + - name: Use shared OCaml setting up steps + uses: ./.github/actions/ocaml-shared with: - ocaml-compiler: ${{ env.OCAML_VERSION }} - # https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386 - # disable-cache: true + ocaml_version: ${{ env.OCAML_VERSION }} -# - name: Run iai bench -# run: | -# set -x -# cargo bench -p kimchi --bench proof_iai > iai_bench -# cat iai_bench + # - name: Run iai bench + # run: | + # set -x + # cargo bench -p kimchi --bench proof_iai > iai_bench + # cat iai_bench - name: Run criterion bench run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28b6b28d72..4fcc4659a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,9 @@ jobs: # TODO: Remove debug logging - name: Echo tollchain version and environment run: | - echo rustc --version + rustc --version + echo "" + cargo --version echo "" echo $GITHUB_PATH echo "" @@ -97,6 +99,8 @@ jobs: echo "" echo $CARGO_HOME echo "" + cat rust-toolchain + echo "" env # diff --git a/.github/workflows/gh-page.yml b/.github/workflows/gh-page.yml index b4966ffc1d..1ba550b789 100644 --- a/.github/workflows/gh-page.yml +++ b/.github/workflows/gh-page.yml @@ -16,29 +16,18 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout Repository + - name: Checkout repository uses: actions/checkout@v4.1.1 - # as action-rs does not seem to be maintained anymore, building from - # scratch the environment using rustup - - name: Setup nightly Rust toolchain - run: - | - curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \ - https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init - chmod +x ./rustup-init - ./rustup-init -y --default-toolchain "$RUST_TOOLCHAIN_VERSION" --profile default - rm ./rustup-init - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - # overwriting default rust-toolchain - echo $RUST_TOOLCHAIN_VERSION > rust-toolchain + - name: Use shared Rust toolchain setting up steps + uses: ./.github/actions/toolchain-shared + with: + rust_toolchain_version: ${{ env.RUST_TOOLCHAIN_VERSION }} - - name: Setup OCaml ${{ env.OCAML_VERSION }} - uses: ocaml/setup-ocaml@v2 + - name: Use shared OCaml setting up steps + uses: ./.github/actions/ocaml-shared with: - ocaml-compiler: ${{ env.OCAML_VERSION }} - # https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386 - # disable-cache: true + ocaml_version: ${{ env.OCAML_VERSION }} # This must be the same as in the section "Generate rustdoc locally" in the README.md - name: Build Rust Documentation From 13d70197e7ca661d53a3496a4770d853b7f9afdb Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 29 Aug 2024 21:19:07 +0300 Subject: [PATCH 14/25] Use latest actions/checkout@v4 with submodules=recursive. --- .github/workflows/benches.yml | 4 +++- .github/workflows/ci-nightly.yml | 6 ++++-- .github/workflows/ci.yml | 33 +++++++++++--------------------- .github/workflows/gh-page.yml | 4 +++- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/.github/workflows/benches.yml b/.github/workflows/benches.yml index aff0c4941b..70cd89cee9 100644 --- a/.github/workflows/benches.yml +++ b/.github/workflows/benches.yml @@ -16,7 +16,9 @@ jobs: if: github.event.label.name == 'benchmark' steps: - name: Checkout repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Use shared Rust toolchain setting up steps uses: ./.github/actions/toolchain-shared diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index 14e565ceb8..7889772681 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -16,8 +16,8 @@ env: CARGO_INCREMENTAL: 1 # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions CARGO_TERM_COLOR: always - RUST_MIN_STACK: 31457280 # 30 MB of stack for Keccak tests + RUST_MIN_STACK: 31457280 jobs: run_tests: @@ -33,7 +33,9 @@ jobs: os: ["hetzner-1"] steps: - name: Checkout repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Use shared Rust toolchain setting up steps uses: ./.github/actions/toolchain-shared diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fcc4659a7..fedf4924c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ env: CARGO_INCREMENTAL: 1 # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions CARGO_TERM_COLOR: always - RUST_MIN_STACK: 31457280 # 30 MB of stack for Keccak tests + RUST_MIN_STACK: 31457280 jobs: run_mdbook: @@ -22,7 +22,9 @@ jobs: rust_toolchain_version: ["1.72"] steps: - name: Checkout repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Use shared Rust toolchain setting up steps uses: ./.github/actions/toolchain-shared @@ -43,7 +45,9 @@ jobs: rust_toolchain_version: ["nightly"] steps: - name: Checkout repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Use shared Rust toolchain setting up steps uses: ./.github/actions/toolchain-shared @@ -68,8 +72,10 @@ jobs: ocaml_version: ["4.14"] os: ["ubuntu-latest"] steps: - - name: Checkout repo - uses: actions/checkout@v4.1.1 + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive - name: Use shared Rust toolchain setting up steps uses: ./.github/actions/toolchain-shared @@ -86,23 +92,6 @@ jobs: # FIXME: 0.39.0 makes the CI fail npm install -g markdownlint-cli@0.38.0 - # TODO: Remove debug logging - - name: Echo tollchain version and environment - run: | - rustc --version - echo "" - cargo --version - echo "" - echo $GITHUB_PATH - echo "" - echo $PATH - echo "" - echo $CARGO_HOME - echo "" - cat rust-toolchain - echo "" - env - # # Doc & Spec # diff --git a/.github/workflows/gh-page.yml b/.github/workflows/gh-page.yml index 1ba550b789..6e9b3386b9 100644 --- a/.github/workflows/gh-page.yml +++ b/.github/workflows/gh-page.yml @@ -17,7 +17,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Use shared Rust toolchain setting up steps uses: ./.github/actions/toolchain-shared From e8a39efa0493119d2401a864fc88ddb8acb659ce Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 29 Aug 2024 13:43:37 -0700 Subject: [PATCH 15/25] CI: bump up setup-ocaml version to v3 Released earlier this year in July. No big changes. Only bumping up to stay up-to-date. --- .github/actions/ocaml-shared/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/ocaml-shared/action.yml b/.github/actions/ocaml-shared/action.yml index 37351b6a4c..0ca66d56ba 100644 --- a/.github/actions/ocaml-shared/action.yml +++ b/.github/actions/ocaml-shared/action.yml @@ -8,7 +8,7 @@ runs: using: "composite" steps: - name: Setup OCaml ${{ inputs.ocaml_version }} - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: ${{ inputs.ocaml_version }} # https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386 From 90bd5182ea8bca860535a6d9f19dc57bc2d159c8 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 30 Aug 2024 10:13:41 +0300 Subject: [PATCH 16/25] Job rename. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fedf4924c6..2c7fc59b7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: make format run_checks: - name: Run some basic checks and tests + name: Run checks and tests runs-on: ${{ matrix.os }} env: RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74" From 2d0063509839011f698ff5e56f42f89ce3a5b9d0 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 30 Aug 2024 16:12:56 +0300 Subject: [PATCH 17/25] Documentation. --- .github/workflows/benches.yml | 2 +- .github/workflows/ci.yml | 1 - CONTRIBUTING.md | 69 +++++++++++++++++++++++++++-------- Makefile | 14 ++++++- README.md | 16 ++++---- 5 files changed, 75 insertions(+), 27 deletions(-) diff --git a/.github/workflows/benches.yml b/.github/workflows/benches.yml index 70cd89cee9..24924d043d 100644 --- a/.github/workflows/benches.yml +++ b/.github/workflows/benches.yml @@ -49,7 +49,7 @@ jobs: cat criterion_bench - name: Write result in PR - uses: actions/github-script@v5 + uses: actions/github-script@v7 with: script: | const fs = require('fs'); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c7fc59b7d..d44c41b8f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,6 @@ jobs: if: ${{ matrix.rust_toolchain_version != env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) - make clean make nextest - name: Run non-heavy tests with the code coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 93f062b120..3f47c5c106 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,14 +14,17 @@ We have a list of easy task to start contributing. [Start over there](https://gi ## Setting up the project -Run +Make sure you have the GNU `make` utility installed since we use it to streamline various tasks. +Windows users may need to use the `WSL` to run `make` commands. +For the complete list of `make` targets, please refer to the [Makefile](Makefile). + +After the repository being cloned, run: ```shell -git submodule init -git submodule update +make setup ``` -to get the version of Optimism the zkVM has been developed for. +this will also synchronize the Git submodules to get the version of Optimism the zkVM has been developed for. ### Mac & Linux @@ -38,29 +41,63 @@ Windows development can be done using [Windows Subsystem for Linux (WSL)](https: ## Development -To run tests: +To run all tests: + +### Setting up -```bash -cargo test --all-features --release +```shell +make install-test-deps ``` -Takes about 5-8 minutes on a MacBook Pro (2019, 8-Core Intel Core i9, 32GB RAM). Without `--release`, more than an hour. +### Cargo test runner -To scan for lints: +```shell +make test-all +``` + +### Nextest test runner -```bash -cargo clippy --all-features --tests --all-targets -- -D warnings +```shell +make nextest-all ``` -Note: cargo can automatically fix some lints. To do so, add `--fix` to the above command (as the first parameter). +We also provide the `make` targets to run tests with the code coverage reporting, for example: + +```shell +make test-all-with-coverage +``` -Finally, to check formatting: +You can also specify an extra CLI argument to `make` to pass it to the cargo or binary, for example: + +```shell +CARGO_EXTRA_ARGS="-p poly-commitment" make test-all-with-coverage +BIN_EXTRA_ARGS="-p poly-commitment" make nextest-all-with-coverage +``` -```bash -cargo fmt +Note: In example above we run tests for the `poly-commitment` package only. + +We build and run tests in `--release` mode, because otherwise tests execution can last for a long time. + +To check formatting: + +```shell +make format +``` + +To scan for lints: + +```shell +make lint +``` + +Note: cargo can automatically fix some lints. To do so, add `--fix` to the `CARGO_EXTRA_ARGS` variable and use it with the command above like this: + +```shell +CARGO_EXTRA_ARGS="--fix" make lint ``` -These are enforced by GitHub PR checks, so be sure to have any errors produced by the above tools fixed before pushing the code to your pull request branch. Refer to `.github/workflows` for all PR checks. +Formatting and lints are enforced by GitHub PR checks, so please be sure to have any errors produced by the above tools fixed before pushing the code to your pull request branch. +Please refer to [CI](.github/workflows/ci.yml) workflow to see all PR checks. ## Branching policy diff --git a/Makefile b/Makefile index fa79d7b25c..3543440992 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,16 @@ GRCOV_CALL = grcov ./target/profraw --binary-path ./target/release/deps/ -s . -- # Default target all: release +setup: + @echo "" + @echo "Syncing the Git submodules." + @echo "" + git submodule sync + git submodule update --init --recursive + @echo "" + @echo "Git submodules synced." + @echo "" + # Install test dependencies # https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions # FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72. @@ -87,7 +97,7 @@ format: # Lint the code lint: - cargo clippy --all-features --all-targets --tests -- -W clippy::all -D warnings + cargo clippy --all-features --all-targets --tests $(CARGO_EXTRA_ARGS) -- -W clippy::all -D warnings generate-test-coverage-report: @echo "" @@ -103,4 +113,4 @@ generate-test-coverage-report: @echo "The test coverage report is available at: ./target/coverage" @echo "" -.PHONY: install-test-deps all clean build release test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report +.PHONY: all setup install-test-deps clean build release test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report diff --git a/README.md b/README.md index d6b0776f7d..0d365a4707 100644 --- a/README.md +++ b/README.md @@ -80,13 +80,15 @@ You can visualize the documentation by opening the file `target/doc/index.html`. -The CI will build different targets. - -- [Deploy Specifications & Docs to GitHub Pages](.github/workflows/gh-page.yml). - When CI passes on master, the documentation built from the rust code will be - available [here](https://o1-labs.github.io/proof-systems/rustdoc) and the book - will be available [here](https://o1-labs.github.io/proof-systems). +- [CI](.github/workflows/ci.yml). + This workflow ensures that the entire project builds correctly, adheres to guidelines, and passes all necessary tests. +- [Nightly tests with code coverage](.github/workflows/ci-nightly.yml). + This workflow runs all the tests nightly or on demand, generates and publishes the code coverage report. +- [Benchmarks](.github/workflows/benches.yml). + This workflow runs benchmarks when a pull request is labeled with "benchmark." It sets up the Rust and OCaml environments, installs necessary tools, and executes cargo criterion benchmarks on the kimchi crate. The benchmark results are then posted as a comment on the pull request for review. +- [Deploy Specifications & Docs to GitHub Pages](.github/workflows/gh-page.yml). + When CI passes on master, the documentation built from the rust code will be available by this [link](https://o1-labs.github.io/proof-systems/rustdoc) and the book will be available by this [link](https://o1-labs.github.io/proof-systems). ## Nix for Dependencies (WIP) -If you have `nix` installed and in particular, `flakes` enabled, you can install the dependencies for these projects using nix. Simply `nix develop .` inside this directory to bring into scope `rustup`, `opam`, and `go` (along with a few other tools). You will have to manage the toolchains yourself using `rustup` and `opam`, in the current iteration. \ No newline at end of file +If you have `nix` installed and in particular, `flakes` enabled, you can install the dependencies for these projects using nix. Simply `nix develop .` inside this directory to bring into scope `rustup`, `opam`, and `go` (along with a few other tools). You will have to manage the toolchains yourself using `rustup` and `opam`, in the current iteration. From 7c6304957255c8b877b6f7f9d986ce72869fed90 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 30 Aug 2024 17:50:25 +0300 Subject: [PATCH 18/25] Let's try to speed up tests with coverage by not cleaning up the env. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d44c41b8f4..94b0b1fd04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -156,7 +156,7 @@ jobs: if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) - make clean + # make clean make nextest-with-coverage - name: Use shared Codecov reporting steps From c61dbbf7ae68f42cf4aab85df0514c51d980e20b Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 30 Aug 2024 20:05:10 +0300 Subject: [PATCH 19/25] Refactor CI to run tests with the code coverage on self-hosted runner and make Nightly builds on demand with the coverage report attached to the job execution results rather than upload it to the Codecov to not mess the diff checks. --- .../{ci-nightly.yml => ci-on-demand.yml} | 18 +++++++++++------- .github/workflows/ci.yml | 16 ++++++++++++---- README.md | 4 ++-- 3 files changed, 25 insertions(+), 13 deletions(-) rename .github/workflows/{ci-nightly.yml => ci-on-demand.yml} (71%) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-on-demand.yml similarity index 71% rename from .github/workflows/ci-nightly.yml rename to .github/workflows/ci-on-demand.yml index 7889772681..443363d3e7 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-on-demand.yml @@ -1,12 +1,11 @@ # -# This workflow is triggered nightly (or on-demand) to run all the tests with the code coverage enabled and using the self-hosted GitHub runner. +# This workflow is triggered on-demand to run all the tests with the code coverage enabled and using the self-hosted GitHub runner. +# Test coverage report is attached to the current job execution results in a form of Zip archive. # -name: Nightly tests with code coverage +name: On-demand tests with the code coverage on: - schedule: - - cron: "0 0 * * *" workflow_dispatch: {} env: @@ -57,7 +56,12 @@ jobs: make clean make nextest-all-with-coverage - - name: Use shared Codecov reporting steps - uses: ./.github/actions/codecov-shared + - name: Upload the HTML test coverage report + uses: actions/upload-artifact@v4 + continue-on-error: true + if: always() with: - token: ${{ secrets.CODECOV_TOKEN }} + if-no-files-found: ignore + name: test-coverage-html-report-${{ matrix.rust_toolchain_version }}-${{ matrix.os }} + path: target/coverage/ + retention-days: 30 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94b0b1fd04..803b8144a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,9 +58,19 @@ jobs: run: | make format + # We run only one of the matrix options on the toffee hetzner-1 self-hosted GitHub runner. + # Only in this configuration we enable heavy tests with the code coverage data gathering. + run_checks_setup: + runs-on: ubuntu-latest + outputs: + runners: '{"1.71":"ubuntu-latest", "1.72": "ubuntu-latest", "1.73": "ubuntu-latest", "1.74": "hetzner-1"}' + steps: + - run: echo no-op + run_checks: + needs: [run_checks_setup] name: Run checks and tests - runs-on: ${{ matrix.os }} + runs-on: ${{ fromJSON(needs.run_checks_setup.outputs.runners)[matrix.rust_toolchain_version] }} env: RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74" strategy: @@ -147,7 +157,6 @@ jobs: make install-test-deps - name: Run non-heavy tests without the code coverage - if: ${{ matrix.rust_toolchain_version != env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) make nextest @@ -156,8 +165,7 @@ jobs: if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) - # make clean - make nextest-with-coverage + make nextest-heavy-with-coverage - name: Use shared Codecov reporting steps if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} diff --git a/README.md b/README.md index 0d365a4707..8ace4ec2dc 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ You can visualize the documentation by opening the file `target/doc/index.html`. - [CI](.github/workflows/ci.yml). This workflow ensures that the entire project builds correctly, adheres to guidelines, and passes all necessary tests. -- [Nightly tests with code coverage](.github/workflows/ci-nightly.yml). - This workflow runs all the tests nightly or on demand, generates and publishes the code coverage report. +- [On-demand tests with the code coverage](.github/workflows/ci-on-demand.yml). + This workflow runs all the tests on demand, generates and attaches the code coverage report to job execution results. - [Benchmarks](.github/workflows/benches.yml). This workflow runs benchmarks when a pull request is labeled with "benchmark." It sets up the Rust and OCaml environments, installs necessary tools, and executes cargo criterion benchmarks on the kimchi crate. The benchmark results are then posted as a comment on the pull request for review. - [Deploy Specifications & Docs to GitHub Pages](.github/workflows/gh-page.yml). From d6347964f1b02061c0dcc311dce241a1bc3b8d05 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 30 Aug 2024 20:11:49 +0300 Subject: [PATCH 20/25] Refactoring. --- .github/workflows/{ci-on-demand.yml => ci-nightly.yml} | 6 ++++-- .github/workflows/ci.yml | 1 + README.md | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) rename .github/workflows/{ci-on-demand.yml => ci-nightly.yml} (88%) diff --git a/.github/workflows/ci-on-demand.yml b/.github/workflows/ci-nightly.yml similarity index 88% rename from .github/workflows/ci-on-demand.yml rename to .github/workflows/ci-nightly.yml index 443363d3e7..a17e94ebf3 100644 --- a/.github/workflows/ci-on-demand.yml +++ b/.github/workflows/ci-nightly.yml @@ -1,11 +1,13 @@ # -# This workflow is triggered on-demand to run all the tests with the code coverage enabled and using the self-hosted GitHub runner. +# This workflow is triggered by scheduler or on-demand to run all the tests with the code coverage enabled and using the self-hosted GitHub runner. # Test coverage report is attached to the current job execution results in a form of Zip archive. # -name: On-demand tests with the code coverage +name: Nightly tests with the code coverage on: + schedule: + - cron: "0 0 * * *" # every day at midnight workflow_dispatch: {} env: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 803b8144a0..c9ca68bc8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -157,6 +157,7 @@ jobs: make install-test-deps - name: Run non-heavy tests without the code coverage + if: ${{ matrix.rust_toolchain_version != env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) make nextest diff --git a/README.md b/README.md index 8ace4ec2dc..75a40fdd1c 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ You can visualize the documentation by opening the file `target/doc/index.html`. - [CI](.github/workflows/ci.yml). This workflow ensures that the entire project builds correctly, adheres to guidelines, and passes all necessary tests. -- [On-demand tests with the code coverage](.github/workflows/ci-on-demand.yml). - This workflow runs all the tests on demand, generates and attaches the code coverage report to job execution results. +- [Nightly tests with the code coverage](.github/workflows/ci-nightly.yml). + This workflow runs all the tests per scheduler or on-demand, generates and attaches the code coverage report to the job's execution results. - [Benchmarks](.github/workflows/benches.yml). This workflow runs benchmarks when a pull request is labeled with "benchmark." It sets up the Rust and OCaml environments, installs necessary tools, and executes cargo criterion benchmarks on the kimchi crate. The benchmark results are then posted as a comment on the pull request for review. - [Deploy Specifications & Docs to GitHub Pages](.github/workflows/gh-page.yml). From 98280335dd75df66c7ab9b672bb21fa72a48faa7 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 30 Aug 2024 20:59:21 +0300 Subject: [PATCH 21/25] Step name fix. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9ca68bc8b..dff3501843 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,7 +162,7 @@ jobs: eval $(opam env) make nextest - - name: Run non-heavy tests with the code coverage + - name: Run heavy tests with the code coverage if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) From c26b5b1dc17776b3d5314d08a211190f0c9bf2a7 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 30 Aug 2024 23:25:08 +0300 Subject: [PATCH 22/25] Heavy tests with coverage are too heavy (3h+), reverting back to non-heavy, everything else will be executed during the Nightly runs. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dff3501843..3bbfa04993 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,11 +162,11 @@ jobs: eval $(opam env) make nextest - - name: Run heavy tests with the code coverage + - name: Run non-heavy tests with the code coverage if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} run: | eval $(opam env) - make nextest-heavy-with-coverage + make nextest-with-coverage - name: Use shared Codecov reporting steps if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} From 8373817b299b58563c115838b404d50be8b3bd05 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Sat, 31 Aug 2024 09:29:37 +0300 Subject: [PATCH 23/25] Log job summary with the test coverage on completion. --- .../coverage-summary-shared/action.yml | 32 +++++++++++++++++++ .github/workflows/ci-nightly.yml | 3 ++ .github/workflows/ci.yml | 4 +++ 3 files changed, 39 insertions(+) create mode 100644 .github/actions/coverage-summary-shared/action.yml diff --git a/.github/actions/coverage-summary-shared/action.yml b/.github/actions/coverage-summary-shared/action.yml new file mode 100644 index 0000000000..fd61cd647d --- /dev/null +++ b/.github/actions/coverage-summary-shared/action.yml @@ -0,0 +1,32 @@ +name: "Shared code coverage summary" +description: "Shared code coverage summary" +inputs: + html_file: + description: "HTML file with the coverage report" + required: false + default: "target/coverage/index.html" + shell: + description: "Shell to use" + required: false + default: "bash" +runs: + using: "composite" + steps: + - name: Add test coverage summary + run: | + echo "### Test coverage summary" >> $GITHUB_STEP_SUMMARY + # Define the HTML file + html_file="${{ inputs.html_file }}" + # Extract data for Lines, Functions, and Branches using `sed` + lines=$(sed -n '/heading">Lines/{n;n;s/.*]*>\(.*%\)<\/abbr>.*/\1/p;}' "$html_file") + functions=$(sed -n '/heading">Functions/{n;n;s/.*]*>\(.*%\)<\/abbr>.*/\1/p;}' "$html_file") + branches=$(sed -n '/heading">Branches/{n;n;s/.*]*>\(.*%\)<\/abbr>.*/\1/p;}' "$html_file") + # Compose Markdown summary table + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Metric | Coverage |" >> $GITHUB_STEP_SUMMARY + echo "|-----------|----------|" >> $GITHUB_STEP_SUMMARY + echo "| Lines | $lines |" >> $GITHUB_STEP_SUMMARY + echo "| Functions | $functions |" >> $GITHUB_STEP_SUMMARY + echo "| Branches | $branches |" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: ${{ inputs.shell }} diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index a17e94ebf3..55b4106aab 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -58,6 +58,9 @@ jobs: make clean make nextest-all-with-coverage + - name: Use shared code coverage summary + uses: ./.github/actions/coverage-summary-shared + - name: Upload the HTML test coverage report uses: actions/upload-artifact@v4 continue-on-error: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bbfa04993..6b063195f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -168,6 +168,10 @@ jobs: eval $(opam env) make nextest-with-coverage + - name: Use shared code coverage summary + if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} + uses: ./.github/actions/coverage-summary-shared + - name: Use shared Codecov reporting steps if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }} uses: ./.github/actions/codecov-shared From 47f86e690465fa7a8979c60f169ab44deea34f60 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Sat, 31 Aug 2024 09:52:35 +0300 Subject: [PATCH 24/25] Refactor runners selection. --- .github/workflows/ci.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b063195f0..fe59e19c12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,19 +58,11 @@ jobs: run: | make format - # We run only one of the matrix options on the toffee hetzner-1 self-hosted GitHub runner. - # Only in this configuration we enable heavy tests with the code coverage data gathering. - run_checks_setup: - runs-on: ubuntu-latest - outputs: - runners: '{"1.71":"ubuntu-latest", "1.72": "ubuntu-latest", "1.73": "ubuntu-latest", "1.74": "hetzner-1"}' - steps: - - run: echo no-op - run_checks: - needs: [run_checks_setup] name: Run checks and tests - runs-on: ${{ fromJSON(needs.run_checks_setup.outputs.runners)[matrix.rust_toolchain_version] }} + # We run only one of the matrix options on the toffee `hetzner-1` self-hosted GitHub runner. + # Only in this configuration we enable heavy tests with the code coverage data gathering. + runs-on: ${{ matrix.rust_toolchain_version == '1.74' && 'hetzner-1' || 'ubuntu-latest' }} env: RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74" strategy: From 68de23a6c6d57e855e7e9cec2d180ef8763e3e98 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Sat, 31 Aug 2024 09:55:07 +0300 Subject: [PATCH 25/25] Comments fix. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe59e19c12..788c258a34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: run_checks: name: Run checks and tests # We run only one of the matrix options on the toffee `hetzner-1` self-hosted GitHub runner. - # Only in this configuration we enable heavy tests with the code coverage data gathering. + # Only in this configuration we enable tests with the code coverage data gathering. runs-on: ${{ matrix.rust_toolchain_version == '1.74' && 'hetzner-1' || 'ubuntu-latest' }} env: RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74"