Skip to content

Commit

Permalink
github action to run tests (#65)
Browse files Browse the repository at this point in the history
Re-enable the test suite using github actions and modern python infrastructure.

Co-authored-by: Mahdi Qezlou <[email protected]>
  • Loading branch information
sbird and qezlou authored Apr 8, 2022
1 parent 7cffe17 commit a6ab494
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install build
pip install -r requirements.txt
sudo apt update
sudo apt install -y libgsl-dev libboost-test-dev
- name: Build package
run: python -m build
run: |
git submodule update --init --recursive
python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# main test workflow; ported from .travis.yaml

name: tests

on:
push:
branches: [ '*', $default-branch ]
pull_request:
branches: [ $default-branch ]

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install build pytest
sudo apt update
sudo apt install -y libgsl-dev libboost-test-dev
- name: Build
run: |
git submodule update --init --recursive
python3 -m build
- name: Install
run:
python3 -m pip install --user dist/fake_spectra*.whl
- name: Python unit tests
run: pytest
- name: Boost unit tests
run: make test
Empty file removed fake_spectra/tests/__init__.py
Empty file.
4 changes: 0 additions & 4 deletions fake_spectra/tests/test_rate_network.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Tests for the rate network."""

import time
import numpy as np
from fake_spectra import rate_network
from fake_spectra import ratenetworkspectra
Expand Down Expand Up @@ -59,15 +58,12 @@ def testRateNetwork():
neuts2 = rates2.get_neutral_fraction(dens, 100.)/(0.76*dens)
ii = np.where(dens < 1e-4)
assert np.all(np.abs(neuts[ii]/neuts2[ii] -1.) < 2e-2)
before = time.clock()
ntests = 100
for i in range(ntests):
nH_bench = ((1.*i)/ntests-1e-6)
for j in range(ntests):
uu_bench = ((2.e5*j)/ntests + 200.)
rates2.get_temp(nH_bench, uu_bench)
after = time.clock()
print(after-before)

def test_heatingcooling_rate():
"""Test the cooling rate."""
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"setuptools",
"wheel",
"numpy",
"scipy",
"h5py",
]
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wheel
numpy
scipy
h5py

0 comments on commit a6ab494

Please sign in to comment.