Skip to content

Commit

Permalink
Add GitHub Actions workflow for running pytest (#54)
Browse files Browse the repository at this point in the history
* Fix pytest

* Remove collect_ignore
* Import function from correct module in test_horizontal_mean.py

* Add GitHub Actions workflow for running pytest
  • Loading branch information
gustavo-marques authored Nov 27, 2024
1 parent 0bf11aa commit b372c34
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Python Tests

on:
push:
branches:
- main # Trigger the workflow when changes are pushed to the main branch
pull_request:
branches:
- main # Trigger the workflow on pull requests targeting the main branch

jobs:
test:
runs-on: ubuntu-latest # Use the latest Ubuntu runner for the job

steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v2

# Step 2: Set up Python (using a version from your project, e.g., 3.11)
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11' # Set the Python version you want to use

# Step 3: Install dependencies (e.g., from requirements.txt)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Step 4: Run pytest
- name: Run pytest
run: |
pytest --maxfail=1 --disable-warnings -v # You can customize pytest flags here
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ select = B,C,E,F,W,T4,B9
# Define setup.py command aliases here
test = pytest

[tool:pytest]
collect_ignore = ['setup.py']
#[tool:pytest]
#collect_ignore = ['setup.py']

[isort]
known_first_party=mom6_tools
Expand Down
2 changes: 1 addition & 1 deletion tests/test_horizontal_mean.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from mom6_tools.stats import HorizontalMeanDiff_da, HorizontalMeanRmse_da
from mom6_tools.drift import HorizontalMeanDiff_da, HorizontalMeanRmse_da
import xarray as xr

# starts with simple cases then build complexity.
Expand Down

0 comments on commit b372c34

Please sign in to comment.