From f5893160171e6a51380ac8d149073b0568675cd2 Mon Sep 17 00:00:00 2001 From: Helge Eichhorn Date: Tue, 23 Jan 2024 15:26:39 +0100 Subject: [PATCH] Try to generate coverage from Python --- .github/workflows/rust.yml | 15 ++++++++++++--- README.md | 2 +- crates/lox_py/pyproject.toml | 4 ++++ crates/lox_py/tests/test_coords.py | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 crates/lox_py/tests/test_coords.py diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 467b8bf9..9622193d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -48,14 +48,23 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: "3.11" + cache: "pip" + - name: Setup Python environment + run: | + pip install --user maturin + python -m venv .venv + maturin develop -E test - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - name: Generate code coverage - run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + run: | + cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + source .venv/bin/activate + pytest tests --cov=lox_space --cov-report xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - files: lcov.info + files: lcov.info, coverage.xml fail_ci_if_error: true diff --git a/README.md b/README.md index a0e0abf1..99382ad0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LOX -[![codecov](https://codecov.io/gh/OpenAstrodynamics/lox/branch/main/graph/badge.svg?token=R1W6HLN2N2)](https://codecov.io/gh/OpenAstrodynamics/lox) +[![codecov](https://codecov.io/gh/lox-space/lox/graph/badge.svg?token=R1W6HLN2N2)](https://codecov.io/gh/lox-space/lox) > Liquid oxygen—abbreviated LOx, LOX or Lox in the aerospace, submarine and gas industries—is the liquid form of molecular oxygen. > It was used as the *oxidizer* in the first liquid-fueled rocket invented in 1926 by Robert H. Goddard, an application which has continued to the present. diff --git a/crates/lox_py/pyproject.toml b/crates/lox_py/pyproject.toml index cedfa322..820ae15a 100644 --- a/crates/lox_py/pyproject.toml +++ b/crates/lox_py/pyproject.toml @@ -19,6 +19,10 @@ dependencies = [ dev = [ "black" ] +test = [ + "pytest", + "pytest-cov", +] [tool.maturin] features = ["pyo3/extension-module"] diff --git a/crates/lox_py/tests/test_coords.py b/crates/lox_py/tests/test_coords.py new file mode 100644 index 00000000..fc5fa2f7 --- /dev/null +++ b/crates/lox_py/tests/test_coords.py @@ -0,0 +1,16 @@ +# Copyright (c) 2024. Helge Eichhorn and the LOX contributors +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. + +import lox_space as lox +import numpy as np + +def test_iss(): + time = lox.Epoch("TDB", 2016, 5, 30, 12) + position = np.array([6068279.27, -1692843.94, -2516619.18]) * 1e-3 + velocity = np.array([-660.415582, 5495.938726, -5303.093233]) * 1e-3 + iss_cartesian = lox.Cartesian(time, lox.Planet("Earth"), "ICRF", position, velocity) + iss = iss_cartesian.to_keplerian() + assert isinstance(iss, lox.Keplerian)