Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "3.7"
displayName: Use Python 3.7

- template: install-dependencies.yml

- script: python -m pip install pipenv --upgrade
displayName: Install Pipenv

- script: pipenv install --dev
displayName: Create Development Environment

- script: |
pipenv run inv clean
pipenv run inv build
displayName: Build Package

- script: |
pipenv run pip install twine readme-renderer[md]
pipenv run twine check dist/*
displayName: check package build

- task: CopyFiles@2
inputs:
sourceFolder: dist/
contents: "**"
targetFolder: $(Build.ArtifactStagingDirectory)
displayName: Copy Artifacts

- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: PackageArtifacts
displayName: Publish Artifacts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- script: |
python -m pip install --upgrade pip setuptools wheel pipenv && pipenv install --dev
displayName: Install Dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
steps:
- script: pipenv run pip install codacy-coverage codecov
displayName: 'Install Coverage Reporters'

- script: |
pipenv run coverage combine
pipenv run coverage xml -o coverage/coverage.xml
pipenv run coverage html -d coverage
displayName: 'Build Coverage Report'
- script: |
pipenv run python-codacy-coverage -r coverage/coverage.xml
pipenv run codecov --file coverage/coverage.xml
env:
CODACY_PROJECT_TOKEN: $(CODACY_PROJECT_TOKEN)
CODECOV_TOKEN: $(CODECOV_TOKEN)
displayName: 'Send Coverage Report'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage from coverage.xml'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage'
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: $(python.version)
displayName: Use Python $(python.version)

- template: install-dependencies.yml

- script: pipenv install --dev
displayName: Install Package

- script: pipenv run coverage run --parallel -m pytest -ra --junitxml=junit/test-results.xml tests/
displayName: 'Run Pytest'

- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: '$(Agent.OS) - $(Build.DefinitionName) - Python $(python.version)'
condition: succeededOrFailed()
displayName: 'Publish Test Results'
4 changes: 4 additions & 0 deletions {{cookiecutter.repo_name}}/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[run]
branch = True
dynamic_context = test_function
parallel = True
source = src/{{ cookiecutter.package_name }}/

[report]
# Regexes for lines to exclude from consideration
precision = 2
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
Expand All @@ -18,6 +20,8 @@ exclude_lines =
raise NotImplementedError
# Don't complain if non-runnable code isn't run:
if 0:
if False:
if MYPY_RUNNING:
if __name__ == .__main__.:

[html]
Expand Down
111 changes: 111 additions & 0 deletions {{cookiecutter.repo_name}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: {{ cookiecutter.package_name }} CI

on:
push:
paths-ignore:
- 'docs/**'
- 'news/**'
- '*.ini'
- '*.md'
- '**/*.txt'
- '*.rst'
- '.gitignore'
- '.gitmodules'
- '.gitattributes'
- '.editorconfig'
branches:
- master
pull_request:
paths-ignore:
- 'docs/**'
- 'news/**'
- '*.ini'
- '*.md'
- '**/*.txt'
- '*.rst'
- '.gitignore'
- '.gitmodules'
- '.gitattributes'
- '.editorconfig'

jobs:
test:
name: $\{\{matrix.os\}\} / $\{\{ matrix.python-version \}\}
runs-on: $\{\{ matrix.os \}\}-latest
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
os: [MacOS, Ubuntu, Windows]

steps:
- uses: actions/checkout@v1

- name: Set up Python $\{\{ matrix.python-version \}\}
uses: actions/setup-python@v1
with:
python-version: $\{\{ matrix.python-version \}\}

- name: Get python path
id: python-path
run: |
echo ::set-output name=path::$(python -c "import sys; print(sys.executable)")

- name: Install latest pip, setuptools, wheel
run: |
python -m pip install --upgrade coveralls pip setuptools wheel --upgrade-strategy=eager
python -m pip install --upgrade --pre pipenv

- name: Run tests
env:
PIPENV_DEFAULT_PYTHON_VERSION: $\{\{ matrix.python-version \}\}
PYTHONWARNINGS: ignore:DEPRECATION
COVERALLS_REPO_TOKEN: $\{\{ secrets.GITHUB_TOKEN \}\}
COVERALLS_GIT_COMMIT: $\{\{ github.sha \}\}
COVERALLS_GIT_BRANCH: $\{\{ github.ref \}\}
COVERALLS_FLAG_NAME: $\{\{ matrix.os }}-$\{\{ matrix.python-version \}\}
COVERALLS_SERVICE_NAME: github
COVERALLS_SERVICE_JOB_ID: $\{\{ github.run_id \}\}
COVERALLS_PARALLEL: true
PIPENV_NOSPIN: '1'
CI: '1'
run: |
git submodule sync
git submodule update --init --recursive
python -m pipenv install --dev --python=$\{\{ steps.python-path.outputs.path \}\}
pipenv run coverage run -p -m pytest -ra tests/
pipenv run coverage combine
coveralls

