From 64f5fcf63e9c8fe38ee32b74122d4aaffe828a3a Mon Sep 17 00:00:00 2001 From: Greg Sleap Date: Fri, 12 Apr 2024 16:29:58 +1000 Subject: [PATCH 1/3] Fixes #69- SHAO and EDA2 receiver types --- CHANGELOG.md | 7 ++++++- Cargo.toml | 2 +- src/rfinput/mod.rs | 13 ++++++++++--- src/rfinput/test.rs | 6 ++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad33d4a..e552164 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Changes in each release are listed below. +## 1.3.0 12-Apr-2024 + +* Added 'EDA2' and 'SHAO' as new valid `ReceiverType`s to `Rfinput` struct. +* Release now include MacOS Arm architecture binaries. + ## 1.2.3 12-Mar-2024 * Removed error-inducing, unneeded `python_version` requirement from the `[build-system]` `requires` setting. @@ -9,7 +14,7 @@ Changes in each release are listed below. ## 1.2.2 12-Mar-2024 * Explictly typed the buffer_ptr to be `signed char*` instead of the ambiguous `char*` in FFI VoltageContext read methods to fix portability issue with Arm64 platform. Fixes #67. -* Updated deprecated call when using `Duration:milliseconds`. +* Updated deprecated call when using `Duration:milliseconds`. ## 1.2.1 24-Nov-2023 diff --git a/Cargo.toml b/Cargo.toml index 8e80792..602d728 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mwalib" -version = "1.2.3" +version = "1.3.0" homepage = "https://github.com/MWATelescope/mwalib" repository = "https://github.com/MWATelescope/mwalib" readme = "README.md" diff --git a/src/rfinput/mod.rs b/src/rfinput/mod.rs index 2bafccb..28f9821 100644 --- a/src/rfinput/mod.rs +++ b/src/rfinput/mod.rs @@ -173,6 +173,8 @@ pub enum ReceiverType { RRI, NI, Pseudo, + SHAO, + EDA2 } /// Implements fmt::Display for ReceiverType @@ -197,12 +199,15 @@ impl fmt::Display for ReceiverType { ReceiverType::RRI => "RRI", ReceiverType::NI => "NI", ReceiverType::Pseudo => "Pseudo", + ReceiverType::SHAO => "SHAO", + ReceiverType::EDA2 => "EDA2", } ) } } -/// Implements str::FromStr for ReceiverType enum +/// Implements str::FromStr for ReceiverType enum. +/// Non uppercase values are coverted to uppercase for comparision. /// /// # Arguments /// @@ -217,11 +222,13 @@ impl fmt::Display for ReceiverType { impl std::str::FromStr for ReceiverType { type Err = (); - fn from_str(input: &str) -> Result { - match input { + fn from_str(input: &str) -> Result { + match input.to_uppercase().as_str() { "RRI" => Ok(ReceiverType::RRI), "NI" => Ok(ReceiverType::NI), "PSEUDO" => Ok(ReceiverType::Pseudo), + "SHAO" => Ok(ReceiverType::SHAO), + "EDA2" => Ok(ReceiverType::EDA2), _ => Ok(ReceiverType::Unknown), } } diff --git a/src/rfinput/test.rs b/src/rfinput/test.rs index 2921dec..2a2d6dd 100644 --- a/src/rfinput/test.rs +++ b/src/rfinput/test.rs @@ -244,6 +244,12 @@ fn test_string_to_receiver_type() { assert!(String::from("RRI").parse::().unwrap() == ReceiverType::RRI); assert!(String::from("NI").parse::().unwrap() == ReceiverType::NI); assert!(String::from("PSEUDO").parse::().unwrap() == ReceiverType::Pseudo); + assert!(String::from("SHAO").parse::().unwrap() == ReceiverType::SHAO); + assert!(String::from("EDA2").parse::().unwrap() == ReceiverType::EDA2); + + // what happens for lowercase? + assert!(String::from("rri").parse::().unwrap() == ReceiverType::RRI); + assert!( String::from("something else") .parse::() From 9dc203c1ecc7ea370e3bf7d4a48d8c16c6b453da Mon Sep 17 00:00:00 2001 From: Greg Sleap Date: Fri, 12 Apr 2024 17:01:23 +1000 Subject: [PATCH 2/3] Upgraded test CIs to also test on MacOS 14 Arm64 architecture --- .github/workflows/coverage.yml | 23 ++++++++--- .github/workflows/releases.yml | 2 +- .github/workflows/run_python_tests.yml | 53 +++++++++++++++++--------- .github/workflows/run_tests.yml | 39 ++++++++++++++----- CHANGELOG.md | 2 +- 5 files changed, 84 insertions(+), 35 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3406027..0a8ece8 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -34,9 +34,22 @@ jobs: env: DEBIAN_FRONTEND: noninteractive - - name: Install cfitsio - run: ./.github/workflows/make_cfitsio.sh - shell: bash + - name: install cfitsio + env: + # TODO: CFITSIO_VERSION: 4.4.0 + CFITSIO_VERSION: 3.49 + run: | + cd /tmp + curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz + tar -xf cfitsio.tar.gz + rm cfitsio.tar.gz + cd cfitsio-${CFITSIO_VERSION} + ./configure --prefix=/usr/local --enable-reentrant --disable-curl + sudo make shared + sudo make install + cd .. + + sudo ldconfig - name: Install stable toolchain uses: actions-rs/toolchain@v1 @@ -49,10 +62,10 @@ jobs: - name: Install cargo-llvm-cov run: cargo install cargo-llvm-cov - - name: Set up Python 3.11 + - name: Set up Python 3.12 uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: Generate test lcov coverage into coverage/ dir run: | diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index f6fec18..303444e 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -89,7 +89,7 @@ jobs: - name: install maturin run: | python -m pip install --upgrade pip - python -m pip install maturin # [patchelf] ? + python -m pip install maturin - name: build mwalib run: | diff --git a/.github/workflows/run_python_tests.yml b/.github/workflows/run_python_tests.yml index 41d10d4..27aee90 100644 --- a/.github/workflows/run_python_tests.yml +++ b/.github/workflows/run_python_tests.yml @@ -19,16 +19,17 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, macOS-14] python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] steps: - name: Checkout sources - uses: actions/checkout@v3 - - - name: Install cfitsio - run: ./.github/workflows/make_cfitsio.sh - shell: bash + uses: actions/checkout@v4 + - name: (macos) install automake and autoconf + if: ${{ startsWith(matrix.os, 'macOS') }} + run: | + brew install automake autoconf + - name: Install stable toolchain uses: actions-rs/toolchain@v1 with: @@ -36,6 +37,25 @@ jobs: toolchain: stable override: true + - name: install cfitsio + env: + # TODO: CFITSIO_VERSION: 4.4.0 + CFITSIO_VERSION: 3.49 + run: | + cd /tmp + curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz + tar -xf cfitsio.tar.gz + rm cfitsio.tar.gz + cd cfitsio-${CFITSIO_VERSION} + ./configure --prefix=/usr/local --enable-reentrant --disable-curl + sudo make shared + sudo make install + cd .. + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo ldconfig + fi + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -44,18 +64,15 @@ jobs: - name: Run rust tests to generate test data run: cargo test --features=cfitsio-static - - name: Run pytests + - name: Setup python environment and run pytests run: | - pip3 install --upgrade pip - python3 -m venv env - source env/bin/activate - - pip3 install maturin==1.3.2 - if [[ "$OSTYPE" == "darwin"* ]]; then - brew install automake - fi + pip3 install --upgrade pip + python3 -m venv env + source env/bin/activate + pip3 install --upgrade pip + pip3 install maturin==1.3.2 - maturin develop --features=python,cfitsio-static --strip + maturin develop --features=python,cfitsio-static --strip - pip install pytest - pytest + pip3 install pytest + pytest diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 0ff0c53..5f8bf00 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -19,14 +19,15 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, macOS-14] steps: - name: Checkout sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Install cfitsio - run: ./.github/workflows/make_cfitsio.sh - shell: bash + - name: (macos) install automake and autoconf + if: ${{ startsWith(matrix.os, 'macOS') }} + run: | + brew install automake autoconf - name: Install stable toolchain uses: actions-rs/toolchain@v1 @@ -34,13 +35,31 @@ jobs: profile: minimal toolchain: stable override: true + + - name: install cfitsio + env: + # TODO: CFITSIO_VERSION: 4.4.0 + CFITSIO_VERSION: 3.49 + run: | + cd /tmp + curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz + tar -xf cfitsio.tar.gz + rm cfitsio.tar.gz + cd cfitsio-${CFITSIO_VERSION} + ./configure --prefix=/usr/local --enable-reentrant --disable-curl + sudo make shared + sudo make install + cd .. + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo ldconfig + fi - - name: Run tests + - name: Run tests on latest stable rust run: cargo test --release --features cfitsio-static,examples - name: Minimum-specified Rust version works run: | - MIN_RUST=$(grep -m1 "rust-version" Cargo.toml | sed 's|.*\"\(.*\)\"|\1|') - ~/.cargo/bin/rustup install $MIN_RUST --profile minimal - cargo +${MIN_RUST} test - cargo +${MIN_RUST} test --features cfitsio-static,examples \ No newline at end of file + MIN_RUST=$(grep -m1 "rust-version" Cargo.toml | sed 's|.*\"\(.*\)\"|\1|') + ~/.cargo/bin/rustup install $MIN_RUST --profile minimal + cargo +${MIN_RUST} test --features cfitsio-static,examples \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e552164..d993553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Changes in each release are listed below. ## 1.3.0 12-Apr-2024 * Added 'EDA2' and 'SHAO' as new valid `ReceiverType`s to `Rfinput` struct. -* Release now include MacOS Arm architecture binaries. +* Release and tests now include MacOS 14 Arm64 architecture binaries. ## 1.2.3 12-Mar-2024 From a24e08941e1f206b59cc4d9836cfe9dbf304b56b Mon Sep 17 00:00:00 2001 From: Greg Sleap Date: Fri, 12 Apr 2024 17:15:17 +1000 Subject: [PATCH 3/3] Fix to exclude python 3.8,3.9 from MacOS 14 Arm --- .github/workflows/run_python_tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/run_python_tests.yml b/.github/workflows/run_python_tests.yml index 27aee90..da85021 100644 --- a/.github/workflows/run_python_tests.yml +++ b/.github/workflows/run_python_tests.yml @@ -21,6 +21,11 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, macOS-14] python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] + exclude: + - os: macOS-14 + python-version: 3.8 + - os: macOS-14 + python-version: 3.9 steps: - name: Checkout sources uses: actions/checkout@v4