From ed5e32048175d48b55317f5665e50210b5e413af Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Wed, 20 Sep 2023 05:56:04 +0000 Subject: [PATCH 1/9] simple test suite --- smpsite/smpsite/test/__init__.py | 0 smpsite/smpsite/test/test_execution.py | 12 ++++++++++++ 2 files changed, 12 insertions(+) create mode 100644 smpsite/smpsite/test/__init__.py create mode 100644 smpsite/smpsite/test/test_execution.py diff --git a/smpsite/smpsite/test/__init__.py b/smpsite/smpsite/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/smpsite/smpsite/test/test_execution.py b/smpsite/smpsite/test/test_execution.py new file mode 100644 index 0000000..af54e97 --- /dev/null +++ b/smpsite/smpsite/test/test_execution.py @@ -0,0 +1,12 @@ +import numpy as np +from numpy.testing import assert_allclose +import smpsite as smp + +def test_run_kappa_from_latitude(): + _res = smp.kappa_from_latitude(10.0, degrees=True) + assert isinstance(_res, np.ndarray) + assert _res.shape == () + +def test_run_lat_correction(): + _res = smp.lat_correction(30.0, degrees=True) + assert_allclose(_res, 1.2578124999999998, atol=1e-6) \ No newline at end of file From 786404a62e883c932df5f5a55825c46855494687 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 22:59:48 -0700 Subject: [PATCH 2/9] Create test.yml --- .github/workflows/test.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1610409 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: Testing + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9"] + + 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 flake8 pytest + # if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi + - name: Install dependencies manually + run: | + pip install future matplotlib cartopy pandas requests seaborn jupyter-book scikit-learn ipywidgets + pip install pmagpy==4.2.106 + pip install -e ./smpsite + pip install flake8 pytest + - 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 smpsite From 92d94a8ab333aefd3416b8ffad96876e6164b7e8 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 23:04:09 -0700 Subject: [PATCH 3/9] Add passing test badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7770e53..e2f8584 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ For a detailed description of the project, take a look at [our preprint of a man [![DOI](https://zenodo.org/badge/595793364.svg)](https://zenodo.org/badge/latestdoi/595793364) [![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://polarwandering.github.io/PaleoSampling/) [![Build Status](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml/badge.svg?branch=main)](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml?query=branch%3Amain) +![Tests Passing](https://github.com/github/docs/actions/workflows/test.yml/badge.svg) [![All Contributors](https://img.shields.io/github/all-contributors/PolarWandering/PaleoSampling?color=ee8449&style=flat-square)](#contributors) From 8665cdc5b98650b20abaa22e4fd926eb0c363ba0 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 23:19:07 -0700 Subject: [PATCH 4/9] add codedev action --- .github/workflows/test.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1610409..1fbe3a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,11 +16,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - # - name: Install dependencies - # run: | - # python -m pip install --upgrade pip - # pip install flake8 pytest - # if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi - name: Install dependencies manually run: | pip install future matplotlib cartopy pandas requests seaborn jupyter-book scikit-learn ipywidgets @@ -36,3 +31,7 @@ jobs: - name: Test with pytest run: | pytest smpsite + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 3a48e594f2b21d8f4836b2d04001cb66edd71350 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 23:26:37 -0700 Subject: [PATCH 5/9] Add directory to codecov action --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1fbe3a4..c077433 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,5 +33,7 @@ jobs: pytest smpsite - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 + with: + directory: ./smpsite env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From a4c311fb915e341feee3b4f5bc1590495e8208a4 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 23:38:17 -0700 Subject: [PATCH 6/9] add coverage option to pytest --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c077433..15d10c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,10 +30,10 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - pytest smpsite + pytest smpsite --cov --cov-report=html:coverage_re - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 - with: - directory: ./smpsite + # with: + # directory: ./smpsite env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 5a089472d482eb112c1b7de7c78cfe750a8e6422 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 23:42:14 -0700 Subject: [PATCH 7/9] install pytest-cov --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15d10c0..39eace1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: pip install future matplotlib cartopy pandas requests seaborn jupyter-book scikit-learn ipywidgets pip install pmagpy==4.2.106 pip install -e ./smpsite - pip install flake8 pytest + pip install flake8 pytest pytest-cov - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From b22914af4862bef429c54cc5c3e69090bab164f9 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 23:45:54 -0700 Subject: [PATCH 8/9] Add covering badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e2f8584..f4307ea 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ For a detailed description of the project, take a look at [our preprint of a man [![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://polarwandering.github.io/PaleoSampling/) [![Build Status](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml/badge.svg?branch=main)](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml?query=branch%3Amain) ![Tests Passing](https://github.com/github/docs/actions/workflows/test.yml/badge.svg) +[![codecov](https://codecov.io/gh/facusapienza21/PaleoSampling/graph/badge.svg?token=L3WO0AEN90)](https://codecov.io/gh/facusapienza21/PaleoSampling) [![All Contributors](https://img.shields.io/github/all-contributors/PolarWandering/PaleoSampling?color=ee8449&style=flat-square)](#contributors) From 87d2753264df99e5476f9a3ab3a117748a7c5e40 Mon Sep 17 00:00:00 2001 From: Facundo Sapienza Date: Tue, 19 Sep 2023 23:49:04 -0700 Subject: [PATCH 9/9] facusapienza21 -> PolarWandering --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f4307ea..cb4a9ae 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ For a detailed description of the project, take a look at [our preprint of a man [![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://polarwandering.github.io/PaleoSampling/) [![Build Status](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml/badge.svg?branch=main)](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml?query=branch%3Amain) ![Tests Passing](https://github.com/github/docs/actions/workflows/test.yml/badge.svg) -[![codecov](https://codecov.io/gh/facusapienza21/PaleoSampling/graph/badge.svg?token=L3WO0AEN90)](https://codecov.io/gh/facusapienza21/PaleoSampling) +[![codecov](https://codecov.io/gh/PolarWandering/PaleoSampling/graph/badge.svg?token=L3WO0AEN90)](https://codecov.io/gh/PaleoWandering/PaleoSampling) [![All Contributors](https://img.shields.io/github/all-contributors/PolarWandering/PaleoSampling?color=ee8449&style=flat-square)](#contributors)