Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 13, 2020
2 parents e7cac6b + b07b273 commit 649dc3c
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
omit = .tox/*

[report]
show_missing = True
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
repos:
- repo: https://github.com/ambv/black
rev: 18.9b0
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black

- repo: https://github.com/asottile/blacken-docs
rev: v1.4.0
hooks:
- id: blacken-docs
14 changes: 2 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@ dist: xenial
language: python

python:
- 2.7
- 3.5
- &latest_py3 3.7

jobs:
fast_finish: true
include:
- stage: deploy
if: tag IS present
python: *latest_py3
before_script: skip
script: tox -e release
- 3.6
- &latest_py3 3.8

cache: pip

Expand Down
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

.. image:: https://img.shields.io/pypi/pyversions/zipp.svg

.. image:: https://dev.azure.com/jaraco/zipp/_apis/build/status/jaraco.zipp?branchName=master
:target: https://dev.azure.com/jaraco/zipp/_build/latest?definitionId=1&branchName=master

.. image:: https://img.shields.io/travis/jaraco/zipp/master.svg
:target: https://travis-ci.org/jaraco/zipp

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
:target: https://github.com/psf/black
:alt: Code style: Black

.. image:: https://img.shields.io/appveyor/ci/jaraco/zipp/master.svg
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ environment:

matrix:
- PYTHON: "C:\\Python36-x64"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python38-x64"

install:
# symlink python from a directory with a space
Expand Down
71 changes: 71 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Create the project in Azure with:
# az devops project create --name $name --organization https://dev.azure.com/$org/ --visibility public
# then configure the pipelines (through web UI)

trigger:
branches:
include:
- '*'
tags:
include:
- '*'

pool:
vmimage: 'Ubuntu-18.04'

variables:
- group: Azure secrets

stages:
- stage: Test
jobs:

- job: 'Test'
strategy:
matrix:
Python36:
python.version: '3.6'
Python38:
python.version: '3.8'
maxParallel: 4

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'

- script: python -m pip install tox
displayName: 'Install tox'

- script: |
tox -- --junit-xml=test-results.xml
displayName: 'run tests'
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'Python $(python.version)'
condition: succeededOrFailed()

- stage: Publish
dependsOn: Test
jobs:
- job: 'Publish'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
architecture: 'x64'

- script: python -m pip install tox
displayName: 'Install tox'

- script: |
tox -e release
env:
TWINE_PASSWORD: $(PyPI-token)
displayName: 'publish to PyPI'
condition: contains(variables['Build.SourceBranch'], 'tags')
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3

[options]
py_modules = zipp
packages = find:
include_package_data = true
python_requires = >=2.7
python_requires = >=3.6
install_requires =
more_itertools
setup_requires = setuptools_scm >= 1.15.0
Expand Down
38 changes: 31 additions & 7 deletions skeleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The skeleton assumes the developer has [tox](https://pypi.org/project/tox) insta

Other environments (invoked with `tox -e {name}`) supplied include:

- a `build-docs` environment to build the documentation
- a `docs` environment to build the documentation
- a `release` environment to publish the package to PyPI

A pytest.ini is included to define common options around running tests. In particular:
Expand All @@ -103,26 +103,50 @@ Relies a .flake8 file to correct some default behaviors:

## Continuous Integration

The project is pre-configured to run tests in [Travis-CI](https://travis-ci.org) (.travis.yml). Any new project must be enabled either through their web site or with the `travis enable` command.
The project is pre-configured to run tests through multiple CI providers.

### Azure Pipelines

[Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) are the preferred provider as they provide free, fast, multi-platform services. See azure-pipelines.yml for more details.

Features include:

- test against multiple Python versions
- run on Ubuntu Bionic

### Travis CI

[Travis-CI](https://travis-ci.org) is configured through .travis.yml. Any new project must be enabled either through their web site or with the `travis enable` command.

Features include:
- test against Python 2 and 3
- test against 3
- run on Ubuntu Xenial
- correct for broken IPv6

Also provided is a minimal template for running under Appveyor (Windows).
### Appveyor

A minimal template for running under Appveyor (Windows) is provided.

### Continuous Deployments

In addition to running tests, an additional deploy stage is configured to automatically release tagged commits to PyPI using [API tokens](https://pypi.org/help/#apitoken). The release process expects an authorized token to be configured with Travis as the TWINE_PASSWORD environment variable. After the Travis project is created, configure the token through the web UI or with a command like the following (bash syntax):
In addition to running tests, an additional deploy stage is configured to automatically release tagged commits to PyPI using [API tokens](https://pypi.org/help/#apitoken). The release process expects an authorized token to be configured with Azure as the `Azure secrets` variable group. This variable group needs to be created only once per organization. For example:

```
TWINE_PASSWORD={token} travis env copy TWINE_PASSWORD
# create a resource group if none exists
az group create --name main --location eastus2
# create the vault (try different names until something works)
az keyvault create --name secrets007 --resource-group main
# create the secret
az keyvault secret set --vault-name secrets007 --name PyPI-token --value $token
```

Then, in the web UI for the project's Pipelines Library, create the `Azure secrets` variable group referencing the key vault name.

For more details, see [this blog entry](https://blog.jaraco.com/configuring-azure-pipelines-with-secets/).

## Building Documentation

Documentation is automatically built by [Read the Docs](https://readthedocs.org) when the project is registered with it, by way of the .readthedocs.yml file. To test the docs build manually, a tox env may be invoked as `tox -e build-docs`. Both techniques rely on the dependencies declared in `setup.cfg/options.extras_require.docs`.
Documentation is automatically built by [Read the Docs](https://readthedocs.org) when the project is registered with it, by way of the .readthedocs.yml file. To test the docs build manually, a tox env may be invoked as `tox -e docs`. Both techniques rely on the dependencies declared in `setup.cfg/options.extras_require.docs`.

In addition to building the sphinx docs scaffolded in `docs/`, the docs build a `history.html` file that first injects release dates and hyperlinks into the CHANGES.rst before incorporating it as history in the docs.

Expand Down
18 changes: 12 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@ envlist = python
minversion = 3.2
# https://github.com/jaraco/skeleton/issues/6
tox_pip_extensions_ext_venv_update = true
# Ensure that a late version of pip is used even on tox-venv.
requires =
tox-pip-version>=0.0.6
tox-venv


[testenv]
deps =
setuptools>=31.0.1
pip_version = pip
commands =
python -m unittest discover
usedevelop = True
extras = testing

[testenv:build-docs]
[testenv:docs]
extras =
docs
testing
docs
testing
changedir = docs
commands =
python -m sphinx . {toxinidir}/build/html
python -m sphinx . {toxinidir}/build/html

[testenv:release]
skip_install = True
deps =
pep517>=0.5
twine>=1.13
path.py
twine[keyring]>=1.13
path
passenv =
TWINE_PASSWORD
setenv =
Expand Down

0 comments on commit 649dc3c

Please sign in to comment.