Skip to content

Commit 476036c

Browse files
authored
CI updates (#44)
* Split into compabitibility vs unit tests * Update the python versions we test on * .gitignore updates * include a MANIFEST.in * Use a valid unreleased semvar in VERSION * Switch to pyproject.toml * Use pre-commit for CI checks * Fix isort issues * Update coverage, build badges * Add black to the CI * Add coverage, macOS files to gitignore * VERSION file must be specified in a list * Use checkout@v3 for all test runs * Extra black exceptions
1 parent 0968941 commit 476036c

21 files changed

+667
-471
lines changed

.github/workflows/python-package.yaml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,58 @@ on:
1212
- master
1313

1414
jobs:
15-
test:
15+
unit-test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up Python 3.10
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.10"
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -e .[test]
27+
pre-commit install
28+
pre-commit autoupdate
29+
- name: Lint with precommit checks
30+
run: |
31+
pre-commit run --all-files
32+
- name: Test with Pytest
33+
run: |
34+
pytest \
35+
--junitxml=junit/test-results.xml \
36+
--cov-report=xml --cov=carsons \
37+
tests/
38+
- name: Make coverage file
39+
run: |
40+
coverage xml
41+
- uses: codecov/codecov-action@v3
42+
with:
43+
files: ./coverage.xml # optional
44+
flags: unittests # optional
45+
name: codecov-umbrella # optional
46+
fail_ci_if_error: true # optional (default = false)
47+
verbose: true # optional (default = false)
48+
49+
compatibility:
50+
needs: unit-test
1651
runs-on: ubuntu-latest
1752
strategy:
1853
fail-fast: false
1954
matrix:
20-
python-version: [3.6, 3.7, 3.8, 3.9]
55+
python-version: ["3.7", "3.8", "3.9", "3.11", pypy3.8, pypy3.9]
56+
# skipping 3.10 since the unit-test job runs against it
2157
steps:
22-
- uses: actions/checkout@v2
58+
- uses: actions/checkout@v3
2359
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v2
60+
uses: actions/setup-python@v4
2561
with:
2662
python-version: ${{ matrix.python-version }}
2763
- name: Install dependencies
2864
run: |
2965
python -m pip install --upgrade pip
3066
pip install -e .[test]
31-
- name: Lint with flake8
32-
run: |
33-
flake8
3467
- name: Test with Pytest
3568
run: |
36-
pytest \
37-
--junitxml=junit/test-results.xml \
38-
--mypy \
39-
--cov-report term-missing --cov-report=xml --cov-report=html --cov=carsons \
40-
tests/
69+
pytest

.github/workflows/python-publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
VERSION_FILE: $(basename $GITHUB_REPOSITORY)/VERSION
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Set up Python
24-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v4
2525
with:
2626
python-version: '3.x'
2727
- name: Install dependencies

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,15 @@
33
*/__pycache__/
44

55
.coverage
6+
.coverage.xml
7+
8+
# IDE stuff
69
carsons.code-workspace
10+
.DS_store
11+
12+
# pyenv
13+
.python-version
14+
15+
# build
16+
dist
17+
*.egg-info

.pre-commit-config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# pre-commit runs static analysis in the CI for this repo
2+
#
3+
# you can also use it to have the static analysis run incrementally on your commits;
4+
#
5+
# install:
6+
#
7+
# pip install .[test]
8+
# pre-commit install
9+
#
10+
# after this, pre-commit will run automatically when you run `git commit`; it will
11+
# flag any answers, and in the case of black / isort will automatically update
12+
# your local files
13+
#
14+
# run on the whole repo: pre-commit run --all-files
15+
# run a single hook: pre-commit run --all-files black
16+
repos:
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v4.4.0
19+
hooks:
20+
- id: mixed-line-ending
21+
args: ['--fix=lf']
22+
description: Forces to replace line ending by the UNIX 'lf' character.
23+
24+
- repo: https://github.com/pycqa/flake8
25+
rev: 6.0.0
26+
hooks:
27+
- id: flake8
28+
name: Flake PEP8 check
29+
additional_dependencies: ["importlib-metadata<=4.13.0"]
30+
args: ["--max-line-length=120"]
31+
32+
- repo: https://github.com/psf/black
33+
rev: 22.12.0
34+
hooks:
35+
- id: black
36+
name: Black autoformatting
37+
38+
- repo: https://github.com/pycqa/isort
39+
rev: 5.11.4
40+
hooks:
41+
- id: isort
42+
43+
- repo: https://github.com/pre-commit/mirrors-mypy
44+
rev: "v0.991"
45+
hooks:
46+
- id: mypy

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include carsons/VERSION
2+
include carsons/py.typed
3+
4+
prune tests

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ carsons
44
[![latest release on pypi](https://badge.fury.io/py/carsons.svg)](https://badge.fury.io/py/carsons)
55
[![versons of python supported by carsons](https://img.shields.io/pypi/pyversions/carsons.svg)](https://pypi.python.org/pypi/carsons)
66
[![GitHub license](https://img.shields.io/github/license/opusonesolutions/carsons.svg)](https://github.com/opusonesolutions/carsons/blob/master/LICENSE.txt)
7-
[![build passing or failing](https://travis-ci.org/opusonesolutions/carsons.svg?branch=master)](https://travis-ci.org/opusonesolutions/carsons)
7+
[![build passing or failing](https://github.com/opusonesolutions/carsons/blob/master/.github/workflows/python-package.yaml/badge.svg)](https://travis-ci.org/opusonesolutions/carsons)
88
[![test coverage](https://coveralls.io/repos/github/opusonesolutions/carsons/badge.svg?branch=master)](https://coveralls.io/github/opusonesolutions/carsons?branch=master)
99
[![Maintainability](https://api.codeclimate.com/v1/badges/22cfed180fd6032fe29b/maintainability)](https://codeclimate.com/github/opusonesolutions/carsons/maintainability)
1010

carsons/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
unreleased
1+
99999999999.0.0.dev0+unreleased

carsons/__init__.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
from carsons.carsons import (convert_geometric_model, # noqa 401
2-
calculate_impedance, # noqa 401
3-
calculate_sequence_impedance_matrix,
4-
calculate_sequence_impedances,
5-
CarsonsEquations,
6-
ConcentricNeutralCarsonsEquations, # noqa 401
7-
MultiConductorCarsonsEquations, # noqa 401
8-
TapeShieldedCableCarsonsEquations) # noqa 401
1+
from carsons.carsons import ( # noqa F401
2+
CarsonsEquations,
3+
ConcentricNeutralCarsonsEquations,
4+
MultiConductorCarsonsEquations,
5+
TapeShieldedCableCarsonsEquations,
6+
calculate_impedance,
7+
calculate_sequence_impedance_matrix,
8+
calculate_sequence_impedances,
9+
convert_geometric_model,
10+
)
911

1012
name = "carsons"
13+
14+
15+
def get_version():
16+
import sys
17+
18+
# TODO: if 3.8 support is dropped, we can standardize on
19+
# importlib.resources.files
20+
if sys.version_info < (3, 9):
21+
from importlib.resources import read_text
22+
23+
return read_text(__name__, "VERSION").strip()
24+
else:
25+
from importlib.resources import files
26+
27+
return files(__name__).joinpath("VERSION").open("r").read().strip()
28+
29+
30+
__version__ = get_version()

0 commit comments

Comments
 (0)