Skip to content

Commit

Permalink
👷 Setup CI job matrix to run cargo test (#17)
Browse files Browse the repository at this point in the history
* 👷 Setup CI job matrix for cargo test

Ensure that Rust unit tests and doctests are checked too. Running on Ubuntu-24.04.

* 📌 Test on Rust stable, beta and nightly toolchains

Test on all three release channels of Rust.

* 🚩 Add --crate-type=rlib compilation target

Needed to enable doctests, otherwise `cargo test --doc` would error with "warning: doc tests are not supported for crate type(s) `cdylib` in package `cog3pio`". Xref https://users.rust-lang.org/t/how-to-run-only-the-doctests/54048/2 and rust-lang/cargo#4717.

* 💚 Fix broken doctest due to mismatched Array type

Update docstring in src/lib.rs to check for an Array3 output from the read_geotiff function. Patches bca4c18.
  • Loading branch information
weiji14 authored Jul 8, 2024
1 parent 1009387 commit ebd2a31
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,34 @@ on:
types: [ opened, reopened, synchronize ]
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

permissions:
contents: read

jobs:
rust:
runs-on: ubuntu-24.04
strategy:
matrix:
toolchain:
- stable
- beta
- nightly
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Update Rust toolchain
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

linux:
runs-on: ubuntu-22.04
strategy:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "cog3pio"
crate-type = ["cdylib"]
crate-type = ["cdylib", "rlib"]

[dependencies]
bytes = "1.5.0"
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//!
//! use bytes::Bytes;
//! use cog3pio::io::geotiff::read_geotiff;
//! use ndarray::Array2;
//! use ndarray::Array3;
//! use object_store::path::Path;
//! use object_store::{parse_url, GetResult, ObjectStore};
//! use tokio;
Expand All @@ -38,9 +38,9 @@
//! Cursor::new(bytes)
//! };
//!
//! let arr: Array2<f32> = read_geotiff(stream).unwrap();
//! assert_eq!(arr.dim(), (549, 549));
//! assert_eq!(arr[[500, 500]], 0.13482364);
//! let arr: Array3<f32> = read_geotiff(stream).unwrap();
//! assert_eq!(arr.dim(), (1, 549, 549));
//! assert_eq!(arr[[0, 500, 500]], 0.13482364);
//! }
//! ```

Expand Down

0 comments on commit ebd2a31

Please sign in to comment.