From 04b3d4bd84a1083689ca863b0436f4a7422ac212 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 27 Feb 2023 15:49:20 +0000 Subject: [PATCH 1/4] Update CI - Removes dependencies on unmaintained actions. - Added bitrot and rustfmt checks. - We now require `clippy` and `rustfmt` be installed as part of the toolchain, which is fine as contributors will need them to satisfy CI. --- .github/workflows/ci.yml | 101 ++++++++++------------------- .github/workflows/lints-beta.yml | 24 +++++++ .github/workflows/lints-stable.yml | 18 +++++ rust-toolchain | 1 - rust-toolchain.toml | 3 + 5 files changed, 78 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/lints-beta.yml create mode 100644 .github/workflows/lints-stable.yml delete mode 100644 rust-toolchain create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fbf3dda..5df85c65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,25 +3,6 @@ name: CI checks on: [push, pull_request] jobs: - lint: - name: Lint - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.56.0 - override: true - - # Ensure all code has been formatted with rustfmt - - run: rustup component add rustfmt - - name: Check formatting - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check --color always - test: name: Test on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -30,25 +11,9 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.56.0 - override: true - - name: cargo fetch - uses: actions-rs/cargo@v1 - with: - command: fetch - - name: Build tests - uses: actions-rs/cargo@v1 - with: - command: build - args: --verbose --release --tests --features experimental,zeroize + - uses: actions/checkout@v3 - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --verbose --release --features experimental,zeroize + run: cargo test --verbose --release --features experimental,zeroize no-std: name: Check no-std target ${{ matrix.target }} @@ -61,41 +26,41 @@ jobs: - wasm32-wasi steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.56.0 - override: true + - uses: actions/checkout@v3 - run: rustup target add ${{ matrix.target }} - - name: cargo fetch - uses: actions-rs/cargo@v1 - with: - command: fetch + - run: cargo fetch - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --verbose --target ${{ matrix.target }} --no-default-features --features groups,pairings + run: > + cargo build + --verbose + --target ${{ matrix.target }} + --no-default-features + --features groups,pairings - doc-links: - name: Nightly lint + bitrot: + name: Bitrot check runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: cargo fetch - uses: actions-rs/cargo@v1 - with: - command: fetch + - uses: actions/checkout@v3 + # Build benchmarks and all-features to prevent bitrot + - name: Build benchmarks + run: cargo build --benches --examples --all-features - # Ensure intra-documentation links all resolve correctly - # Requires #![deny(intra_doc_link_resolution_failure)] in crate. + doc-links: + name: Intra-doc links + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: cargo fetch + # Requires #![deny(rustdoc::broken_intra_doc_links)] in crate. - name: Check intra-doc links - uses: actions-rs/cargo@v1 - with: - command: doc - args: --document-private-items + run: cargo doc --document-private-items + + fmt: + name: Rustfmt + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check formatting + run: cargo fmt --all -- --check diff --git a/.github/workflows/lints-beta.yml b/.github/workflows/lints-beta.yml new file mode 100644 index 00000000..4440b58f --- /dev/null +++ b/.github/workflows/lints-beta.yml @@ -0,0 +1,24 @@ +name: Beta lints + +# These lints are only informative, so we only run them directly on branches +# and not trial-merges of PRs, to reduce noise. +on: push + +jobs: + clippy-beta: + name: Clippy (beta) + timeout-minutes: 30 + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@beta + id: toolchain + - run: rustup override set ${{steps.toolchain.outputs.name}} + - name: Run Clippy (beta) + uses: actions-rs/clippy-check@v1 + continue-on-error: true + with: + name: Clippy (beta) + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features --all-targets -- -W clippy::all diff --git a/.github/workflows/lints-stable.yml b/.github/workflows/lints-stable.yml new file mode 100644 index 00000000..1e697ef6 --- /dev/null +++ b/.github/workflows/lints-stable.yml @@ -0,0 +1,18 @@ +name: Stable lints + +# We only run these lints on trial-merges of PRs to reduce noise. +on: pull_request + +jobs: + clippy: + name: Clippy (MSRV) + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run clippy + uses: actions-rs/clippy-check@v1 + with: + name: Clippy (MSRV) + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features --all-targets -- -D warnings diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 3ebf789f..00000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.56.0 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..de43b230 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.56.0" +components = [ "clippy", "rustfmt" ] From a1965f3224c536d8f357f28ac9237dfd91482aa3 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 27 Feb 2023 15:51:02 +0000 Subject: [PATCH 2/4] Add Dependabot config --- .github/dependabot.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..5c4156c6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + timezone: Etc/UTC + open-pull-requests-limit: 10 + reviewers: + - str4d + assignees: + - str4d + labels: + - "A-CI" From d6016933adcf7a9280ff303958a34bf4fdb6fb7a Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 27 Feb 2023 15:57:48 +0000 Subject: [PATCH 3/4] Restrict dev-dependencies to `csv < 1.2` We only have this dependency for `criterion`, so it doesn't need to affect the crate MSRV. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index fba2e75f..b923d4d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ edition = "2021" rustdoc-args = [ "--html-in-header", "katex-header.html" ] [dev-dependencies] +csv = ">= 1.0, < 1.2" # csv 1.2 has MSRV 1.60 criterion = "0.3" hex = "0.4" rand_xorshift = "0.3" From 477b97cc214e5ebab42c316d320199c0dee3e281 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 27 Feb 2023 16:26:50 +0000 Subject: [PATCH 4/4] Fix clippy lint --- src/hash_to_curve/map_scalar.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hash_to_curve/map_scalar.rs b/src/hash_to_curve/map_scalar.rs index bec8a4a8..ec4bb9e0 100644 --- a/src/hash_to_curve/map_scalar.rs +++ b/src/hash_to_curve/map_scalar.rs @@ -10,7 +10,7 @@ impl HashToField for Scalar { fn from_okm(okm: &GenericArray) -> Scalar { let mut bs = [0u8; 64]; - bs[16..].copy_from_slice(&okm); + bs[16..].copy_from_slice(okm); bs.reverse(); // into little endian Scalar::from_bytes_wide(&bs) }