forked from mlflow/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (161 loc) · 6.5 KB
/
cross-version-tests.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
name: Cross version tests
on:
workflow_dispatch:
inputs:
repository:
description: >
[Optional] Repository name with owner. For example, mlflow/mlflow.
Defaults to the repository that triggered a workflow.
required: false
default: ""
ref:
description: >
[Optional] The branch, tag or SHA to checkout. When checking out the repository that
triggered a workflow, this defaults to the reference or SHA for that event. Otherwise,
uses the default branch.
required: false
default: ""
flavors:
description: "[Optional] Comma-separated string specifying which flavors to test (e.g. 'sklearn, xgboost'). If unspecified, all flavors are tested."
required: false
default: ""
versions:
description: "[Optional] Comma-separated string specifying which versions to test (e.g. '1.2.3, 4.5.6'). If unspecified, all versions are tested."
required: false
default: ""
schedule:
# Run this workflow daily at 7:00 UTC
- cron: "0 7 * * *"
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
shell: bash --noprofile --norc -exo pipefail {0}
jobs:
set-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
is_matrix_empty: ${{ steps.set-matrix.outputs.is_matrix_empty }}
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.repository }}
ref: ${{ github.event.inputs.ref }}
- uses: actions/setup-python@v2
with:
python-version: "3.6"
- name: Install dependencies
run: |
pip install packaging requests pyyaml pytest
- name: Check labels
uses: actions/github-script@v4
id: enable-dev-tests
if: ${{ github.event_name == 'pull_request' }}
with:
result-encoding: string
script: |
const labels = await github.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
return labels.data.some(({ name }) => name === "enable-dev-tests");
- name: Test set_matrix.py
run: |
python -m pytest --noconftest tests/dev/test_set_matrix.py --doctest-modules dev/set_matrix.py
- id: set-matrix
name: Set matrix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EVENT_NAME="${{ github.event_name }}"
if [ "$EVENT_NAME" = "pull_request" ]; then
REPO="${{ github.repository }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
REF_VERSIONS_YAML="https://raw.githubusercontent.com/$REPO/master/mlflow/ml-package-versions.yml"
CHANGED_FILES="$(python dev/list_changed_files.py --repository $REPO --pr-num $PR_NUMBER)"
ENABLE_DEV_TESTS="${{ steps.enable-dev-tests.outputs.result }}"
EXCLUDE_DEV_VERSIONS_FLAG=$([ "$ENABLE_DEV_TESTS" == "true" ] && echo "" || echo "--exclude-dev-versions")
python dev/set_matrix.py --ref-versions-yaml "$REF_VERSIONS_YAML" --changed-files "$CHANGED_FILES" $EXCLUDE_DEV_VERSIONS_FLAG
elif [ "$EVENT_NAME" = "workflow_dispatch" ]; then
python dev/set_matrix.py --flavors "${{ github.event.inputs.flavors }}" --versions "${{ github.event.inputs.versions }}"
else
python dev/set_matrix.py
fi
test:
needs: set-matrix
if: ${{ needs.set-matrix.outputs.is_matrix_empty == 'false' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.repository }}
ref: ${{ github.event.inputs.ref }}
- uses: actions/setup-java@v2
with:
# GitHub Actions' Ubuntu 20.04 image uses Java 11 (which is incompatible with Spark 2.4.x) by default:
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#java
java-version: 8
distribution: "adopt"
- name: Get python version
id: get-python-version
run: |
if [[ "${{ matrix.version }}" = "dev" ]] || \
[[ "${{ matrix.package }}" = "scikit-learn" && ! "${{ matrix.version }}" =~ ^0\.* ]] || \
[[ "${{ matrix.package }}" = "statsmodels" ]] || \
[[ "${{ matrix.package }}" = "tensorflow" && ! "${{ matrix.version }}" =~ ^2\.[0-6] ]] || \
[[ "${{ matrix.package }}" = "keras" && ! "${{ matrix.version }}" =~ ^2\.[0-6] ]]
then
python_version=3.7
else
python_version=3.6
fi
echo "::set-output name=version::$python_version"
- uses: ./.github/actions/setup-python
with:
python-version: ${{ steps.get-python-version.outputs.version }}
- name: Get cache key
env:
INSTALL_COMMAND: ${{ matrix.install }}
id: get-cache-key
run: |
date=$(date -u "+%Y%m%d")
hash=$(echo -n "$INSTALL_COMMAND" | sha256sum)
echo "::set-output name=key::$ImageOS-$ImageVersion-wheels-$date-$hash"
- uses: actions/cache@v2
# We only cache wheels that take long (> 10 min) to build
if: ${{ contains('pyspark, catboost, scikit-learn', matrix.package) && matrix.version == 'dev' }}
with:
path: /home/runner/.cache/wheels
key: ${{ steps.get-cache-key.outputs.key }}
restore-keys: |
${{ steps.get-cache-key.outputs.key }}
- name: Install mlflow & test dependencies
run: |
python --version
pip install --upgrade pip wheel
pip install -e .
pip install -r requirements/small-requirements.txt
- name: Install ${{ matrix.package }} ${{ matrix.version }}
env:
CACHE_DIR: /home/runner/.cache/wheels
run: |
${{ matrix.install }}
- name: Check package versions
run: |
python dev/show_package_release_dates.py
- name: Run tests
env:
MLFLOW_CONDA_HOME: /usr/share/miniconda
SPARK_LOCAL_IP: 127.0.0.1
PACKAGE_VERSION: ${{ matrix.version }}
run: |
${{ matrix.run }}