Skip to content

Commit 958b46f

Browse files
authored
Merge pull request #27 from rust-cv/update_ci
update CI script
2 parents 25da00e + b2ca229 commit 958b46f

File tree

4 files changed

+37
-56
lines changed

4 files changed

+37
-56
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,79 +11,60 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout sources
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1515

1616
- name: Install beta toolchain
17-
uses: actions-rs/toolchain@v1
17+
uses: dtolnay/rust-toolchain@beta
1818
with:
19-
profile: minimal
20-
toolchain: beta
21-
override: true
2219
components: rustfmt, clippy
2320

2421
- name: Set up cache
25-
uses: Swatinem/rust-cache@v1
22+
uses: Swatinem/rust-cache@v2
2623
with:
2724
cache-on-failure: true
2825

2926
- name: Run cargo fmt
30-
uses: actions-rs/cargo@v1
31-
with:
32-
command: fmt
33-
args: --all -- --check
27+
run: cargo fmt --all -- --check
3428

3529
- name: Run cargo clippy
36-
uses: actions-rs/cargo@v1
37-
with:
38-
command: clippy
39-
args: --tests -- -D warnings
30+
run: cargo clippy --all-targets --tests -- -D warnings
4031

4132
no_std:
4233
name: no_std
4334
runs-on: ubuntu-latest
4435
steps:
4536
- name: Checkout sources
46-
uses: actions/checkout@v2
37+
uses: actions/checkout@v4
4738

48-
- name: Install beta toolchain
49-
uses: actions-rs/toolchain@v1
39+
- name: Install beta toolchain for ARM
40+
uses: dtolnay/rust-toolchain@beta
5041
with:
51-
profile: minimal
52-
toolchain: beta
53-
target: armv7a-none-eabi
54-
override: true
42+
targets: armv7a-none-eabi
5543

5644
- name: Set up cache
57-
uses: Swatinem/rust-cache@v1
45+
uses: Swatinem/rust-cache@v2
5846
with:
5947
cache-on-failure: true
6048

6149
- name: Build binary for armv7a-none-eabi
62-
uses: actions-rs/cargo@v1
63-
with:
64-
command: rustc
65-
args: --target=armv7a-none-eabi --manifest-path=ensure_no_std/Cargo.toml
50+
run: cargo rustc --target=armv7a-none-eabi --manifest-path=ensure_no_std/Cargo.toml
6651

6752
tests:
6853
name: tests
6954
runs-on: ubuntu-latest
7055
steps:
7156
- name: Checkout sources
72-
uses: actions/checkout@v2
57+
uses: actions/checkout@v4
7358

7459
- name: Install beta toolchain
75-
uses: actions-rs/toolchain@v1
76-
with:
77-
profile: minimal
78-
toolchain: beta
79-
override: true
60+
uses: dtolnay/rust-toolchain@beta
8061

8162
- name: Set up cache
82-
uses: Swatinem/rust-cache@v1
63+
uses: Swatinem/rust-cache@v2
8364
with:
8465
cache-on-failure: true
8566

8667
- name: Run cargo test
87-
uses: actions-rs/cargo@v1
88-
with:
89-
command: test
68+
# run: cargo test --all-features --no-fail-fast --locked --workspace -- --nocapture
69+
# run: cargo test --all-features --no-fail-fast --workspace -- --nocapture
70+
run: cargo test --features "" --no-fail-fast --workspace -- --nocapture

Cargo.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,19 @@ minpack-compat = []
2626

2727
[dependencies]
2828
nalgebra = { version = "0.34", default-features = false }
29-
num-traits = { version = "0.2", default-features = false, features = [
30-
"libm",
31-
] }
32-
cfg-if = "1.0.0"
29+
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
30+
cfg-if = "1.0.1"
3331

