-
Notifications
You must be signed in to change notification settings - Fork 17
103 lines (93 loc) · 2.75 KB
/
pythonpackage.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
name: Python package
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: build
run: pip install .
- name: mypy check
run: |
mypy
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 ./src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest and check coverage
run: |
pytest --cov=estimators
build_wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install twine
- name: Build universal wheel
run: pip wheel . --no-deps --wheel-dir ./dist
- uses: actions/upload-artifact@v3
with:
path: dist/*.whl
- name: Check wheels
run: twine check dist/*
- name: Test wheel
run: |
pip install --find-links dist/ vw-estimators
pytest
deploy_test:
name: "Upload if tag (test)"
environment: "Test-PyPi"
needs: [build_wheel, build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/[email protected]
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
deploy_prod:
name: "Upload if tag (prod)"
environment: "Prod-PyPi"
needs: [deploy_test]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/[email protected]
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}