Skip to content

Commit

Permalink
added github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dtamayo committed Jan 24, 2024
1 parent 5fc99e6 commit 4d42d35
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ipynb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: celmech (ipynb)

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["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 pytest matplotlib scipy
pip install wheel setuptools
- name: Install Celmech
run: |
pip install -e . -v
- name: Running jupyter notebooks
run: |
cd jupyter_examples
python ipynb2py.py QuickstartExample.ipynb
30 changes: 30 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: celmech (python)

on: [push, pull_request]

jobs:
build:
name: Python tests on ${{ matrix.os }} (${{ matrix.python-version }})
timeout-minutes: 10

runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.11"]
os: [ubuntu-latest, macos-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 pytest wheel setuptools numpy matplotlib
pip install -e . -v
- name: Output package contents
run: pip show celmech -vf
- name: Run unit tests
run: python -m unittest discover -s celmech/test/ -v
24 changes: 24 additions & 0 deletions jupyter_examples/ipynb2py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
import sys
exec("import matplotlib as mpl")
exec("mpl.use(\"Agg\")")

if len(sys.argv)!=2:
print("Usage: ipynb2py.py FILENAME")
exit(1)
with open(sys.argv[1]) as data_file:
ipynb = json.load(data_file)

code = ""
for c in ipynb["cells"]:
if c["cell_type"] == "code":
source = c["source"]
for s in source:
if s[0] != "%":
code += s.rstrip('\n')+"\n"
import socket
try:
exec(code)
except socket.error:
print("A socket error occured. This is most likely due to a timeout in the NASA Horizons connections. We catch this exception here and ignore is.")
pass

0 comments on commit 4d42d35

Please sign in to comment.