3432
[dev-dependencies]
35-
arrsac = "0.10.0"
36-
rand = { version = "0.8.4", default-features = false }
33+
arrsac = "0.11.0"
34+
rand = { version = "0.9.2", default-features = false }
35+
rand_chacha = "0.9.0"
3736
nalgebra = "0.34"
38-
pcg_rand = "0.13.0"
3937
sample-consensus = "1.0.2"
4038
approx = "0.5.1"
4139

4240
[build-dependencies]
43-
rustc_version = "0.4.0"
41+
rustc_version = "0.4.1"
4442

4543
[profile.test]
4644
# The line fitting test case needs this to run in reasonable amount of time

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@
6363
//! type ResidualStorage = Owned<f64, U2>;
6464
//! type JacobianStorage = Owned<f64, U2, U2>;
6565
//!
66-
//! fn set_params(&mut self, p: &VectorN<f64, U2>) {
66+
//! fn set_params(&mut self, p: &Vector2<f64>) {
6767
//! self.p.copy_from(p);
6868
//! // do common calculations for residuals and the Jacobian here
6969
//! }
7070
//!
71-
//! fn params(&self) -> VectorN<f64, U2> { self.p }
71+
//! fn params(&self) -> Vector2<f64> { self.p }
7272
//!
7373
//! fn residuals(&self) -> Option<Vector2<f64>> {
7474
//! let [x, y] = [self.p.x, self.p.y];

tests/line_fitting.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ use nalgebra::{
55
storage::Owned,
66
Dim, Dyn, Matrix, Matrix2, OMatrix, VecStorage, Vector2,
77
};
8-
use pcg_rand::Pcg64;
9-
use rand::distributions::Uniform;
10-
use rand::{distributions::Distribution, Rng};
8+
use rand::{
9+
distr::{Distribution, Uniform},
10+
Rng, SeedableRng,
11+
};
12+
use rand_chacha::ChaCha20Rng;
1113
use sample_consensus::{Consensus, Estimator, Model};
1214

1315
type F = f64;
@@ -134,27 +136,27 @@ impl<'a> LeastSquaresProblem<F, Dyn, U2> for LineFittingOptimizationProblem<'a>
134136

135137
#[test]
136138
fn lines() {
137-
let mut rng = Pcg64::new_unseeded();
139+
let mut rng = ChaCha20Rng::seed_from_u64(0);
138140
// The max candidate hypotheses had to be increased dramatically to ensure all 1000 cases find a
139141
// good-fitting line.
140-
let mut arrsac = Arrsac::new(5.0, Pcg64::new_unseeded());
142+
let mut arrsac = Arrsac::new(5.0, ChaCha20Rng::seed_from_u64(1));
141143
let mut would_have_failed = false;
142144
for _ in 0..LINES_TO_ESTIMATE {
143145
// Generate <a, b> and normalize.
144146
let normal =
145-
Vector2::new(rng.gen_range(-10.0..10.0), rng.gen_range(-10.0..10.0)).normalize();
147+
Vector2::new(rng.random_range(-10.0..10.0), rng.random_range(-10.0..10.0)).normalize();
146148
let normal_angle = F::atan2(normal[1], normal[0]);
147149
// Get parallel ray.
148150
let ray = Vector2::new(normal.y, -normal.x);
149151
// Generate random c.
150-
let c = rng.gen_range(-10.0..10.0);
152+
let c = rng.random_range(-10.0..10.0);
151153

152154
// Generate random number of points.
153-
let num = rng.gen_range(100..1000);
155+
let num = rng.random_range(100..1000);
154156
// The points should be no more than 5.0 away from the line and be evenly distributed away from the line.
155-
let residuals = Uniform::new(-5.0, 5.0);
157+
let residuals = Uniform::new(-5.0, 5.0).unwrap();
156158
// The points must be generated along the line, but the distance should be bounded to make it more difficult.
157-
let distances = Uniform::new(-50.0, 50.0);
159+
let distances = Uniform::new(-50.0, 50.0).unwrap();
158160
// Generate the points.
159161
let points: Vec<Vector2<F>> = (0..num)
160162
.map(|_| {

0 commit comments

Comments
 (0)