-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from magmax/ci/add-code-coverage
Add code coverage to Github Actions
- Loading branch information
Showing
34 changed files
with
624 additions
and
189 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pip==21.3.1 | ||
nox==2021.10.1 | ||
nox-poetry==0.9.0 | ||
poetry==1.1.12 | ||
virtualenv==20.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,73 @@ | ||
# This workflow will upload a Python Package using Twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
--- | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
push: | ||
branches: | ||
- main | ||
- master | ||
|
||
jobs: | ||
deploy: | ||
|
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
twine upload dist/* | ||
- name: Check out the repository | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Upgrade pip | ||
run: | | ||
pip install --constraint=.github/workflows/constraints.txt pip | ||
pip --version | ||
- name: Install Poetry | ||
run: | | ||
pip install --constraint=.github/workflows/constraints.txt poetry | ||
poetry --version | ||
- name: Check if there is a parent commit | ||
id: check-parent-commit | ||
run: | | ||
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)" | ||
- name: Detect and tag new version | ||
id: check-version | ||
if: steps.check-parent-commit.outputs.sha | ||
uses: salsify/[email protected] | ||
with: | ||
version-command: | | ||
bash -o pipefail -c "poetry version | awk '{ print \$2 }'" | ||
- name: Bump version for developmental release | ||
if: "! steps.check-version.outputs.tag" | ||
run: | | ||
poetry version patch && | ||
version=$(poetry version | awk '{ print $2 }') && | ||
poetry version $version.dev.$(date +%s) | ||
- name: Build package | ||
run: | | ||
poetry build --ansi | ||
- name: Publish package on PyPI | ||
if: steps.check-version.outputs.tag | ||
uses: pypa/[email protected] | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
- name: Publish the release notes | ||
uses: release-drafter/[email protected] | ||
with: | ||
publish: ${{ steps.check-version.outputs.tag != '' }} | ||
tag: ${{ steps.check-version.outputs.tag }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,137 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
--- | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
|
||
tests: | ||
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ["3.7", "3.8", "3.9", "3.10"] | ||
runs-on: ${{ matrix.platform }} | ||
include: | ||
- { python: "3.10", os: "ubuntu-latest", session: "pre-commit" } | ||
- { python: "3.10", os: "ubuntu-latest", session: "tests" } | ||
- { python: "3.9", os: "ubuntu-latest", session: "tests" } | ||
- { python: "3.8", os: "ubuntu-latest", session: "tests" } | ||
- { python: "3.7", os: "ubuntu-latest", session: "tests" } | ||
- { python: "3.10", os: "windows-latest", session: "tests" } | ||
- { python: "3.10", os: "macos-latest", session: "tests" } | ||
|
||
env: | ||
NOXSESSION: ${{ matrix.session }} | ||
FORCE_COLOR: "1" | ||
PRE_COMMIT_COLOR: "always" | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -r requirements-dev.txt | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest | ||
- name: Check out the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Upgrade pip | ||
run: | | ||
pip install --constraint=.github/workflows/constraints.txt pip | ||
pip --version | ||
- name: Upgrade pip in virtual environments | ||
shell: python | ||
run: | | ||
import os | ||
import pip | ||
with open(os.environ["GITHUB_ENV"], mode="a") as io: | ||
print(f"VIRTUALENV_PIP={pip.__version__}", file=io) | ||
- name: Install Poetry | ||
run: | | ||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry | ||
poetry --version | ||
- name: Install Nox | ||
run: | | ||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox | ||
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry | ||
nox --version | ||
- name: Compute pre-commit cache key | ||
if: matrix.session == 'pre-commit' | ||
id: pre-commit-cache | ||
shell: python | ||
run: | | ||
import hashlib | ||
import sys | ||
python = "py{}.{}".format(*sys.version_info[:2]) | ||
payload = sys.version.encode() + sys.executable.encode() | ||
digest = hashlib.sha256(payload).hexdigest() | ||
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8]) | ||
print("::set-output name=result::{}".format(result)) | ||
- name: Restore pre-commit cache | ||
uses: actions/[email protected] | ||
if: matrix.session == 'pre-commit' | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }} | ||
restore-keys: | | ||
${{ steps.pre-commit-cache.outputs.result }}- | ||
- name: Run Nox | ||
run: | | ||
nox --force-color --python=${{ matrix.python }} | ||
- name: Upload coverage data | ||
if: always() && matrix.session == 'tests' | ||
uses: "actions/[email protected]" | ||
with: | ||
name: coverage-data | ||
path: ".coverage.*" | ||
|
||
coverage: | ||
runs-on: ubuntu-latest | ||
needs: tests | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Upgrade pip | ||
run: | | ||
pip install --constraint=.github/workflows/constraints.txt pip | ||
pip --version | ||
- name: Install Poetry | ||
run: | | ||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry | ||
poetry --version | ||
- name: Install Nox | ||
run: | | ||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox | ||
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry | ||
nox --version | ||
- name: Download coverage data | ||
uses: actions/[email protected] | ||
with: | ||
name: coverage-data | ||
|
||
- name: Combine coverage data and display human readable report | ||
run: | | ||
nox --force-color --session=coverage | ||
- name: Create coverage report | ||
run: | | ||
nox --force-color --session=coverage -- xml | ||
- name: Upload coverage report | ||
uses: codecov/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
*~ | ||
\#* | ||
\.\#* | ||
*.pyc | ||
*.egg-info/ | ||
venv/ | ||
.coverage* | ||
coverage.xml | ||
dist/ | ||
build/ | ||
runtests.py | ||
/.coverage | ||
/.coverage.* | ||
/.nox/ | ||
/dist/ | ||
.cache | ||
*.swp | ||
.ropeproject/ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
comment: false | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: "90" | ||
patch: | ||
default: | ||
target: "90" |
Oops, something went wrong.