forked from planetarypy/planetarypy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request planetarypy#23 from michaelaye/main
implement GH workflow for running tests
- Loading branch information
Showing
16 changed files
with
442 additions
and
455 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# FILE: .github/workflows/test.yaml | ||
name: Run software tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Conda | ||
uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
miniforge-variant: Miniforge3 | ||
miniforge-version: latest | ||
activate-environment: test_env | ||
use-mamba: true | ||
python-version: "3.9" | ||
channels: conda-forge | ||
channel-priority: strict | ||
auto-activate-base: false | ||
conda-remove-defaults: true | ||
|
||
- name: Cache conda env | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.conda/pkgs | ||
~/.conda/envs | ||
key: conda-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.sha }} | ||
restore-keys: | | ||
conda-${{ runner.os }}-py${{ matrix.python-version }}- | ||
conda-${{ runner.os }}- | ||
- name: Install dependencies | ||
shell: bash -l {0} | ||
run: | | ||
# Install tomlkit and sh first to run the installation script | ||
mamba install -y -c conda-forge tomlkit sh | ||
# Run the installation script | ||
python install_dev_deps.py | ||
- name: Install package | ||
shell: bash -l {0} | ||
run: | | ||
pip install -e . | ||
- name: Run tests | ||
shell: bash -l {0} | ||
run: | | ||
pytest --cov=src/planetarypy --cov-report=xml --cov-report=term | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.xml | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,8 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pixi environments | ||
.pixi | ||
*.egg-info | ||
*.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python | ||
from pathlib import Path | ||
import tomlkit | ||
import sh | ||
import sys | ||
|
||
# Define packages that should be installed via pip instead of conda | ||
PIP_PACKAGES = {'build', 'pip-tools'} | ||
|
||
def install_deps(): | ||
# Read pyproject.toml | ||
pyproject_path = Path("pyproject.toml") | ||
with open(pyproject_path) as f: | ||
pyproject = tomlkit.load(f) | ||
|
||
# Get both main and dev dependencies | ||
main_deps = pyproject["project"]["dependencies"] | ||
dev_deps = pyproject["project"]["optional-dependencies"]["dev"] | ||
all_deps = main_deps + dev_deps | ||
|
||
# Split dependencies into conda and pip packages | ||
conda_deps = [dep for dep in all_deps if dep not in PIP_PACKAGES] | ||
pip_deps = [dep for dep in all_deps if dep in PIP_PACKAGES] | ||
|
||
# Install conda packages | ||
if conda_deps: | ||
try: | ||
print("Installing with mamba:", ' '.join(conda_deps)) | ||
sh.mamba("install", "-y", "-c", "conda-forge", *conda_deps, | ||
_err=sys.stderr, _out=sys.stdout) | ||
print("Conda installation completed successfully!") | ||
except sh.ErrorReturnCode as e: | ||
print("Error installing conda packages!") | ||
print("Exit code:", e.exit_code) | ||
print("Stdout:", e.stdout.decode() if e.stdout else 'No stdout') | ||
print("Stderr:", e.stderr.decode() if e.stderr else 'No stderr') | ||
sys.exit(1) | ||
|
||
# Install pip packages | ||
if pip_deps: | ||
try: | ||
print("\nInstalling with pip:", ' '.join(pip_deps)) | ||
sh.pip("install", *pip_deps, _err=sys.stderr, _out=sys.stdout) | ||
print("Pip installation completed successfully!") | ||
except sh.ErrorReturnCode as e: | ||
print("Error installing pip packages!") | ||
print("Exit code:", e.exit_code) | ||
print("Stdout:", e.stdout.decode() if e.stdout else 'No stdout') | ||
print("Stderr:", e.stderr.decode() if e.stderr else 'No stderr') | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
install_deps() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
}, | ||
{ | ||
"path": "../0_nbplanetary" | ||
} | ||
], | ||
"settings": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "planetarypy" | ||
version = "0.2.0" | ||
description = "Core package for planetary data tools." | ||
readme = "README.rst" | ||
requires-python = ">= 3.9, <4" | ||
license = {text = "BSD license"} | ||
license-file = "LICENSE" | ||
authors = [ | ||
{name = "Planetarypy Developers", email = "[email protected]"} | ||
] | ||
keywords = ["planetarypy", "planetary", "space", "science"] | ||
classifiers = [ | ||
"Development Status :: 2 - Pre-Alpha", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: BSD License", | ||
"Natural Language :: English", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
] | ||
dependencies = [ | ||
"tomlkit", | ||
"requests", | ||
"tqdm", | ||
"pandas", | ||
"astropy", | ||
"spiceypy", | ||
"yarl", | ||
"matplotlib", | ||
] | ||
repository = "https://github.com/planetarypy/planetarypy" | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"pytest", | ||
"pytest-cov", | ||
"build", | ||
"twine", | ||
"pip-tools", | ||
"make" | ||
] | ||
|
||
[project.scripts] | ||
planetarypy = "planetarypy.cli:main" | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["src/planetarypy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.