From a6228bd2b36a0782563220873b5b9fa6c7c512e5 Mon Sep 17 00:00:00 2001 From: Son Pham-Ba Date: Thu, 23 Nov 2023 12:51:00 +0100 Subject: [PATCH 1/5] separate windows from linux ci tests --- .github/workflows/tests.yml | 4 ---- .github/workflows/tests_windows.yml | 37 +++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/tests_windows.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c4f6afd..a98b95db 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,10 +25,6 @@ jobs: experimental: false coverage: true - - os: "windows-latest" - python-version: "3.11" - experimental: false - steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml new file mode 100644 index 00000000..1bbddfb4 --- /dev/null +++ b/.github/workflows/tests_windows.yml @@ -0,0 +1,37 @@ +name: Tests Windows +on: [push, pull_request, workflow_dispatch] + +jobs: + tests: + name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}${{ matrix.experimental && ' with latest dependencies' || '' }} + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -el {0} + + strategy: + fail-fast: false + matrix: + os: ["windows-latest"] + python-version: ["3.11"] + experimental: [false] + + steps: + - uses: actions/checkout@v3 + + - name: Set up micromamba and install package dependencies + uses: mamba-org/setup-micromamba@v1 + with: + environment-file: ${{ matrix.experimental && 'ci/environment_latest.yml' || 'ci/environment.yml' }} + create-args: >- + python=${{ matrix.python-version }} + init-shell: >- + bash + + - name: Install the package + run: | + pip install -e . + + - name: Test with pytest + run: | + coverage run -m pytest diff --git a/README.md b/README.md index 05aac09c..751e2918 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ | Deployment | [![PyPI](https://badge.fury.io/py/disdrodb.svg?style=flat)](https://pypi.org/project/disdrodb/) [![Conda](https://img.shields.io/conda/vn/conda-forge/disdrodb.svg?logo=conda-forge&logoColor=white&style=flat)](https://anaconda.org/conda-forge/disdrodb) | | Activity | [![PyPI Downloads](https://img.shields.io/pypi/dm/disdrodb.svg?label=PyPI%20downloads&style=flat)](https://pypi.org/project/disdrodb/) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/disdrodb.svg?label=Conda%20downloads&style=flat)](https://anaconda.org/conda-forge/disdrodb) | | Python Versions | [![Python Versions](https://img.shields.io/badge/Python-3.8%20%203.9%20%203.10%20%203.11%20%203.12-blue?style=flat)](https://www.python.org/downloads/) | -| Supported Systems | [![Linux](https://img.shields.io/github/actions/workflow/status/ltelab/disdrodb/.github/workflows/tests.yml?label=Linux&style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/tests.yml) [![macOS](https://img.shields.io/github/actions/workflow/status/ltelab/disdrodb/.github/workflows/tests.yml?label=macOS&style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/tests.yml) [![Windows](https://img.shields.io/github/actions/workflow/status/ltelab/disdrodb/.github/workflows/tests.yml?label=Windows&style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/tests.yml) | +| Supported Systems | [![Linux](https://img.shields.io/github/actions/workflow/status/ltelab/disdrodb/.github/workflows/tests.yml?label=Linux&style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/tests.yml) [![macOS](https://img.shields.io/github/actions/workflow/status/ltelab/disdrodb/.github/workflows/tests.yml?label=macOS&style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/tests.yml) [![Windows](https://img.shields.io/github/actions/workflow/status/ltelab/disdrodb/.github/workflows/tests_windows.yml?label=Windows&style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/tests_windows.yml) | | Project Status | [![Project Status](https://www.repostatus.org/badges/latest/active.svg?style=flat)](https://www.repostatus.org/#active) | | Build Status | [![Tests](https://github.com/ltelab/disdrodb/actions/workflows/tests.yml/badge.svg?style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/tests.yml) [![Lint](https://github.com/ltelab/disdrodb/actions/workflows/lint.yml/badge.svg?style=flat)](https://github.com/ltelab/disdrodb/actions/workflows/lint.yml) [![Docs](https://readthedocs.org/projects/disdrodb/badge/?version=latest&style=flat)](https://disdrodb.readthedocs.io/en/latest/) | | Linting | [![Black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat)](https://github.com/astral-sh/ruff) [![Codespell](https://img.shields.io/badge/Codespell-enabled-brightgreen?style=flat)](https://github.com/codespell-project/codespell) | From 135aa3fc64e275939508ad393e7ff43e1e70025d Mon Sep 17 00:00:00 2001 From: Son Pham-Ba Date: Thu, 23 Nov 2023 13:23:05 +0100 Subject: [PATCH 2/5] add coverage files export in pyproject --- .github/workflows/tests.yml | 20 ++++++++++++-------- .gitignore | 1 + pyproject.toml | 3 +++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a98b95db..c576cb95 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,24 +43,28 @@ jobs: - name: Test with pytest run: | - coverage run -m pytest + pytest # See pyproject.toml for cov options - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + - name: Upload coverage reports to Codacy + uses: codacy/codacy-coverage-reporter-action@v1 if: matrix.coverage - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.xml - - name: Generate coverage report in LCOV format + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 if: matrix.coverage - run: | - coverage lcov -o coverage/lcov.info + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml - name: Coveralls Parallel uses: coverallsapp/github-action@v2 if: matrix.coverage with: parallel: true + files: lcov.info end-coveralls: needs: [tests] diff --git a/.gitignore b/.gitignore index 83eef221..d966e09e 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,7 @@ htmlcov/ .cache nosetests.xml coverage.xml +lcov.info *.cover *.py,cover .hypothesis/ diff --git a/pyproject.toml b/pyproject.toml index 52eb2538..c359a05f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,9 @@ disdrodb_upload_station="disdrodb.data_transfer.scripts.disdrodb_upload_station: # Metadata archive disdrodb_check_metadata_archive="disdrodb.metadata.scripts.disdrodb_check_metadata_archive:disdrodb_check_metadata_archive" +[tool.pytest.ini_options] +addopts = "--cov --cov-report term-missing --cov-report xml --cov-report lcov:lcov.info" + [tool.ruff] select = ["F", "E", From 63ad7d0232f01f15ee7ded8332fce670ebe0a132 Mon Sep 17 00:00:00 2001 From: Son Pham-Ba Date: Thu, 23 Nov 2023 13:56:36 +0100 Subject: [PATCH 3/5] move codacy order in ci --- .github/workflows/tests.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c576cb95..228d6c72 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,13 +45,6 @@ jobs: run: | pytest # See pyproject.toml for cov options - - name: Upload coverage reports to Codacy - uses: codacy/codacy-coverage-reporter-action@v1 - if: matrix.coverage - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: coverage.xml - - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 if: matrix.coverage @@ -66,6 +59,13 @@ jobs: parallel: true files: lcov.info + - name: Upload coverage reports to Codacy + uses: codacy/codacy-coverage-reporter-action@v1 + if: matrix.coverage + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.xml + end-coveralls: needs: [tests] if: ${{ always() }} From 68d807dff84f7e3d70a8e2d16917d299bb237599 Mon Sep 17 00:00:00 2001 From: Son Pham-Ba Date: Thu, 23 Nov 2023 14:23:40 +0100 Subject: [PATCH 4/5] add python 3.9 and 3.10 to windows ci tests --- .github/workflows/tests_windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index 1bbddfb4..9729e45d 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: ["windows-latest"] - python-version: ["3.11"] + python-version: ["3.9", "3.10", "3.11"] experimental: [false] steps: From d58287af87286742a3952ae5b676d736801d8bba Mon Sep 17 00:00:00 2001 From: Son Pham-Ba Date: Thu, 23 Nov 2023 14:33:08 +0100 Subject: [PATCH 5/5] run codacy only on main branch --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 228d6c72..6e4a27d4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,9 +61,9 @@ jobs: - name: Upload coverage reports to Codacy uses: codacy/codacy-coverage-reporter-action@v1 - if: matrix.coverage + if: matrix.coverage && github.ref == 'refs/heads/main' with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} # Not accessible from PR coverage-reports: coverage.xml end-coveralls: