Skip to content

Commit

Permalink
Add GitHub Actions workflow for testing with pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
jgieseler committed Dec 16, 2024
1 parent 15d3162 commit 74e421f
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/pytest.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: pytest

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

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-doctestplus pytest-cov pytest-mpl
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -rP --mpl --mpl-baseline-path=baseline --mpl-baseline-relative --mpl-generate-summary=html --mpl-results-path='/home/runner/work/bowtie/Bowtie/tests/report/' --cov=Bowtie Bowtie/tests/test.py
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v4
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Save pytest-mpl report as artifcat
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.python-version }}-pytest-mpl-report-artifact
path: "/home/runner/work/bowtie/Bowtie/tests/report/"
257 changes: 257 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
### Python: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
tmp/

# C extensions
*.so

# Distribution / packaging
.Python
pip-wheel-metadata/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
junit/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

### https://raw.github.com/github/gitignore/master/Global/OSX.gitignore

.DS_Store
.AppleDouble
.LSOverride

# Icon must ends with two \r.
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

### Linux: https://raw.githubusercontent.com/github/gitignore/master/Global/Linux.gitignore

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### MacOS: https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Windows: https://raw.githubusercontent.com/github/gitignore/master/Global/Windows.gitignore

# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

### VScode: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore
.vscode/*
.vscode/
.vs/*

### Extra Python Items and SunPy Specific
.hypothesis
.pytest_cache
sunpydata.sqlite
sunpydata.sqlite-journal
sunpy/_compiler.c
sunpy/cython_version.py
sunpy/_version.py
docs/_build
docs/generated
docs/whatsnew/latest_changelog.txt
examples/**/*.asdf
examples/**/*.csv
figure_test_images*
tags
sunpy_map.asdf
# baseline
docs/guide/data_types/figure.png
october_M1_flares.csv
aia_map.fits

### Pycharm(?)
.idea

# Release script
.github_cache

# Misc Stuff
.history
*.orig
.tmp

# PyInstaller Files
.pyinstaller/run_tests
.pyinstaller/run_tests.spec
.pyinstaller/sunpy_tests

### Vagrant: https://www.toptal.com/developers/gitignore/api/vagrant
# General
.vagrant/

# Log files generated by 'vagrant up'
*.log

### Vagrant Patch ###
*.box

# asv stuff
asv_env
asv_results
html
results
result_images
2 changes: 1 addition & 1 deletion Bowtie/plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup_latex(rcParams, no_fourier=False):
:param rcParams: rcParams imported locally from matplotlib
:param no_fourier: True if there is no fourier package in your LaTeX distribution and it is impossible to install it (e.g. on Dione)
"""
rcParams['text.usetex'] = True
rcParams['text.usetex'] = False
if no_fourier:
rcParams['text.latex.preamble'] = r'\usepackage{amsmath}' + '\n' + r'\usepackage{amssymb}' + '\n' + r'\usepackage{graphicx}'
else:
Expand Down
3 changes: 3 additions & 0 deletions Bowtie/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
This module contains package tests.
"""
Binary file added Bowtie/tests/baseline/test_bowtie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 74e421f

Please sign in to comment.