From 565f30f223b82eb8353acb74a8f30315f59541ff Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Jun 2024 13:19:35 -0700 Subject: [PATCH 1/6] sieve: Use `saturating_add` when computing `next_base` Fixes #60, so we don't overflow `usize` on 32-bit targets at the end. --- Cargo.toml | 5 +++++ primal-sieve/src/sieve.rs | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7402c010..4662e677 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,3 +52,8 @@ tag-name = "{{crate_name}}-{{version}}" [package.metadata.release] sign-tag = true tag-name = "{{crate_name}}-{{version}}" + +# Make sure all our slow_tests still check overflows in --release tests. +# (This doesn't affect downstream dependents building these libraries.) +[profile.release] +overflow-checks = true diff --git a/primal-sieve/src/sieve.rs b/primal-sieve/src/sieve.rs index 4b2089cb..0e9f9456 100644 --- a/primal-sieve/src/sieve.rs +++ b/primal-sieve/src/sieve.rs @@ -358,7 +358,7 @@ impl Sieve { let bits = &self.seen[base].bits; let current_base = base_byte_count * wheel::BYTE_MODULO; - let next_base = current_base + bits.len() * wheel::BYTE_MODULO / 8; + let next_base = current_base.saturating_add(bits.len() * wheel::BYTE_MODULO / 8); SievePrimes { early, @@ -404,7 +404,9 @@ impl<'a> SievePrimes<'a> { match self.bits.next() { Some(Item { bits, .. }) => { self.base = self.next_base; - self.next_base += bits.len() * wheel::BYTE_MODULO / 8; + self.next_base = self + .next_base + .saturating_add(bits.len() * wheel::BYTE_MODULO / 8); self.ones = bits.ones_from(0); true }, From 526de024de3314ea460584037115072c874c61c8 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Jun 2024 13:29:08 -0700 Subject: [PATCH 2/6] Run all CI on pull requests --- .github/workflows/ci.yml | 4 ++-- .github/workflows/pr.yml | 23 ----------------------- 2 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e9da391..8147dd3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,8 @@ name: Continuous integration on: push: branches: - - staging - - trying + - master + pull_request: env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index cbf77420..00000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Pull Request -on: - pull_request: - -env: - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - -jobs: - tests: - runs-on: ubuntu-latest - strategy: - matrix: - include: - - rust: stable - - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} - - name: Tests - run: ./ci/script.sh From bc127972c5358a2d235e590e19ad869f3aca87fe Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Jun 2024 13:32:58 -0700 Subject: [PATCH 3/6] bors is dead --- bors.toml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 bors.toml diff --git a/bors.toml b/bors.toml deleted file mode 100644 index 7df51f18..00000000 --- a/bors.toml +++ /dev/null @@ -1,8 +0,0 @@ -status = [ - "tests (1.36.0)", - "tests (stable)", - "tests (beta)", - "tests (nightly)", - "tests (nightly-i686-unknown-linux-gnu)", - "tests (stable, mips64-unknown-linux-gnuabi64)", -] From d2fd72d1db7a3b4001d0e323b9186472e7601e17 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Jun 2024 13:34:03 -0700 Subject: [PATCH 4/6] Use s390x for big-endian testing --- .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 8147dd3a..71bcd873 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - rust: nightly - rust: nightly-i686-unknown-linux-gnu - rust: stable - target: mips64-unknown-linux-gnuabi64 + target: s390x-unknown-linux-gnu steps: - uses: actions/checkout@v3 From e748fc1567514254c941e7b957ca8db29c133ccc Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Jun 2024 13:40:37 -0700 Subject: [PATCH 5/6] Upgrade to actions/checkout@v4 --- .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 71bcd873..364c8092 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: target: s390x-unknown-linux-gnu steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} From 3c583c76e22f8f5a4f4c0ba51d1a01a3f45a8dfc Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Jun 2024 14:08:50 -0700 Subject: [PATCH 6/6] Add a "bors" summary status --- .github/workflows/ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 364c8092..290e776a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,3 +35,18 @@ jobs: env: TARGET: ${{ matrix.target }} run: ./ci/script.sh + + # One job that "summarizes" the success state of this pipeline. This can then be added to branch + # protection, rather than having to add each job separately. + success: + name: bors + runs-on: ubuntu-latest + needs: [tests] + # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency + # failed" as success. So we have to do some contortions to ensure the job fails if any of its + # dependencies fails. + if: always() # make sure this is never "skipped" + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: check if any dependency failed + run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'