diff --git a/.github/actions/install-icepyx/action.yml b/.github/actions/install-icepyx/action.yml new file mode 100644 index 000000000..fb738d7cd --- /dev/null +++ b/.github/actions/install-icepyx/action.yml @@ -0,0 +1,19 @@ +name: 'Install icepyx' +description: 'Install icepyx and dev dependencies' + +inputs: + python-version: + required: true + +runs: + using: "composite" + steps: + - uses: "actions/setup-python@v5" + with: + python-version: "${{ inputs.python-version }}" + + - name: "Install package and test dependencies" + shell: "bash" + run: | + python -m pip install . + python -m pip install -r requirements-dev.txt diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml new file mode 100644 index 000000000..1c9dc6ed7 --- /dev/null +++ b/.github/workflows/integration_test.yml @@ -0,0 +1,53 @@ +name: "Integration test" +# NOTE: We're just running the tests that require earthdata login here; we +# don't distinguish between unit and integration tests yet. + +on: + push: + branches: + - "main" # Releases + - "development" # PR merges + pull_request: + branches: + - "main" # Release pull requests + pull_request_review: + types: + - "submitted" + paths: + - ".github/**" + - "icepyx/**/*.py" + - "pyproject.toml" + - "requirements*.txt" + + +jobs: + test: + name: "Integration test" + # Job is conditional: + # - Do not run on PRs from forks + # - Do not run on `pull_request_review` events unless the PR is approved. + if: "${{ !github.event.pull_request.head.repo.fork && (github.event.action != 'pull_request_review' || github.event.review.state == 'approved') }}" + runs-on: "ubuntu-latest" + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 0 + + - uses: "./.github/actions/install-icepyx" + with: + python-version: "3.12" + + - name: "Run tests" + env: + EARTHDATA_PASSWORD: "${{ secrets.EARTHDATA_PASSWORD }}" + NSIDC_LOGIN: "${{ secrets.EARTHDATA_PASSWORD }}" + run: | + pytest icepyx/ --verbose --cov app \ + icepyx/tests/test_behind_NSIDC_API_login.py \ + icepyx/tests/test_auth.py + + - name: "Upload coverage report" + uses: "codecov/codecov-action@v4.5.0" + with: + token: "${{ secrets.CODECOV_TOKEN }}" diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml new file mode 100644 index 000000000..989c7e298 --- /dev/null +++ b/.github/workflows/unit_test.yml @@ -0,0 +1,40 @@ +name: "Unit test" +# NOTE: We're just skipping the tests requiring earthdata login here; we don't +# distinguish yet between unit and integration tests. + +on: + pull_request: + push: + branches: + - "main" + - "development" + + +jobs: + test: + name: "Unit test (Python ${{ matrix.python-version }})" + runs-on: "ubuntu-latest" + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.12"] #NOTE: min and max Python versions supported by icepyx + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 0 + + - uses: "./.github/actions/install-icepyx" + with: + python-version: "${{ matrix.python-version }}" + + - name: "Run tests" + run: | + pytest icepyx/ --verbose --cov app \ + --ignore=icepyx/tests/test_behind_NSIDC_API_login.py \ + --ignore=icepyx/tests/test_auth.py + + - name: "Upload coverage report" + uses: "codecov/codecov-action@v4.5.0" + with: + token: "${{ secrets.CODECOV_TOKEN }}" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 271eb5bff..000000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: python - -before_install: - - sudo apt-get update - - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - # Useful for debugging any issues with conda - - conda info -a - -install: - - conda create --name icepyx-env --channel conda-forge python=3.10 proj geos - - source activate icepyx-env - - pip install -r requirements.txt -r requirements-dev.txt - - pip install -e .[complete] - -stages: - - name: basic tests - if: (type = pull_request) OR (type = push AND repo = icesat2py/icepyx AND branch IN (main, development)) - - name: behind Earthdata - if: branch = main OR commit_message =~ nsidc_tests OR type = cron - -#ultimately move basic tests list into a separate script with the list of files to run (then this can be put into a matrix and parallellized as well) -jobs: - include: - - stage: basic tests - script: pytest icepyx/ --verbose --cov app --ignore=icepyx/tests/test_behind_NSIDC_API_login.py --ignore=icepyx/tests/test_auth.py - # includes an integrity check of the uploader as recommended by CodeCov - after_success: - - curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import # One-time step - - curl -Os https://uploader.codecov.io/latest/linux/codecov - - curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM - - curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig - - gpgv codecov.SHA256SUM.sig codecov.SHA256SUM - - shasum -a 256 -c codecov.SHA256SUM - - chmod +x codecov - - ./codecov -t ${CODECOV_TOKEN} - - stage: behind Earthdata - script: - - export EARTHDATA_PASSWORD=$NSIDC_LOGIN - - pytest icepyx/tests/test_behind_NSIDC_API_login.py icepyx/tests/test_auth.py diff --git a/README.rst b/README.rst index 5ef8b1ba7..b89dd51e0 100644 --- a/README.rst +++ b/README.rst @@ -7,9 +7,9 @@ icepyx |JOSS| |Zenodo-all| -Latest release (main branch): |Docs Status main| |Travis main Build Status| |Code Coverage main| +Latest release (main branch): |Docs Status main| |Unit Tests Status (main)| |Integration Tests Status (main)| |Code Coverage main| -Current development version (development branch): |Docs Status dev| |Travis dev Build Status| |Code Coverage dev| |Pre-commit dev| +Current development version (development branch): |Docs Status dev| |Unit Tests Status (dev)| |Integration Tests Status (main)| |Code Coverage dev| |Pre-commit dev| .. |GitHub license| image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg :target: https://opensource.org/licenses/BSD-3-Clause @@ -38,11 +38,17 @@ Current development version (development branch): |Docs Status dev| |Travis dev .. |Docs Status dev| image:: https://readthedocs.org/projects/icepyx/badge/?version=development :target: https://icepyx.readthedocs.io/en/development -.. |Travis main Build Status| image:: https://app.travis-ci.com/icesat2py/icepyx.svg?branch=main - :target: https://app.travis-ci.com/icesat2py/icepyx +.. |Unit Tests Status (main)| image:: https://github.com/icesat2py/icepyx/actions/workflows/unit_test.yml/badge.svg?branch=main + :target: https://github.com/icesat2py/icepyx/actions/workflows/unit_test.yml -.. |Travis dev Build Status| image:: https://app.travis-ci.com/icesat2py/icepyx.svg?branch=development - :target: https://app.travis-ci.com/icesat2py/icepyx +.. |Integration Tests Status (main)| image:: https://github.com/icesat2py/icepyx/actions/workflows/integration_test.yml/badge.svg?branch=main + :target: https://github.com/icesat2py/icepyx/actions/workflows/integration_test.yml + +.. |Unit Tests Status (dev)| image:: https://github.com/icesat2py/icepyx/actions/workflows/unit_test.yml/badge.svg?branch=development + :target: https://github.com/icesat2py/icepyx/actions/workflows/unit_test.yml + +.. |Integration Tests Status (dev)| image:: https://github.com/icesat2py/icepyx/actions/workflows/integration_test.yml/badge.svg?branch=development + :target: https://github.com/icesat2py/icepyx/actions/workflows/integration_test.yml .. |Code Coverage main| image:: https://codecov.io/gh/icesat2py/icepyx/branch/main/graph/badge.svg :target: https://codecov.io/gh/icesat2py/icepyx