From fde2bc36dc83038abc5f667ec3ad2a89b53b522f Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 19 Oct 2023 11:04:48 +0200 Subject: [PATCH] Add GitHub actions for Rust code (#2) --- .github/workflows/coverage.yml | 33 +++++++++++++++++++++++ .github/workflows/rust.yml | 49 ++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ Code/Cargo.toml | 6 +++++ Code/rust-toolchain.toml | 2 ++ Code/rustfmt.toml | 2 ++ 6 files changed, 95 insertions(+) create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/rust.yml create mode 100644 Code/Cargo.toml create mode 100644 Code/rust-toolchain.toml create mode 100644 Code/rustfmt.toml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..9bba1b589 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,33 @@ +name: Coverage + +on: [pull_request, push] + +jobs: + coverage: + runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: llvm-tools-preview + - name: Install cargo-nextest + uses: taiki-e/install-action@cargo-nextest + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + working_dir: Code + run: cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info + - name: Generate text report + working_dir: Code + run: cargo llvm-cov report --text + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v3 + # working_dir: Code + # with: + # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + # files: lcov.info + # fail_ci_if_error: true diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 000000000..cf9d9cf55 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,49 @@ +name: "Rust" +on: + push: + pull_request: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install cargo-nextest + uses: taiki-e/install-action@cargo-hack + - name: Build code + working_dir: Code + run: cargo nextest run --workspace --all-features --no-run + - name: Run tests + working_dir: Code + run: cargo nextest run --workspace --all-features + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + - uses: auguwu/clippy-action@1 + with: + token: ${{secrets.GITHUB_TOKEN}} + + fmt: + name: Formatting + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Check formatting + uses: actions-rust-lang/rustfmt@v1 diff --git a/.gitignore b/.gitignore index 6985cf1bd..5166e1ec1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + +# Code coverage artifacts +lcov.info diff --git a/Code/Cargo.toml b/Code/Cargo.toml new file mode 100644 index 000000000..9f2294dc8 --- /dev/null +++ b/Code/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] +resolver = "2" + +members = [ + "round-sm" +] diff --git a/Code/rust-toolchain.toml b/Code/rust-toolchain.toml new file mode 100644 index 000000000..292fe499e --- /dev/null +++ b/Code/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable" diff --git a/Code/rustfmt.toml b/Code/rustfmt.toml new file mode 100644 index 000000000..6641a0f46 --- /dev/null +++ b/Code/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 120 +comment_width = 100