Skip to content

Commit

Permalink
Merge pull request #2 from NASA-Planetary-Science/workflows
Browse files Browse the repository at this point in the history
Workflows and Tests
  • Loading branch information
trappitsch authored Aug 14, 2023
2 parents cfec2ab + 6dc20a8 commit 2fcb152
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 49 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/db_test.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package PyPi

on:
release:
types: [created]

jobs:
deploy:
if: github.repository_owner == 'NASA-Planetary-Science'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit
- name: Build and publish
env:
FLIT_USERNAME: '__token__'
FLIT_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
flit publish
50 changes: 50 additions & 0 deletions .github/workflows/rimseval_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
# Build and test
build:
if: github.repository_owner == 'NASA-Planetary-Science'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox
pip install .[dev,db_maintainer]
- name: Run nox
run: nox --no-error-on-missing-interpreters
- name: Generate coverage report
run: |
pip install codecov
pip install pytest-cov
pytest --cov=./ --cov-report=xml
codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[![PyPi](https://img.shields.io/pypi/v/pgdtools?color=informational)](https://pypi.org/project/pgdtools/)
[![docs](https://readthedocs.org/projects/pgdtools/badge/?version=latest)](https://pgdtools.readthedocs.io)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/NASA-Planetary-Science/pgdtools/blob/main/LICENSE)
[![tests](https://github.com/NASA-Planetary-Science/pgdtools/actions/workflows/rimseval_testing.yml/badge.svg?branch=main)](https://github.com/NASA-Planetary-Science/pgdtools/)
[![codecov](https://codecov.io/gh/NASA-Planetary-Science/pgdtools/branch/main/graph/badge.svg?token=N0NNVEI8CX)](https://codecov.io/gh/NASA-Planetary-Science/pgdtools)
[![Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# Presolar grain database tools (pgdTools)

Currently under development.
Expand Down
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@nox.session(python=python_main)
def docs(session):
"""Build the documentation."""
session.install("sphinx", "sphinx_rtd_theme", ".[db_maintainer]")
session.install("sphinx", "sphinx_rtd_theme", ".[docs]")
session.chdir("docs")
session.run(
"sphinx-build", "-b", "html", ".", "_build/html/"
Expand All @@ -25,7 +25,7 @@ def docs(session):
def lint(session):
"""Lint project using ``flake8``."""
args = session.posargs or locations
session.install(".[dev, db_maintainer]")
session.install(".[dev]")
session.run("flake8", *args)


Expand All @@ -39,7 +39,7 @@ def tests(session):
@nox.session(python=python_main)
def safety(session):
"""Safety check for all dependencies."""
session.install(".[dev, db_maintainer]", "safety")
session.install(".[dev, db_maintainer, docs]", "safety")
session.run(
"safety",
"check",
Expand Down
2 changes: 1 addition & 1 deletion pgdtools/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pathlib import Path

DB_FILE_URL = "https://raw.githubusercontent.com/NASA-Planetary-Science/pgdtools/main/database/db.json"
DB_FILE_URL = "https://raw.githubusercontent.com/NASA-Planetary-Science/pgdtools/main/database/db.json" # noqa: B950

BIBFILE = Path(__file__).parent.joinpath("pgd_references.bib").absolute()
OLAFKEYFILE = (
Expand Down
6 changes: 4 additions & 2 deletions pgdtools/pgdtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ def filter_value(
if comparator not in comp_dict.keys():
raise ValueError(f"Comparator {comparator} is not valid.")

# evaluate
self.db = self.db[eval(f"self.db[hdr] {comp_dict[comparator]} {value}")]
# evaluate -- todo: insecure, but garbage anyway
self.db = self.db[
eval(f"self.db[hdr] {comp_dict[comparator]} {value}") # noqa: S307
]

def filter_type(self, grain_type):
"""Filter grain database by grain type.
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ dev = [
"requests"
]

db_maintainer = [
"bibtexparser"
]

docs = [
"sphinx",
"sphinx_rtd_theme",
"sphinxcontrib-mermaid"
]

pds = [
"bibtexparser"
]

0 comments on commit 2fcb152

Please sign in to comment.