coveralls-complete:
needs: test
runs-on: ubuntu-latest
env:
COVERALLS_REPO_TOKEN: $\{\{ secrets.GITHUB_TOKEN \}\}
COVERALLS_GIT_COMMIT: $\{\{ github.sha \}\}
COVERALLS_GIT_BRANCH: $\{\{ github.ref \}\}
COVERALLS_SERVICE_NAME: github
steps:
- name: install requests
run: |
pip install --upgrade --upgrade-strategy=eager requests
- name: Coveralls Finished
run: |
import os
import requests
url = "https://coveralls.io/webhook"
pr_number = None
service_number = os.environ['COVERALLS_GIT_COMMIT']
git_branch = os.environ.get('COVERALLS_GIT_BRANCH', '')
if git_branch.startswith('refs/pull/'):
pr_number = git_branch.split('/')[2]
service_number = '{}-PR-{}'.format(service_number, pr_number)
payload = {
"repo_token": os.environ['COVERALLS_REPO_TOKEN'],
"repo_name": os.environ['GITHUB_REPOSITORY'],
"payload": {"build_num": service_number, "status": "done"}
}
response = requests.post(url, json=payload)
response.raise_for_status()
assert response.json() == {"done": True}, response.json()
shell: python
63 changes: 63 additions & 0 deletions {{cookiecutter.repo_name}}/.github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# name: Create Release & Upload To PyPI

# on:
# push:
# # Sequence of patterns matched against refs/tags
# tags:
# - v?[0-9]+.[0-9]+.[0-9]+ # add .* to allow dev releases

# jobs:
# build:
# name: {{ cookiecutter.package_name }} PyPI Upload
# runs-on: ubuntu-latest
# env:
# CI: "1"

# steps:
# - name: Checkout code
# uses: actions/checkout@v2

# - uses: webfactory/ssh-agent@v0.1.1
# with:
# ssh-private-key: $\{\{ secrets.SSH_PRIVATE_KEY \}\}

# - name: Create Release
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: $\{\{ secrets.GITHUB_TOKEN \}\}
# with:
# tag_name: $\{\{ github.ref \}\}
# release_name: Release $\{\{ github.ref \}\}
# draft: false
# prerelease: false

# - name: Set up Python 3.7
# uses: actions/setup-python@v1
# with:
# python-version: 3.7

# - name: Install latest tools for build
# run: |
# python -m pip install --upgrade pip setuptools wheel pipenv invoke
# python -m pipenv install --dev --pre
# python -m pipenv run pip install invoke
# - name: Build wheels
# run: |
# python -m pipenv run inv build
# # to upload to test pypi, pass repository_url: https://test.pypi.org/legacy/ and use secrets.TEST_PYPI_TOKEN
# - name: Publish a Python distribution to PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# user: __token__
# password: $\{\{ secrets.PYPI_TOKEN \}\}
# packages_dir: dist/
# # git push https://$\{\{ github.actor \}\}:$\{\{ secrets.GITHUB_TOKEN \}\}@github.com/$\{\{ github.repository \}\}.git HEAD:master
# # we need to use a deploy key for this to get around branch protection as the default token fails
# - name: Pre-bump
# run: |
# git config --local user.name 'Github Action'
# git config --local user.email action@github.com
# python -m pipenv run inv bump-version -t dev
# git commit -am 'pre-bump'
# git push git@github.com:$\{\{ github.repository \}\}.git HEAD:master
7 changes: 7 additions & 0 deletions {{cookiecutter.repo_name}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ venv.bak/

# Rope project settings
.ropeproject
.vim

# mkdocs documentation
/site

# mypy
.mypy_cache/
.typeshed
.pyre
.pytype

.vscode/

pip-wheel-metadata
32 changes: 32 additions & 0 deletions {{cookiecutter.repo_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3.6

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1 # pick a git hash / tag to point to
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/asottile/seed-isort-config
rev: v2.1.1
hooks:
- id: seed-isort-config

- repo: https://github.com/timothycrosley/isort
rev: v4.3.21
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v2.4.1
hooks:
- id: pyupgrade

- repo: https://github.com/myint/docformatter
rev: v1.3.1
hooks:
- id: docformatter
37 changes: 0 additions & 37 deletions {{cookiecutter.repo_name}}/.travis.yml

This file was deleted.

13 changes: 6 additions & 7 deletions {{cookiecutter.repo_name}}/Pipfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
{{ cookiecutter.package_name }} = { path = '.', editable = true }
{{ cookiecutter.package_name }} = { path = ".", editable = true, extras = ["lint", "release", "dev", "tests"] }

[dev-packages]
invoke = '*'
parver = '*'
towncrier = '*'
wheel = '*'
pytest = '*'
pytest-xdist = '*'
pytest-cov = '*'
sphinx = '*'
sphinx-rtd-theme = '*'

Expand Down
Loading