From 5198341b26406838042cb48caf84437eb993a320 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Wed, 16 Nov 2022 19:49:45 +0100 Subject: [PATCH] CI: setup GHA (#6) * CI: setup GHA * fix suffixes * avoid duplication * ignore tests in coverage * add linting pre-commit and check * fix pre-commit * use bash as a default shell * typo * include isort * remove linting and use pre-commit.ci instead * use pytest-reportlog * include pytest-reportlog in latest * add id to run tests --- .github/workflows/tests.yaml | 56 ++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 20 +++++++++++++ ci/dev.yaml | 18 ++++++++++++ ci/latest.yaml | 14 +++++++++ environment.yml | 4 +++ pyproject.toml | 5 +++- 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 ci/dev.yaml create mode 100644 ci/latest.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..207f605 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,56 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: + - "*" + + schedule: + - cron: "59 23 * * 3" + +jobs: + Tests: + name: ${{ matrix.os }}, ${{ matrix.environment-file }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + environment-file: [ci/latest.yaml] + include: + - environment-file: ci/dev.yaml + os: ubuntu-latest + defaults: + run: + shell: bash -l {0} + + steps: + - name: checkout repo + uses: actions/checkout@v2 + + - name: setup micromamba + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ${{ matrix.environment-file }} + micromamba-version: "latest" + channel-priority: "flexible" + + - name: Install xvec + run: pip install . + + - name: run tests + id: status + run: pytest -v . -m "not request" --cov=xvec --cov-append --cov-report term-missing --cov-report xml --color=yes --report-log pytest-log.jsonl + + - uses: codecov/codecov-action@v3 + + - name: Generate and publish the report + if: | + failure() + && steps.status.outcome == 'failure' + && github.event_name == 'schedule' + && github.repository_owner == 'martinfleis' + uses: xarray-contrib/issue-from-pytest-log@v1 + with: + log-path: pytest-log.jsonl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7845c8a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +files: 'xvec\/' +repos: + - repo: https://github.com/python/black + rev: 22.10.0 + hooks: + - id: black + language_version: python3 + - repo: https://github.com/pycqa/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + language: python_venv + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + language_version: python3 + +ci: + autofix_prs: false diff --git a/ci/dev.yaml b/ci/dev.yaml new file mode 100644 index 0000000..56ffe61 --- /dev/null +++ b/ci/dev.yaml @@ -0,0 +1,18 @@ +name: xvec_dev +channels: + - conda-forge + - conda-forge/label/shapely_dev +dependencies: + - python + # to build from source + - cython + - geos + # testing + - pytest + - pytest-cov + - pytest-xdist + - pytest-reportlog + - pip + - pip: + - git+https://github.com/shapely/shapely.git@main + - git+https://github.com/pydata/xarray.git@main diff --git a/ci/latest.yaml b/ci/latest.yaml new file mode 100644 index 0000000..9f113f4 --- /dev/null +++ b/ci/latest.yaml @@ -0,0 +1,14 @@ +name: xvec +channels: + - conda-forge + - conda-forge/label/shapely_dev +dependencies: + - python + # required + - shapely=2 + - xarray + # testing + - pytest + - pytest-cov + - pytest-xdist + - pytest-reportlog diff --git a/environment.yml b/environment.yml index 1b42a79..6968c44 100644 --- a/environment.yml +++ b/environment.yml @@ -18,3 +18,7 @@ dependencies: - numpydoc - pydata-sphinx-theme - geopandas + # linting + - flake8 + - black + - isort diff --git a/pyproject.toml b/pyproject.toml index 0c1cfe6..b14b7de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,4 +39,7 @@ Repository = "https://github.com/martinfleis/xvec" include = [ "xvec", "xvec.*", -] \ No newline at end of file +] + +[tool.coverage.run] +omit = ["xvec/tests/*"]