From b372c34ed7a11bfcdf57887fb262797d2c7324a0 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Wed, 27 Nov 2024 11:48:19 -0300 Subject: [PATCH] Add GitHub Actions workflow for running pytest (#54) * Fix pytest * Remove collect_ignore * Import function from correct module in test_horizontal_mean.py * Add GitHub Actions workflow for running pytest --- .github/workflows/python-tests.yml | 36 ++++++++++++++++++++++++++++++ setup.cfg | 4 ++-- tests/test_horizontal_mean.py | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/python-tests.yml diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml new file mode 100644 index 0000000..1575873 --- /dev/null +++ b/.github/workflows/python-tests.yml @@ -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 + diff --git a/setup.cfg b/setup.cfg index 5570f61..32c749f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tests/test_horizontal_mean.py b/tests/test_horizontal_mean.py index ec5bf25..af3173f 100644 --- a/tests/test_horizontal_mean.py +++ b/tests/test_horizontal_mean.py @@ -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.