From 97e52802f30288586c948d6af97da718babe56bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 12 Nov 2022 15:03:45 -0600 Subject: [PATCH 01/14] Update criterion requirement from 0.3 to 0.4 (#22) * Update criterion requirement from 0.3 to 0.4 Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version. - [Release notes](https://github.com/bheisler/criterion.rs/releases) - [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/bheisler/criterion.rs/compare/0.3.0...0.4.0) --- updated-dependencies: - dependency-name: criterion dependency-type: direct:production ... Signed-off-by: dependabot[bot] * cargo clippy Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: John Nystrom --- Cargo.toml | 2 +- src/fits/header.rs | 7 +------ src/fits/mod.rs | 6 +++--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 43dd307..4cc4f22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ thiserror = { version = "1.0" } urlencoding = { version = "2.1", optional = true } [dev-dependencies] -criterion = { version = "0.3", features = ["html_reports"] } +criterion = { version = "0.4", features = ["html_reports"] } image = { version = "0.24", default-features = false, features = ["jpeg"] } tokio-test = { version = "0.4" } diff --git a/src/fits/header.rs b/src/fits/header.rs index b02104a..99bbe84 100644 --- a/src/fits/header.rs +++ b/src/fits/header.rs @@ -140,12 +140,7 @@ impl FitsHeader { &mut self, keyword: K, ) -> Option<&mut FitsHeaderCard> { - for card in self.cards.iter_mut() { - if keyword == card.keyword { - return Some(card); - } - } - None + self.cards.iter_mut().find(|card| keyword == card.keyword) } /// Sets the value and comment of the card with the given keyword. diff --git a/src/fits/mod.rs b/src/fits/mod.rs index 14652a2..509d124 100644 --- a/src/fits/mod.rs +++ b/src/fits/mod.rs @@ -472,7 +472,7 @@ impl FitsDataCollection for Vec { fn to_bytes(&self) -> Vec { let mut data = Vec::with_capacity(self.len() * 4); - for chunk in &*self { + for chunk in self { data.extend_from_slice(&chunk.to_be_bytes()); } data @@ -490,7 +490,7 @@ impl FitsDataCollection for Vec { fn to_bytes(&self) -> Vec { let mut data = Vec::with_capacity(self.len() * 4); - for chunk in &*self { + for chunk in self { data.extend_from_slice(&chunk.to_be_bytes()); } data @@ -508,7 +508,7 @@ impl FitsDataCollection for Vec { fn to_bytes(&self) -> Vec { let mut data = Vec::with_capacity(self.len() * 8); - for chunk in &*self { + for chunk in self { data.extend_from_slice(&chunk.to_be_bytes()); } data From 90172e14c44d48a0e0ae38957d96e91e8599c4a9 Mon Sep 17 00:00:00 2001 From: John Nystrom <66807409+eta077@users.noreply.github.com> Date: Tue, 20 Dec 2022 11:56:27 -0600 Subject: [PATCH 02/14] Correct badge URLs --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e80df24..909689b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -![GitHub Build Status (branch)](https://img.shields.io/github/workflow/status/eta077/astro-rs/Build/release) ![GitHub Test Status (branch)](https://img.shields.io/github/workflow/status/eta077/astro-rs/Test/release?label=test) [![codecov](https://codecov.io/gh/eta077/astro-rs/branch/release/graph/badge.svg)](https://codecov.io/gh/eta077/astro-rs) [![docs.rs](https://img.shields.io/docsrs/astro-rs)](https://docs.rs/astro-rs/latest/astro_rs/) +![GitHub Build Status (branch)](https://img.shields.io/github/actions/workflow/status/eta077/astro-rs/build.yml?branch=release) +![GitHub Test Status (branch)](https://img.shields.io/github/actions/workflow/status/eta077/astro-rs/test.yml?branch=release&label=test) +[![codecov](https://codecov.io/gh/eta077/astro-rs/branch/release/graph/badge.svg)](https://codecov.io/gh/eta077/astro-rs) +[![docs.rs](https://img.shields.io/docsrs/astro-rs)](https://docs.rs/astro-rs/latest/astro_rs/) # astro-rs This library provides utilities to interact with astronomical data. From a851c02e3c250b67bb5c9da032cbc67051a29959 Mon Sep 17 00:00:00 2001 From: John Nystrom <66807409+eta077@users.noreply.github.com> Date: Tue, 21 Mar 2023 19:44:32 -0500 Subject: [PATCH 03/14] Prep for coordinate-lookup merge (#24) --- .github/workflows/build.yml | 4 +- .github/workflows/test.yml | 59 ++++++--------- Cargo.toml | 11 ++- README.md | 8 +- src/coordinates/frames.rs | 34 ++++++--- src/coordinates/lookup.rs | 125 ++++++++++++++++++++----------- src/coordinates/lookup_config.rs | 79 +++++++++++++++++++ src/coordinates/mod.rs | 76 ++++++++++--------- src/fits/header.rs | 26 +++++++ src/fits/mod.rs | 19 +++++ tests/coordinates.rs | 25 +++---- 11 files changed, 322 insertions(+), 144 deletions(-) create mode 100644 src/coordinates/lookup_config.rs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b83c60..3022a0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: profile: minimal toolchain: stable override: true - - run: rustup component add rustfmt + components: rustfmt - uses: actions-rs/cargo@v1 with: command: fmt @@ -52,7 +52,7 @@ jobs: profile: minimal toolchain: stable override: true - - run: rustup component add clippy + components: clippy - uses: actions-rs/cargo@v1 with: command: clippy diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9d4d736..8f3b395 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,46 +13,35 @@ name: Test jobs: test: name: Test with coverage - env: - PROJECT_NAME_UNDERSCORE: astro_rs - CARGO_INCREMENTAL: 0 - RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort - RUSTDOCFLAGS: -Cpanic=abort runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: stable override: true - - name: Cache dependencies - uses: actions/cache@v2 - env: - cache-name: cache-dependencies - with: - path: | - ~/.cargo/.crates.toml - ~/.cargo/.crates2.json - ~/.cargo/bin - ~/.cargo/registry/index - ~/.cargo/registry/cache - target - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }} - - name: Generate test result and coverage report + components: llvm-tools-preview + + - uses: Swatinem/rust-cache@v1 + + - name: Download grcov run: | - cargo install cargo2junit grcov; - cargo test --all-features $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml; - zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`; - grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info; - - name: Upload test results - uses: EnricoMi/publish-unit-test-result-action@v1 - with: - check_name: Test Results - github_token: ${{ secrets.GITHUB_TOKEN }} - files: results.xml - - name: Upload to CodeCov + cargo install grcov + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Run coverage + run: | + rm -rf coverage + mkdir coverage + CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test + grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" -o coverage/tests.lcov + rm -rf *.profraw + + - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./lcov.info - fail_ci_if_error: true \ No newline at end of file + files: coverage/*.lcov + fail_ci_if_error: true diff --git a/Cargo.toml b/Cargo.toml index 4cc4f22..72d9edc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,10 +21,13 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -chrono = { version = "0.4", optional = true } +hifitime = { version = "3.6", optional = true } hyper = { version = "0.14", features = ["client", "http1", "tcp"], optional = true } -measurements = { version = "0.11", optional = true } +once_cell = { version = "1.16", optional = true } +regex = { version = "1.7", optional = true } +rust_decimal = { version = "1.29" } thiserror = { version = "1.0" } +uom = { version = "0.33", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } urlencoding = { version = "2.1", optional = true } [dev-dependencies] @@ -33,8 +36,8 @@ image = { version = "0.24", default-features = false, features = ["jpeg"] } tokio-test = { version = "0.4" } [features] -default = ["fits"] -coordinates = ["dep:chrono", "dep:hyper", "dep:measurements", "dep:urlencoding"] +default = ["coordinates", "fits"] +coordinates = ["dep:hifitime", "dep:hyper", "dep:once_cell", "dep:regex", "dep:uom", "dep:urlencoding"] cosmology = [] fits = [] diff --git a/README.md b/README.md index 909689b..0096f2d 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,16 @@ Inspired by Astropy ( / * Equal or surpass the Astropy benchmarks ## Technical goals +* Use pure Rust as opposed to wrapping other libraries * Deserialize as lazily as possible -* Balance 'tight' () types and adherance to the FITS API with graceful handling of deviation +* Balance 'tight' () types and adherance to APIs with graceful handling of deviation # Testing Test assets are from the following sources: * * + +# Licensing +* Original code is licensed under the MIT license +* `astropy` is licensed under BSD-3-Clause +* `hifitime` is licensed under Apache-2.0 diff --git a/src/coordinates/frames.rs b/src/coordinates/frames.rs index 7219f34..44bc412 100644 --- a/src/coordinates/frames.rs +++ b/src/coordinates/frames.rs @@ -1,24 +1,40 @@ -use chrono::{DateTime, Utc}; +use hifitime::Epoch; +use thiserror::Error; -use super::{EarthLocation, EquatorialCoord, HorizontalCoord}; +use super::{EarthLocation, EquatorialCoord}; + +/// An enumeration of errors that can occur while converting coordinates from one frame to another. +#[derive(Debug, Error)] +pub enum AstroConversionError {} /// Coordinates in the International Celestial Reference System. -#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct Icrs { /// The coordinate value pub coords: EquatorialCoord, } impl Icrs { - /// Converts coordinates from ICRS to AltAz - pub fn as_alt_az(&self, _date_time: &DateTime, _location: &EarthLocation) -> AltAz { - AltAz::default() + /// Creates a new Icrs with the coordinate values rounded to the specified decimal place. + pub fn round(&self, dp: u32) -> Self { + Self { + coords: self.coords.round(dp), + } + } + + /// Converts coordinates from ICRS to observed AltAz coordinates. + pub fn to_alt_az( + &self, + _date_time: &Epoch, + _location: &EarthLocation, + ) -> Result { + Ok(AltAz::default()) } } -/// Coordinates -#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +/// Coordinates with respect to the WGS84 ellipsoid. +#[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct AltAz { /// The coordinate value - pub coords: HorizontalCoord, + pub coords: EquatorialCoord, } diff --git a/src/coordinates/lookup.rs b/src/coordinates/lookup.rs index ccd530e..2fd2b2f 100644 --- a/src/coordinates/lookup.rs +++ b/src/coordinates/lookup.rs @@ -1,18 +1,31 @@ use super::frames::Icrs; +use super::lookup_config::SesameConfig; use super::EquatorialCoord; +use hyper::client::HttpConnector; use hyper::Client; -use measurements::Angle; +use once_cell::sync::OnceCell; +use regex::Regex; use thiserror::Error; +use uom::si::angle::{degree, Angle}; use urlencoding::encode; -const SIMBAD_BASE_URL: &str = - "http://simbad.u-strasbg.fr/simbad/sim-id?output.format=votable&Ident="; -const SIMBAD_OUTPUT_PARAMS: &str = "&output.params=ra(d;ICRS;J2000;2000),dec(d;ICRS;J2000;2000)"; +static SESAME_CONFIG: OnceCell = OnceCell::new(); +static SESAME_PARSER: OnceCell = OnceCell::new(); + +fn init_sesame_parser() -> Regex { + Regex::new(r"%J\s*([0-9\.]+)\s*([\+\-\.0-9]+)").unwrap() +} /// An enumeration of errors that can occur while performing a coordinate lookup. #[derive(Debug, Error)] pub enum AstroLookupError { + /// Indicates the environmental variables contributing to the SESAME configuration are invalid. + #[error("Invalid configuration: {reason}")] + InvalidConfiguration { + /// The reason the configuration is invalid. + reason: String, + }, /// Indicates an error occurred while obtaining the coordinate data. #[error(transparent)] NetworkError(#[from] hyper::Error), @@ -32,15 +45,18 @@ pub enum AstroLookupError { /// Fetches the coordinates of an object with the given identifier. /// +/// # Examples +/// /// ``` /// use astro_rs::coordinates::{self, *}; -/// use measurements::Angle; +/// use uom::si::angle::radian; +/// use uom::si::f64::Angle; /// /// let m33_coords = tokio_test::block_on(async { coordinates::lookup_by_name("M33").await })?; -/// assert_eq!(m33_coords, Icrs { +/// assert_eq!(m33_coords.round(4), Icrs { /// coords: EquatorialCoord { -/// ra: Angle::from_degrees(23.46206906218), -/// dec: Angle::from_degrees(30.66017511198) +/// ra: Angle::new::(0.4095), +/// dec: Angle::new::(0.5351) /// }, /// }); /// @@ -51,8 +67,43 @@ pub enum AstroLookupError { /// # Ok::<(), astro_rs::coordinates::AstroLookupError>(()) /// ``` pub async fn lookup_by_name(name: &str) -> Result { + let sesame_config = SESAME_CONFIG.get_or_init(SesameConfig::init); + let sesame_parser = SESAME_PARSER.get_or_init(init_sesame_parser); let client = Client::new(); - let uri_string = [SIMBAD_BASE_URL, &encode(name), SIMBAD_OUTPUT_PARAMS].concat(); + + let mut err_result = Err(AstroLookupError::InvalidConfiguration { + reason: String::from("No configured SESAME URLs"), + }); + + for url in &sesame_config.urls { + let uri_string = [ + url.as_str(), + if url.ends_with('/') { "" } else { "/" }, + "~", + sesame_config.database.to_str(), + "?", + &encode(name), + ] + .concat(); + + let result = lookup_by_uri(name, sesame_parser, &client, uri_string).await; + + if result.is_ok() { + return result; + } else { + err_result = result; + } + } + + err_result +} + +async fn lookup_by_uri( + name: &str, + sesame_parser: &Regex, + client: &Client, + uri_string: String, +) -> Result { let uri = uri_string .parse() .map_err(|_| AstroLookupError::InvalidName { @@ -60,48 +111,36 @@ pub async fn lookup_by_name(name: &str) -> Result { })?; let response = client.get(uri).await?; - let text_buf = hyper::body::to_bytes(response).await?; - let xml_string = String::from_utf8(text_buf.as_ref().to_vec()).map_err(|er| { + let body_bytes = hyper::body::to_bytes(response).await?; + let body_string = String::from_utf8(body_bytes.as_ref().to_vec()).map_err(|er| { AstroLookupError::ParseError { reason: er.to_string(), } })?; - if !xml_string.contains("") { - return Err(AstroLookupError::InvalidName { - name: name.to_owned(), - }); - } - let mut xml_parts = xml_string.split(""); - let ra = if let Some(ra_string) = xml_parts.nth(1) { - let ra_trimmed = ra_string.trim_end_matches(|c: char| !c.is_numeric()); - ra_trimmed + if let Some(cap) = sesame_parser.captures(&body_string) { + let ra_string = &cap[1]; + let dec_string = &cap[2]; + + let ra: f64 = ra_string .parse() .map_err(|_| AstroLookupError::ParseError { - reason: ["Could not parse ra value: ", ra_trimmed].concat(), - })? - } else { - return Err(AstroLookupError::ParseError { - reason: String::from("Could not find ra value"), - }); - }; - let dec = if let Some(dec_string) = xml_parts.next() { - let dec_trimmed = dec_string.trim_end_matches(|c: char| !c.is_numeric()); - dec_trimmed + reason: ["Could not parse ra value: ", ra_string].concat(), + })?; + let dec: f64 = dec_string .parse() .map_err(|_| AstroLookupError::ParseError { - reason: ["Could not parse dec value: ", dec_trimmed].concat(), - })? - } else { - return Err(AstroLookupError::ParseError { - reason: String::from("Could not find dec value"), - }); - }; - - Ok(Icrs { - coords: EquatorialCoord { - ra: Angle::from_degrees(ra), - dec: Angle::from_degrees(dec), - }, + reason: ["Could not parse dec value: ", dec_string].concat(), + })?; + + let coords = EquatorialCoord { + ra: Angle::new::(ra), + dec: Angle::new::(dec), + }; + return Ok(Icrs { coords }); + } + + Err(AstroLookupError::InvalidName { + name: name.to_owned(), }) } diff --git a/src/coordinates/lookup_config.rs b/src/coordinates/lookup_config.rs new file mode 100644 index 0000000..3a44415 --- /dev/null +++ b/src/coordinates/lookup_config.rs @@ -0,0 +1,79 @@ +use std::env; +use std::error::Error; + +/// An enumeration of SESAME database options +#[allow(missing_docs)] +pub enum SesameDatabase { + /// Indicates all available databases should be queried + All, + Simbad, + Ned, + Vizier, +} + +impl SesameDatabase { + /// Returns the abbreviation for the database, usable in the query URL. + pub fn to_str(&self) -> &str { + match self { + SesameDatabase::All => "A", + SesameDatabase::Simbad => "S", + SesameDatabase::Ned => "N", + SesameDatabase::Vizier => "V", + } + } +} + +impl TryFrom for SesameDatabase { + type Error = String; + + fn try_from(value: String) -> Result { + match value.to_ascii_lowercase().as_str() { + "a" | "all" => Ok(SesameDatabase::All), + "s" | "simbad" => Ok(Self::Simbad), + "n" | "ned" => Ok(Self::Ned), + "v" | "vizier" => Ok(Self::Vizier), + _ => Err(["Unknown SESAME database option: ", &value].concat()), + } + } +} + +/// Configuration for SESAME queries. +pub struct SesameConfig { + /// The SESAME database to query. + pub database: SesameDatabase, + /// The URL at which the SESAME service is hosted. + pub urls: Vec, +} + +impl Default for SesameConfig { + fn default() -> Self { + Self { + database: SesameDatabase::All, + urls: vec![ + String::from("http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/"), + String::from("http://vizier.cfa.harvard.edu/viz-bin/nph-sesame/"), + ], + } + } +} + +impl SesameConfig { + /// Constructs a new SesameConfig. The associated environment variables + /// (SESAME_DATABASE and SESAME_URLS) are examined first; if those + /// variables cannot be parsed, a config with default values is returned. + pub fn init() -> Self { + Self::from_env().unwrap_or_default() + } + + fn from_env() -> Result> { + let database = SesameDatabase::try_from(env::var("SESAME_DATABASE")?)?; + let urls: Vec = env::var("SESAME_URLS")? + .split_ascii_whitespace() + .map(|s| s.to_owned()) + .collect(); + if urls.is_empty() { + return Err("At least one SESAME URL must be present".into()); + } + Ok(Self { database, urls }) + } +} diff --git a/src/coordinates/mod.rs b/src/coordinates/mod.rs index ad2d35d..2cb07dc 100644 --- a/src/coordinates/mod.rs +++ b/src/coordinates/mod.rs @@ -2,32 +2,19 @@ mod frames; mod lookup; +mod lookup_config; -use measurements::{Angle, Distance}; +use rust_decimal::Decimal; +use uom::si::angle::radian; +use uom::si::f64::{Angle, Length}; +use uom::ConstZero; pub use frames::*; pub use lookup::*; - -/// Horizontal coordinates expressed as (altitude, azimuth) -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct HorizontalCoord { - /// The altitude angle - pub alt: Angle, - /// The azimuth angle - pub az: Angle, -} - -impl Default for HorizontalCoord { - fn default() -> Self { - HorizontalCoord { - alt: Angle::from_radians(0.0), - az: Angle::from_radians(0.0), - } - } -} +pub use lookup_config::*; /// Equitorial coordinates expressed as (right ascension, declination) -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct EquatorialCoord { /// The right ascension angle pub ra: Angle, @@ -35,32 +22,49 @@ pub struct EquatorialCoord { pub dec: Angle, } -impl Default for EquatorialCoord { - fn default() -> Self { +impl EquatorialCoord { + /// Constructs an EquitorialCoord. The given right ascension and declination angles will be normalized to [0.0, 2π) + pub fn new(ra: Angle, dec: Angle) -> Self { + Self { + ra: Self::normalize(ra), + dec: Self::normalize(dec), + } + } + + fn normalize(a: Angle) -> Angle { + if a < Angle::ZERO { + (a % Angle::FULL_TURN) + Angle::FULL_TURN + } else { + a % Angle::FULL_TURN + } + } + + /// Creates a new EquitorialCoord with the angle values rounded to the specified decimal place. + pub fn round(&self, dp: u32) -> Self { + let ra = Decimal::from_f64_retain(self.ra.value) + .unwrap() + .round_dp(dp) + .try_into() + .unwrap(); + let dec = Decimal::from_f64_retain(self.dec.value) + .unwrap() + .round_dp(dp) + .try_into() + .unwrap(); Self { - ra: Angle::from_radians(0.0), - dec: Angle::from_radians(0.0), + ra: Angle::new::(ra), + dec: Angle::new::(dec), } } } /// Coordinates that represent a location on Earth. -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct EarthLocation { /// The latitude coordinate pub lat: Angle, /// The longitude coordinate pub lon: Angle, /// The height of the location - pub height: Distance, -} - -impl Default for EarthLocation { - fn default() -> Self { - Self { - lat: Angle::from_radians(0.0), - lon: Angle::from_radians(0.0), - height: Distance::from_meters(0.0), - } - } + pub height: Length, } diff --git a/src/fits/header.rs b/src/fits/header.rs index 99bbe84..3b8222d 100644 --- a/src/fits/header.rs +++ b/src/fits/header.rs @@ -63,6 +63,8 @@ impl FitsHeader { /// Constructs a FitsHeader from the given bytes. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// use std::rc::Rc; @@ -105,6 +107,8 @@ impl FitsHeader { /// Serializes the header into bytes. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -129,6 +133,8 @@ impl FitsHeader { /// Searches the header cards for a match with the given keyword. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -147,6 +153,8 @@ impl FitsHeader { /// If a card already exists, the data is overwritten. /// If a card does not exist, one is created. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// use std::rc::Rc; @@ -200,6 +208,8 @@ impl FitsHeader { /// If a card already exists, the value is overwritten, and the comment is retained. /// If a card does not exist, one is created. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// use std::rc::Rc; @@ -255,6 +265,8 @@ impl FitsHeader { /// If a card already exists, the comment is overwritten, and the value is retained. /// If a card does not exist, this function has no effect. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// use std::rc::Rc; @@ -283,6 +295,8 @@ impl FitsHeader { /// A card within an HDU header section. /// +/// # Examples +/// /// ``` /// use astro_rs::fits::FitsHeaderCard; /// @@ -315,6 +329,8 @@ impl FitsHeaderCard { /// If the value has not yet been deserialized, the deserialization process is attempted. /// If the process succeeds, the deserialized value is cached. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -333,6 +349,8 @@ impl FitsHeaderCard { /// Gets the comment section of the header card. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::FitsHeaderCard; /// @@ -370,6 +388,8 @@ impl From for [u8; 80] { /// A FITS header keyword. /// This wrapper provides functions to interact with both raw arrays and strings. /// +/// # Examples +/// /// ``` /// use astro_rs::fits::FitsHeaderKeyword; /// @@ -389,6 +409,8 @@ impl FitsHeaderKeyword { /// Appends the given number to the keyword. /// If a number is already appended, it is replaced by the given number. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -513,6 +535,8 @@ impl FitsHeaderValueContainer { /// If the value has not yet been deserialized, the deserialization process is attempted. /// If the process succeeds, the deserialized value is cached. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -582,6 +606,8 @@ impl FitsHeaderValueContainer { /// Gets the comment section of the header card. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::FitsHeaderValueContainer; /// diff --git a/src/fits/mod.rs b/src/fits/mod.rs index 509d124..fbb64d1 100644 --- a/src/fits/mod.rs +++ b/src/fits/mod.rs @@ -44,6 +44,8 @@ impl HduList { /// Retrieves the HDU at the given index, or None if an HDU doesn't exist at the index. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -66,6 +68,8 @@ impl HduList { /// Retrieves the HDU with the given value for the `EXTNAME` keyword, or None if an HDU /// with the given name doesn't exist. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -112,6 +116,8 @@ impl HduList { /// Returns a mutable pointer to the first HDU, or `None` if the list is empty. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -131,6 +137,8 @@ impl HduList { /// Deserializes all HDUs if necessary, then returns a mutable iterator over the HDUs. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -160,10 +168,13 @@ impl HduList { /// /// Panics if `index` is out of bounds. /// + /// # Examples + /// /// ```should_panic /// use astro_rs::fits::*; /// /// let mut hdu_list = HduList::default(); + /// // panics, index is out of bounds /// hdu_list.insert(1, image_hdu::default()); /// ``` /// @@ -190,6 +201,8 @@ impl HduList { /// Appends `hdu` to the end of the HDU list. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -208,6 +221,8 @@ impl HduList { /// Writes the HDU list via the given writer. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// use std::io::*; @@ -231,6 +246,8 @@ impl HduList { /// Validates the existence and format of the SIMPLE header card. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// @@ -360,6 +377,8 @@ impl Hdu { /// Gets the name of the HDU, or an empty string if the name cannot be determined. /// + /// # Examples + /// /// ``` /// use astro_rs::fits::*; /// diff --git a/tests/coordinates.rs b/tests/coordinates.rs index 0fe9ef1..586144e 100644 --- a/tests/coordinates.rs +++ b/tests/coordinates.rs @@ -4,29 +4,26 @@ mod coordinate_tests { use astro_rs::coordinates::*; - use chrono::{DateTime, Utc}; - use measurements::{Angle, Distance}; + use hifitime::Epoch; + use uom::si::angle::degree; + use uom::si::f64::{Angle, Length}; + use uom::si::length::meter; #[test] fn test_lookup_by_name() -> Result<(), Box> { let m33_eq_coords = tokio_test::block_on(async { lookup_by_name("M33").await })?; + let bear_mountain = EarthLocation { - lat: Angle::from_degrees(41.3), - lon: Angle::from_degrees(-74.0), - height: Distance::from_meters(390.0), + lat: Angle::new::(41.3), + lon: Angle::new::(-74.0), + height: Length::new::(390.0), }; // 11pm EDT on 2012 July 12 - let date_time = DateTime::parse_from_rfc3339("2012-07-12T23:00:00.00-04:00")?; + let date_time = Epoch::from_gregorian_utc_hms(2012, 07, 13, 03, 00, 00); - let m33_horiz_coords = m33_eq_coords - .as_alt_az(&date_time.with_timezone(&Utc), &bear_mountain) - .coords; + let m33_horiz_coords = m33_eq_coords.to_alt_az(&date_time, &bear_mountain)?.coords; - println!( - "{}, {}", - m33_horiz_coords.alt.as_degrees(), - m33_horiz_coords.az.as_degrees() - ); + println!("{:?}", m33_horiz_coords.round(4)); Ok(()) } From 1372f6b3029fc95e7956dec427f5e1379b203272 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 14:26:25 -0500 Subject: [PATCH 04/14] Update uom requirement from 0.33 to 0.34 (#25) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 72d9edc..7f65b40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ once_cell = { version = "1.16", optional = true } regex = { version = "1.7", optional = true } rust_decimal = { version = "1.29" } thiserror = { version = "1.0" } -uom = { version = "0.33", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } +uom = { version = "0.34", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } urlencoding = { version = "2.1", optional = true } [dev-dependencies] From 25835b4811898674f561cacbce3452a7a539384a Mon Sep 17 00:00:00 2001 From: John Nystrom Date: Mon, 29 May 2023 23:03:31 -0500 Subject: [PATCH 05/14] Update CI (#26) --- .github/codecov.yml | 11 ++++++ .github/dependabot.yml | 14 +++++-- .github/workflows/build.yml | 74 +++++++++++++++++++++---------------- .github/workflows/test.yml | 61 +++++++++++++++++------------- Cargo.toml | 2 +- README.md | 3 ++ codecov.yml | 13 ------- 7 files changed, 104 insertions(+), 74 deletions(-) create mode 100644 .github/codecov.yml delete mode 100644 codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..c23a549 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,11 @@ +coverage: + status: + changes: false + patch: false + project: false + +ignore: + - "tests" + +comment: + layout: "reach,diff,files" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 53f8242..913c141 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,14 @@ version: 2 updates: - - package-ecosystem: "cargo" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "weekly" + interval: weekly + - package-ecosystem: cargo + directory: / + schedule: + interval: weekly + ignore: + - dependency-name: "*" + update-types: + - "version-update:semver-patch" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3022a0a..61ab316 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,6 @@ +permissions: + contents: read + on: push: branches: @@ -7,6 +10,10 @@ on: branches: - main - release + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true name: Build @@ -15,45 +22,50 @@ jobs: name: Fmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true components: rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - run: cargo fmt --check - check: - name: Check + clippy: + name: Clippy runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 + components: clippy + - uses: actions-rs/clippy-check@v1 with: - command: check args: --all-features - - clippy: - name: Clippy + token: ${{ secrets.GITHUB_TOKEN }} + + doc: + name: Doc runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: clippy - - uses: actions-rs/cargo@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - run: cargo doc --no-deps --all-features + env: + RUSTDOCFLAGS: --cfg docsrs + + hack: + name: Feature Unionization + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@cargo-hack + - run: cargo hack --feature-powerset check + + msrv: + name: MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - command: clippy - args: --all-features -- -D warnings \ No newline at end of file + toolchain: 1.60.0 + - run: cargo check --all-features diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f3b395..b15fb9c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,6 @@ +permissions: + contents: read + on: push: branches: @@ -7,41 +10,47 @@ on: branches: - main - release + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true name: Test jobs: test: - name: Test with coverage + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - if: hashFiles('Cargo.lock') == '' + run: cargo generate-lockfile + - run: cargo test --locked --all-features + + minimal: + name: Minimal versions runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@nightly + - run: rustup default stable + - run: cargo +nightly update -Zdirect-minimal-versions + - run: cargo test --locked --all-features - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true components: llvm-tools-preview - - - uses: Swatinem/rust-cache@v1 - - - name: Download grcov - run: | - cargo install grcov - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Run coverage - run: | - rm -rf coverage - mkdir coverage - CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test - grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" -o coverage/tests.lcov - rm -rf *.profraw - - - name: Upload to codecov.io - uses: codecov/codecov-action@v3 + - uses: taiki-e/install-action@cargo-llvm-cov + - if: hashFiles('Cargo.lock') == '' + run: cargo generate-lockfile + - run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info + - uses: codecov/codecov-action@v3 with: - files: coverage/*.lcov fail_ci_if_error: true diff --git a/Cargo.toml b/Cargo.toml index 7f65b40..84282ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ hyper = { version = "0.14", features = ["client", "http1", "tcp"], optional = tr once_cell = { version = "1.16", optional = true } regex = { version = "1.7", optional = true } rust_decimal = { version = "1.29" } -thiserror = { version = "1.0" } +thiserror = { version = "1.0.7" } uom = { version = "0.34", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } urlencoding = { version = "2.1", optional = true } diff --git a/README.md b/README.md index 0096f2d..cdfb410 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,6 @@ Test assets are from the following sources: * Original code is licensed under the MIT license * `astropy` is licensed under BSD-3-Clause * `hifitime` is licensed under Apache-2.0 + +# MSRV +This crate's Minimum Supported Rust Version is `1.60.0`. diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index ead552e..0000000 --- a/codecov.yml +++ /dev/null @@ -1,13 +0,0 @@ -codecov: - require_ci_to_pass: true -comment: - behavior: default - layout: reach,diff,flags,tree,reach - show_carryforward_flags: false -coverage: - status: - changes: false - patch: false - project: false -github_checks: - annotations: true From 67182831e1c9347c7ac784500c44ca061c76633f Mon Sep 17 00:00:00 2001 From: John Nystrom Date: Mon, 29 May 2023 23:15:50 -0500 Subject: [PATCH 06/14] Fix permissions for clippy job --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61ab316..e8a12e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,9 @@ jobs: clippy: name: Clippy + permissions: + contents: read + checks: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 1632c2b8c201fbe04162f305daca50d04cfa3f70 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:45:42 -0500 Subject: [PATCH 07/14] Update uom requirement from 0.34 to 0.35 (#28) Updates the requirements on [uom](https://github.com/iliekturtles/uom) to permit the latest version. - [Release notes](https://github.com/iliekturtles/uom/releases) - [Changelog](https://github.com/iliekturtles/uom/blob/master/CHANGELOG.md) - [Commits](https://github.com/iliekturtles/uom/compare/v0.34.0...v0.35.0) --- updated-dependencies: - dependency-name: uom dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 84282ce..55532d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ once_cell = { version = "1.16", optional = true } regex = { version = "1.7", optional = true } rust_decimal = { version = "1.29" } thiserror = { version = "1.0.7" } -uom = { version = "0.34", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } +uom = { version = "0.35", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } urlencoding = { version = "2.1", optional = true } [dev-dependencies] From 0ef688a8efebe4e26486fb969f8e9706dde4af0c Mon Sep 17 00:00:00 2001 From: John Nystrom Date: Mon, 28 Aug 2023 15:19:01 -0500 Subject: [PATCH 08/14] Account for dependency/rust changes (#29) * removed ambiguous re-export * ensure writer is flushed * pin tokio to retain MSRV --- Cargo.toml | 3 +++ src/fits/hdu_types.rs | 3 --- src/fits/mod.rs | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 55532d4..d671c2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,9 @@ thiserror = { version = "1.0.7" } uom = { version = "0.35", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } urlencoding = { version = "2.1", optional = true } +# pin tokio to retain MSRV +tokio = { version = "= 1.29.1" } + [dev-dependencies] criterion = { version = "0.4", features = ["html_reports"] } image = { version = "0.24", default-features = false, features = ["jpeg"] } diff --git a/src/fits/hdu_types.rs b/src/fits/hdu_types.rs index 57aefb5..30c4c46 100644 --- a/src/fits/hdu_types.rs +++ b/src/fits/hdu_types.rs @@ -1,8 +1,5 @@ //! Construct standard HDU types. -pub use ascii_table_hdu::*; -pub use primary_hdu::*; - use super::*; /// The header keyword indicating the name of a table column. diff --git a/src/fits/mod.rs b/src/fits/mod.rs index fbb64d1..c0f38b6 100644 --- a/src/fits/mod.rs +++ b/src/fits/mod.rs @@ -241,6 +241,7 @@ impl HduList { writer.write_all(&hdu.clone().to_bytes())?; } std::io::copy(&mut self.reader, writer)?; + writer.flush()?; Ok(()) } From bebf38c112b5c2e3de5512e33f995b174bea5c53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 15:36:47 -0500 Subject: [PATCH 09/14] Update criterion requirement from 0.4 to 0.5 (#27) Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version. - [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/bheisler/criterion.rs/compare/0.4.0...0.5.1) --- updated-dependencies: - dependency-name: criterion dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d671c2e..4370287 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ urlencoding = { version = "2.1", optional = true } tokio = { version = "= 1.29.1" } [dev-dependencies] -criterion = { version = "0.4", features = ["html_reports"] } +criterion = { version = "0.5", features = ["html_reports"] } image = { version = "0.24", default-features = false, features = ["jpeg"] } tokio-test = { version = "0.4" } From 97937ae05804d22a3ca0de1362ce4f6825a80bc2 Mon Sep 17 00:00:00 2001 From: John Nystrom Date: Sun, 10 Sep 2023 15:02:03 -0500 Subject: [PATCH 10/14] Pin memchr to retain MSRV (#32) --- Cargo.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4370287..59a9cf0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,9 @@ thiserror = { version = "1.0.7" } uom = { version = "0.35", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } urlencoding = { version = "2.1", optional = true } -# pin tokio to retain MSRV -tokio = { version = "= 1.29.1" } +# pin to retain MSRV +tokio = { version = "1, <1.30.0" } +memchr = { version = "2.4, <2.6.3" } [dev-dependencies] criterion = { version = "0.5", features = ["html_reports"] } From 847c67ccefdf981ebf1d7e87c797e0b8a3976d9c Mon Sep 17 00:00:00 2001 From: John Nystrom Date: Sun, 10 Sep 2023 15:05:57 -0500 Subject: [PATCH 11/14] add doctests to coverage metrics (#31) --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b15fb9c..6ac5c2c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,13 +44,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + # nightly is required for --doctests, see cargo-llvm-cov#2 + - uses: dtolnay/rust-toolchain@nightly with: components: llvm-tools-preview - uses: taiki-e/install-action@cargo-llvm-cov - if: hashFiles('Cargo.lock') == '' run: cargo generate-lockfile - - run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info + - run: cargo +nightly llvm-cov --locked --all-features --lcov --doctests --output-path lcov.info - uses: codecov/codecov-action@v3 with: fail_ci_if_error: true From 7e46ccae4c6ab0a94f4558934aa7308a0bd156d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:27:25 -0500 Subject: [PATCH 12/14] Bump actions/checkout from 3 to 4 (#34) --- .github/workflows/build.yml | 10 +++++----- .github/workflows/test.yml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8a12e5..345cad5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: name: Fmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt @@ -35,7 +35,7 @@ jobs: checks: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: clippy @@ -48,7 +48,7 @@ jobs: name: Doc runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - run: cargo doc --no-deps --all-features env: @@ -58,7 +58,7 @@ jobs: name: Feature Unionization runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@cargo-hack - run: cargo hack --feature-powerset check @@ -67,7 +67,7 @@ jobs: name: MSRV runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: 1.60.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ac5c2c..c5fec1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - if: hashFiles('Cargo.lock') == '' run: cargo generate-lockfile @@ -32,7 +32,7 @@ jobs: name: Minimal versions runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@nightly - run: rustup default stable @@ -43,7 +43,7 @@ jobs: name: Coverage runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # nightly is required for --doctests, see cargo-llvm-cov#2 - uses: dtolnay/rust-toolchain@nightly with: From 2f16d25c6827fbc9c7138984bd68aafa02d9e4e5 Mon Sep 17 00:00:00 2001 From: John Nystrom Date: Wed, 1 Nov 2023 17:50:47 -0500 Subject: [PATCH 13/14] Increase version number; add changelog --- CHANGELOG.md | 15 +++++++++++++++ Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e43f88e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + +## [0.1.1] + +Set MSRV, stricter dependency versions, better workflows + +### Changed + +- Switched from chrono to hifitime +- Switched from measurements to uom +- Included `coordinates` feature by default + +## [0.1.0] + +Initial FITS feature release diff --git a/Cargo.toml b/Cargo.toml index 59a9cf0..c15600b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astro-rs" -version = "0.1.0" +version = "0.1.1" edition = "2021" license = "MIT" description = "Astronomy utils" From b85c9d9ccd627e5272c955d06651bf3437a1db25 Mon Sep 17 00:00:00 2001 From: John Nystrom Date: Wed, 1 Nov 2023 18:10:17 -0500 Subject: [PATCH 14/14] pin regex version (#36) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c15600b..ac5f130 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ rustdoc-args = ["--cfg", "docsrs"] hifitime = { version = "3.6", optional = true } hyper = { version = "0.14", features = ["client", "http1", "tcp"], optional = true } once_cell = { version = "1.16", optional = true } -regex = { version = "1.7", optional = true } rust_decimal = { version = "1.29" } thiserror = { version = "1.0.7" } uom = { version = "0.35", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] } @@ -33,6 +32,7 @@ urlencoding = { version = "2.1", optional = true } # pin to retain MSRV tokio = { version = "1, <1.30.0" } memchr = { version = "2.4, <2.6.3" } +regex = { version = "1.7, <1.10.0", optional = true } [dev-dependencies] criterion = { version = "0.5", features = ["html_reports"] }