This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
simple_package.1-multi-target.yml
86 lines (72 loc) · 3.07 KB
/
simple_package.1-multi-target.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# ##########
#
# A build run against multiple Python targets
#
# We still have only 1 stage, but this time we're running parallel jobs for each target Python version
# There are also some notable changes to the `Publish artifacts` task to capture artifacts per configuration
#
# ##########
# These variables still make sense to keep in one place, and are consistent across all jobs in the matrix
variables:
package: simple_package
srcDirectory: src/$(package)
testsDirectory: tests/$(package)
# Trigger only when simple_package or its build has been modified
trigger:
branches:
include:
- "*" # We're only uploading to build artifacts, so it's safe to trigger on all branches
paths:
include:
- .azure-pipelines/simple_package.1-multi-target.yml
- src/simple_package/*
- tests/simple_package/*
# Jobs are collections of related steps
jobs:
# We define one Job to lint and test our package against multiple Python versions in parallel
- job: Build
# We use a strategy pattern to run everything twice - once for 3.6, and once for 3.7
# Each configuration has its own variables used to customize the build - note that `pythonVersion` has moved and now varies per job
# These jobs run in parallel (https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?tabs=yaml&view=azure-devops#multi-configuration)
strategy:
matrix:
python36:
pythonVersion: 3.6
python37:
pythonVersion: 3.7
# Run on a Microsoft-hosted agent running Ubuntu-16.04
# https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops
pool:
vmImage: ubuntu-16.04
# Steps are the specific tasks that execute code and do things
steps:
# Use a specific Python version
- task: UsePythonVersion@0
displayName: Use Python $(pythonVersion)
inputs:
versionSpec: $(pythonVersion)
# Install some tools needed for build (pylint, flake8, etc)
- bash: pip install -r requirements.build.txt -U --upgrade-strategy eager
displayName: Install packages for build
# Lint via pylint. We need to find all .py files under src/simple_package and run pylint to avoid errors
- bash: find $(srcDirectory) $(testsDirectory) -type f -name "*.py" | xargs pylint
displayName: "Linting: pylint"
# Lint via flake8. flake8 has better discovery, so we can invoke it directly
- bash: flake8
displayName: "Linting: flake8"
workingDirectory: $(srcDirectory)
# Run tests
- bash: pytest
displayName: Run tests
workingDirectory: $(testsDirectory)
# Our built source dist & wheel will land in src/simple_package/dist
- bash: python setup.py sdist bdist_wheel
displayName: Build package
workingDirectory: $(srcDirectory)
# Upload everything in src/simple_package/dist (including subfolders) to the build artifacts for later use or debugging
# Add pythonVersion to the artifact name to avoid conflicts and ensure we capture all build output
- task: PublishPipelineArtifact@0
displayName: Publish artifacts
inputs:
artifactName: dist$(pythonVersion)
targetPath: $(srcDirectory)/dist