Skip to content

Commit 65cfc69

Browse files
authored
Migrate to pyproject.toml and common workflows (#59)
* move to pyproject file * remove setup.py * use common workflows * define __all__ * membership test should be 'not in' * update authors metadata as discussed
1 parent 98cbde9 commit 65cfc69

File tree

10 files changed

+98
-288
lines changed

10 files changed

+98
-288
lines changed

.github/workflows/README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
# Continous Integration Workflows
22

3-
This package implements different workflows for CI.
3+
This package implements different workflows for CI, based on our organisation's common workflows.
44
They are organised as follows.
55

66
### Documentation
77

88
The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful).
9-
It runs on `ubuntu-latest` and `Python 3.7`.
109

1110
### Testing Suite
1211

1312
Tests are ensured in the `tests` workflow, which triggers on all pushes.
14-
It runs on a matrix of all supported operating systems (ubuntu-18.04, ubuntu-20.04, windows-latest and macos-latest) for all supported Python versions (currently `3.7`, `3.8`, `3.9` and `3.10`).
13+
It runs on a matrix of all supported operating systems for all supported Python versions.
1514

1615
### Test Coverage
1716

1817
Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`.
19-
It runs on `ubuntu-latest` & `Python 3.7`, and reports the coverage results of the test suite to `CodeClimate`,
20-
18+
It reports the coverage results of the test suite to `CodeClimate`.
2119

2220
### Regular Testing
2321

2422
A `cron` workflow triggers every Monday at 3am (UTC time) and runs the full testing suite, on all available operating systems and supported Python versions.
25-
It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically detected.
23+
It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically included.
2624

2725
### Publishing
2826

29-
Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the Github repository.
30-
It builds a `wheel`, checks it, and pushes to `PyPI` if checks are successful.
27+
Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the GitHub repository.
28+
It builds a `wheel`, checks it, and pushes to `PyPI` if checks are successful.

.github/workflows/coverage.yml

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Runs all tests and pushes coverage report to codeclimate
22
name: Coverage
33

4-
defaults:
5-
run:
6-
shell: bash
7-
84
on: # Runs on all push events to master branch and any push related to a pull request
95
push:
106
branches:
@@ -13,60 +9,7 @@ on: # Runs on all push events to master branch and any push related to a pull r
139

1410
jobs:
1511
coverage:
16-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
matrix: # only lowest supported Python on latest ubuntu
20-
os: [ubuntu-latest]
21-
python-version: [3.7]
22-
23-
steps:
24-
- uses: actions/checkout@v3
25-
26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v4
28-
with:
29-
python-version: ${{ matrix.python-version }}
30-
cache: 'pip'
31-
cache-dependency-path: '**/setup.py'
32-
33-
- name: Get full Python version
34-
id: full-python-version
35-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
36-
37-
- name: Upgrade pip, setuptools and wheel
38-
run: python -m pip install --upgrade pip setuptools wheel
39-
40-
- name: Install package
41-
run: python -m pip install '.[test]'
42-
43-
- name: Set up env for CodeClimate (push)
44-
run: |
45-
echo "GIT_BRANCH=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_ENV
46-
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
47-
if: github.event_name == 'push'
48-
49-
- name: Set up env for CodeClimate (pull_request)
50-
env:
51-
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
52-
run: |
53-
echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
54-
echo "GIT_COMMIT_SHA=$PR_HEAD_SHA" >> $GITHUB_ENV
55-
if: github.event_name == 'pull_request'
56-
57-
- name: Prepare CodeClimate binary
58-
env:
59-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
60-
run: |
61-
curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter;
62-
chmod +x ./cc-test-reporter
63-
./cc-test-reporter before-build
64-
65-
- name: Run all tests
66-
run: python -m pytest --cov-report xml --cov=generic_parser
67-
68-
- name: Push Coverage to CodeClimate
69-
if: ${{ success() }} # only if tests were successful
70-
env:
71-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
72-
run: ./cc-test-reporter after-build
12+
uses: pylhc/.github/.github/workflows/coverage.yml@master
13+
with:
14+
src-dir: generic_parser
15+
secrets: inherit

.github/workflows/cron.yml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,13 @@
1-
# Runs all tests on master everyday at 10 am (UTC time)
1+
# Runs all tests on master on Mondays at 3 am (UTC time)
22
name: Cron Testing
33

4-
defaults:
5-
run:
6-
shell: bash
74

8-
on: # Runs on master branch on Mondays at 3am UTC time
5+
on:
96
schedule:
107
- cron: '* 3 * * mon'
118

129
jobs:
13-
tests:
14-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
15-
runs-on: ${{ matrix.os }}
16-
strategy:
17-
matrix:
18-
os: [ubuntu-18.04, ubuntu-20.04, macos-latest, windows-latest]
19-
# Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser
20-
python-version: [3.7, 3.8, 3.9, "3.10", 3.x] # crons should always run latest python hence 3.x
21-
22-
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/setup.py'
31-
32-
- name: Get full Python version
33-
id: full-python-version
34-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
35-
36-
- name: Upgrade pip, setuptools and wheel
37-
run: python -m pip install --upgrade pip setuptools wheel
38-
39-
- name: Install package
40-
run: python -m pip install '.[test]'
41-
42-
- name: Run all tests
43-
run: python -m pytest
10+
tests:
11+
uses: pylhc/.github/.github/workflows/cron.yml@master
12+
with:
13+
extra-dependencies: test

.github/workflows/documentation.yml

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,14 @@
11
# Build documentation
2+
# The build is uploaded as artifact if the triggering event is a push for a pull request
3+
# The build is published to github pages if the triggering event is a push to the master branch (PR merge)
24
name: Build and upload documentation
35

4-
defaults:
5-
run:
6-
shell: bash
7-
8-
on: # Runs on any push event to master
6+
on: # Runs on any push event in a PR or any push event to master
7+
pull_request:
98
push:
109
branches:
1110
- 'master'
1211

1312
jobs:
1413
documentation:
15-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
16-
runs-on: ${{ matrix.os }}
17-
strategy:
18-
matrix: # only lowest supported Python on latest ubuntu
19-
os: [ubuntu-latest]
20-
python-version: [3.7]
21-
22-
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/setup.py'
31-
32-
- name: Get full Python version
33-
id: full-python-version
34-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
35-
36-
- name: Upgrade pip, setuptools and wheel
37-
run: python -m pip install --upgrade pip setuptools wheel
38-
39-
- name: Install package
40-
run: python -m pip install '.[doc]'
41-
42-
- name: Build documentation
43-
run: python -m sphinx -b html doc ./doc_build -d ./doc_build
44-
45-
- name: Upload documentation to gh-pages
46-
if: ${{ success() }}
47-
uses: JamesIves/[email protected]
48-
with:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
BRANCH: gh-pages
51-
FOLDER: doc_build
14+
uses: pylhc/.github/.github/workflows/documentation.yml@master

.github/workflows/publish.yml

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,11 @@
11
# Publishes to PyPI upon creation of a release
22
name: Upload Package to PyPI
33

4-
defaults:
5-
run:
6-
shell: bash
7-
84
on: # Runs everytime a release is added to the repository
95
release:
106
types: [created]
117

128
jobs:
139
deploy:
14-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
15-
runs-on: ${{ matrix.os }}
16-
strategy:
17-
matrix: # only lowest supported Python on latest ubuntu
18-
os: [ubuntu-latest]
19-
python-version: [3.7]
20-
21-
22-
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/setup.py'
31-
32-
- name: Get full Python version
33-
id: full-python-version
34-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
35-
36-
- name: Upgrade pip, setuptools, wheel, build and twine
37-
run: python -m pip install --upgrade pip setuptools wheel build twine
38-
39-
- name: Build and check build
40-
run: |
41-
python -m build
42-
twine check dist/*
43-
44-
- name: Publish
45-
if: ${{ success() }}
46-
env:
47-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
48-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
49-
run: |
50-
twine upload dist/*
10+
uses: pylhc/.github/.github/workflows/publish.yml@master
11+
secrets: inherit

.github/workflows/tests.yml

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,17 @@
11
# Runs all tests
2-
name: Tests
2+
name: All Tests
33

44
defaults:
55
run:
66
shell: bash
77

8-
on: [push] # Runs on all push events to any branch
9-
8+
on: # Runs on any push event to any branch except master (the coverage workflow takes care of that)
9+
push:
10+
branches-ignore:
11+
- 'master'
1012

1113
jobs:
1214
tests:
13-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
14-
runs-on: ${{ matrix.os }}
15-
strategy:
16-
matrix:
17-
os: [ubuntu-18.04, ubuntu-20.04, macos-latest, windows-latest]
18-
# Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser
19-
python-version: [3.7, 3.8, 3.9, "3.10"]
20-
21-
steps:
22-
- uses: actions/checkout@v3
23-
24-
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v4
26-
with:
27-
python-version: ${{ matrix.python-version }}
28-
cache: 'pip'
29-
cache-dependency-path: '**/setup.py'
30-
31-
- name: Get full Python version
32-
id: full-python-version
33-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
34-
35-
- name: Upgrade pip, setuptools and wheel
36-
run: python -m pip install --upgrade pip setuptools wheel
37-
38-
- name: Install package
39-
run: python -m pip install '.[test]'
40-
41-
- name: Run basic tests
42-
run: python -m pytest
15+
uses: pylhc/.github/.github/workflows/tests.yml@master
16+
with:
17+
extra-dependencies: test

generic_parser/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
__author__ = "pylhc"
1010
__author_email__ = "[email protected]"
1111
__license__ = "MIT"
12+
13+
__all__ = ["EntryPoint", "EntryPointParameters", "entrypoint", "DotDict"]

generic_parser/dict_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def _parse_arguments(self, arg_dict, param_dict):
160160
checked_dict[key] = DictParser._check_value(key, arg_dict, param_dict)
161161
elif isinstance(param_dict[key], dict):
162162
try:
163-
if not arg_dict or not (key in arg_dict):
163+
if not arg_dict or key not in arg_dict:
164164
checked_dict[key] = self._parse_arguments({}, param_dict[key])[0]
165165
else:
166166
checked_dict[key] = self._parse_arguments(arg_dict[key], param_dict[key])[0]

0 commit comments

Comments
 (0)