Azure Pipelines templates for my repos.
Note: for my personal use only. I do not guarantee any stability around here. In other words: please don't use this.
First, add a service connection named github
:
Project settings
> Service connections
> New service connection
> GitHub
Add this at the beginning of azure-pipelines.yml
:
resources:
repositories:
- repository: templates
type: github
endpoint: github
name: florimondmanca/azure-pipelines-templates
ref: refs/tags/6.0
Then reference templates as <template>.yml@templates
.
Expected scripts: make install-python
, make test
.
Parameters:
jobs
- Mapping- Key: a job name. The Python version is inferred from the start, eg
py311_pg
-> Python 3.11. - Value: job configuration. Accepts
os
,services
,variables
,coverage
.
- Key: a job name. The Python version is inferred from the start, eg
before_steps
: a list of steps to run before runningstep--python-test.yml
.
Example:
jobs:
- template: job--python-test.yml@templates
parameters:
jobs:
# Minimal definition:
py311: null
# Complete definition:
py311_dj30_windows_pg:
coverage: true
os: windows
services:
postgres: pg11
variables:
DJANGO_VERSION: "3.0"
Expected scripts: make install-python
, make check
.
Example:
jobs:
- template: job--python-check.yml@templates
parameters:
pythonVersion: "3.11"
Build docs under a Python environment.
Expected scripts: make install-python
, make docs
.
Example:
jobs:
- template: job--python-docs-build.yml@templates
parameters:
pythonVersion: "3.11"
Publish a Python package to PyPI.
make install-python
,make build
,make publish
must exist.twine
andwheel
must be installed.token
refers to a PyPI API token set via a Python upload service connection (Project settings > Service connection > New... > Python package upload). It may be provided through a variable group (Library > Variable group...), as shown below.
This example assumes you want to publish on tags.
trigger:
- master
- refs/tags/*
variables:
# ...
- group: pypi-credentials # Sets $(pypiToken)
stages:
- stage: test
jobs: # ...
- stage: publish
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
jobs:
- template: job--python-publish--tag.yml@templates
parameters:
token: $(pypiToken)
pythonVersion: "3.11"
Setup a Python runtime and a cache for pip dependencies.
Example:
variables:
PIP_CACHE_DIR: $(Pipeline.Workspace)/.cache/pip
steps:
- template: step--python-provision.yml@templates
parameters:
pythonVersion: "3.11"
Expected scripts: make install-python
.
Example:
variables:
PIP_CACHE_DIR: $(Pipeline.Workspace)/.cache/pip
steps:
- template: step--python-install.yml@templates
parameters:
pythonVersion: "3.11"
Expected scripts: make install-python
, make test
.
Example:
steps:
- template: step--python-test.yml@templates
parameters:
pythonVersion: "3.11"
coverage: true # optional
Expected scripts: make install-node
.
Setup a Node.js runtime and a cache for NPM dependencies.
Example:
variables:
NODE_CACHE_FOLDER: $(Build.SourcesDirectory)/node_modules
steps:
- template: step--node-provision.yml@templates
parameters:
nodeVersion: "18.x"
Expected scripts: make install-node
.
Setup a Node.js runtime, a cache for NPM dependencies, and install NPM dependencies.
Example:
variables:
NODE_CACHE_FOLDER: $(Build.SourcesDirectory)/node_modules
steps:
- template: step--node-install.yml@templates
parameters:
nodeVersion: "18.x"