Skip to content

Commit

Permalink
CI: setup GHA (#6)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
martinfleis committed Nov 16, 2022
1 parent fb78481 commit 5198341
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 1 deletion.
56 changes: 56 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions ci/dev.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions ci/latest.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ dependencies:
- numpydoc
- pydata-sphinx-theme
- geopandas
# linting
- flake8
- black
- isort
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ Repository = "https://github.com/martinfleis/xvec"
include = [
"xvec",
"xvec.*",
]
]

[tool.coverage.run]
omit = ["xvec/tests/*"]

0 comments on commit 5198341

Please sign in to comment.