forked from Azure-Samples/azure-pipelines-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_server.0-consume-artifacts.yml
98 lines (82 loc) · 3.29 KB
/
simple_server.0-consume-artifacts.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
87
88
89
90
91
92
93
94
95
96
97
98
# ##########
#
# Build and test an application that takes a dependency on a package pulled from Azure Artifacts (private PyPI)
#
# We run parallel Jobs to validate our app against multiple Python versions
#
# ##########
# Pipeline-level variables
variables:
app: simple_server
srcDirectory: src/$(app)
testsDirectory: tests/$(app)
artifactFeed: artifacts
# Trigger only when simple_server or its build has been modified
trigger:
branches:
include:
- "*"
paths:
include:
- .azure-pipelines/simple_server.0-consume-artifacts.yml
- src/simple_server/*
- tests/simple_server/*
# Jobs are collections of related steps
jobs:
# We define one Job to lint and test our app 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
# Authenticate to Azure Artifacts
- task: PipAuthenticate@0
displayName: Authenticate with artifact feed
inputs:
artifactFeeds: $(artifactFeed)
# Install the app in editable mode to install dependencies
- bash: pip install -e .
displayName: Install packages for app
workingDirectory: $(srcDirectory)
# 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
# Add the Python version to distinguish between tests on the results page
- bash: pytest --test-run-title="Python $(pythonVersion)"
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