|
1 | | -# azure-pipelines-template |
2 | | -template for your azure pipelines |
| 1 | +# tox azure-pipeline-template |
3 | 2 |
|
| 3 | +This a template that will help simplify the [Azure Pipelines](https://azure.microsoft.com/en-gb/services/devops/pipelines/) |
| 4 | +configuration when using [tox](https://tox.readthedocs.org) to drive your CI. |
| 5 | + |
| 6 | +# usage |
| 7 | + |
| 8 | +**First configure a github service connection** |
| 9 | + |
| 10 | +It is suggested to use a generic name, such as `github` so forks can also configure the same. |
| 11 | + |
| 12 | +You can find this in `Project Settings` => `Service connections` in the Azure Devops dashboard for your project. |
| 13 | +Project settings is located in the bottom left corner of the UI as of 2019-04-30. Below I'm using the endpoint name |
| 14 | +`github`. |
| 15 | + |
| 16 | +**To load the template, add this to the beginning of the `azure-pipelines.yml`** |
| 17 | + |
| 18 | +```yaml |
| 19 | +resources: |
| 20 | + repositories: |
| 21 | + - repository: tox |
| 22 | + type: github |
| 23 | + endpoint: github |
| 24 | + name: tox-dev/azure-pipelines-template |
| 25 | + ref: refs/tags/0.1 |
| 26 | +``` |
| 27 | +
|
| 28 | +this will make the templates in this repository available in the `tox` namespace. |
| 29 | + |
| 30 | +# job templates |
| 31 | + |
| 32 | +## `run-tox-env.yml` |
| 33 | +This job template will run tox for a given set of tox targets on given platform (new in `0.1`). |
| 34 | +Features and functionality: |
| 35 | + |
| 36 | +- each specified toxenv target maps to a single Azure Pipelines job |
| 37 | +- provision a python for the job |
| 38 | +- install tox into that python |
| 39 | +- provision the target tox environment (create environment, install dependencies) |
| 40 | +- invoke the tox target |
| 41 | +- if a junit file is found under `.tox\junit.{toxenv}.xml` upload it as test report |
| 42 | +- if a coverage file is found under `.tox\coverage.xml` or `.tox\.coverage` upload it as build artifact |
| 43 | + |
| 44 | +### example |
| 45 | + |
| 46 | +The following example will run `py36` and `py37` on Windows, Linux and MacOs. It will also invoke |
| 47 | +`fix_lint` and `docs` target with `python3.7` on Linux. Note how the root level name can be used |
| 48 | +to automatically specify the target platform (defaults to Linux). |
| 49 | + |
| 50 | +```yaml |
| 51 | +jobs: |
| 52 | +- template: run-tox-env.yml@tox |
| 53 | + parameters: |
| 54 | + jobs: |
| 55 | + windows: |
| 56 | + toxenvs: |
| 57 | + - py37 |
| 58 | + - py36 |
| 59 | + linux: |
| 60 | + toxenvs: |
| 61 | + - py37 |
| 62 | + - py36 |
| 63 | + macOs: |
| 64 | + toxenvs: |
| 65 | + - py37 |
| 66 | + - py27 |
| 67 | + check: |
| 68 | + py: '3.7' |
| 69 | + toxenvs: |
| 70 | + - fix_lint |
| 71 | + - docs |
| 72 | +``` |
| 73 | + |
| 74 | + |
| 75 | +### parameters |
| 76 | + |
| 77 | +At root level has a single ``jobs`` key. Inside this you can enlist groups of targets as maps. |
| 78 | +The key is the name of the group. The values configure the target: |
| 79 | + |
| 80 | +- `toxenvs`: the list of `tox` environment names to run; must either: |
| 81 | + - be equal to: `py27`, `py34`, `py35`, `py36`, `py37`, `py38` |
| 82 | + - start with: `py27-`, `py34-`, `py35-`, `py36-`, `py37-`, `py38-` |
| 83 | + |
| 84 | +- `image`: specify the Azure pipelines image to use (determines the OS target); if not specified |
| 85 | + we'll use the groups key name to assign one: |
| 86 | + - `linux` - `Ubuntu-16.04` |
| 87 | + - `windows` - `windows-2019` |
| 88 | + - `osx` - `macOS-latest` |
| 89 | + - otherwise `Ubuntu-16.04` |
| 90 | +- `architecture`: either `x64` or `x86`) with default `x64` (only affects windows) |
| 91 | +- `coverage`: if set after running the test suite tox will run this tox target to generate a coverage report. |
| 92 | + |
| 93 | +Note: for now, `python3.8` is only available on linux -- it is installed from |
| 94 | +[deadsnakes](https://github.com/deadsnakes). |
| 95 | + |
| 96 | +## `merge-coverage.yml` |
| 97 | + |
| 98 | +This job template will download coverage files attached to the build (uploaded by `run-tox-env.yml`) |
| 99 | +and use target tox environment configured to generate a unified report. This then will be uploaded |
| 100 | +to the Azure Pipelines coverage report. |
| 101 | + |
| 102 | +### example |
| 103 | + |
| 104 | +```yaml |
| 105 | +- template: merge-coverage.yml@tox |
| 106 | + parameters: |
| 107 | + coverage: 'coverage' |
| 108 | + dependsOn: |
| 109 | + - windows |
| 110 | + - linux |
| 111 | + - macOs |
| 112 | +``` |
| 113 | + |
| 114 | +### parameters |
| 115 | +- `coverage` - tox target that generates the unified coverage report (default `coverage`) |
| 116 | +- `dependsOn` - environments this job depends on |
| 117 | + |
| 118 | +## `publish-pypi.yml` |
| 119 | + |
| 120 | +This job template will publish the Python package in the current folder (both sdist and wheel) |
| 121 | +via the PEP-517/8 build mechanism and twine. |
| 122 | + |
| 123 | +### example |
| 124 | + |
| 125 | +```yaml |
| 126 | +- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}: |
| 127 | + - template: publish-pypi.yml@tox |
| 128 | + parameters: |
| 129 | + - external_feed: 'toxdev' |
| 130 | + - pypi_remote: 'pypi-toxdev' |
| 131 | + - dependsOn: |
| 132 | + - check |
| 133 | + - report_coverage |
| 134 | +``` |
| 135 | + |
| 136 | +### parameters |
| 137 | +- `external_feed` - the external feed to upload |
| 138 | +- `pypi_remote` - the pypi remote to upload to |
| 139 | +- `dependsOn` - environments this job depends on |
0 commit comments