This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
forked from mlflow/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (116 loc) · 4.42 KB
/
test-package-build.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
name: Test package build
on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash --noprofile --norc -exo pipefail {0}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
type: ["full", "skinny"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: "16"
- uses: actions/setup-python@v3
with:
python-version: "3.7"
- name: Set environment variable for skinny client build
if: ${{ matrix.type == 'skinny' }}
run: |
echo "MLFLOW_SKINNY=true" >> $GITHUB_ENV
- name: Build UI
if: ${{ matrix.type == 'full' }}
working-directory: mlflow/server/js
env:
# Prevent warnings (emitted from react-pdf) from being treated as errors
# https://github.com/wojtekmaj/react-pdf/issues/280
CI: false
run: |
yarn install
yarn run build
- name: Install dependencies
run: |
pip install wheel twine
- name: Build distribution files
id: build-dist
run: |
# Build distribution files
python setup.py sdist bdist_wheel
# List distribution files and check their file sizes
ls -lh dist
# Set step outputs
sdist_path=$(find dist -type f -name "*.tar.gz")
wheel_path=$(find dist -type f -name "*.whl")
wheel_name=$(basename $wheel_path)
wheel_size=$(stat -c %s $wheel_path)
echo "::set-output name=sdist-path::${sdist_path}"
echo "::set-output name=wheel-path::${wheel_path}"
echo "::set-output name=wheel-name::${wheel_name}"
echo "::set-output name=wheel-size::${wheel_size}"
- name: Run twine check
run: |
twine check --strict ${{ steps.build-dist.outputs.wheel-path }}
- name: Test installation from tarball
run: |
pip install ${{ steps.build-dist.outputs.sdist-path }}
python -c "import mlflow; print(mlflow.__version__)"
- name: Test installation from wheel
run: |
pip install --force-reinstall ${{ steps.build-dist.outputs.wheel-path }}
python -c "import mlflow; print(mlflow.__version__)"
# Anyone with read access can download the uploaded wheel on GitHub.
- name: Store wheel
uses: actions/upload-artifact@v3
if: github.event_name == 'push'
with:
name: ${{ steps.build-dist.outputs.wheel-name }}
path: ${{ steps.build-dist.outputs.wheel-path }}
- name: Remove old wheels
uses: actions/github-script@v3
if: github.event_name == 'push'
env:
WHEEL_SIZE: ${{ steps.build-dist.outputs.wheel-size }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
// For some reason, the newly-uploaded wheel in the previous step is not included.
const artifactsResp = await github.actions.listArtifactsForRepo({
owner,
repo,
});
const wheels = artifactsResp.data.artifacts.filter(({ name }) => name.endsWith(".whl"));
// The storage usage limit for a free github account is up to 500 MB. See the page below for details:
// https://docs.github.com/en/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions
MAX_SIZE_IN_BYTES = 300_000_000; // 300 MB
let index = 0;
let sum = parseInt(process.env.WHEEL_SIZE); // include the newly-uploaded wheel
for (const [idx, { size_in_bytes }] of wheels.entries()) {
index = idx;
sum += size_in_bytes;
if (sum > MAX_SIZE_IN_BYTES) {
break;
}
}
if (sum <= MAX_SIZE_IN_BYTES) {
return;
}
// Delete old wheels
const promises = wheels.slice(index).map(({ id: artifact_id }) =>
github.actions.deleteArtifact({
owner,
repo,
artifact_id,
})
);
Promise.all(promises).then(data => console.log(data));