-
Notifications
You must be signed in to change notification settings - Fork 6
149 lines (137 loc) · 4.6 KB
/
python-package.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches:
tags:
# pull_request:
# branches: [ main ]
release:
types: [ published ] #, created, edited
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
project: ['target-s3-jsonl']
os: [ubuntu-latest] #, macos-latest, windows-latest
python-version: [3.9, '3.10', 3.11]
exclude:
- os: macos-latest
python-version: 3.9
- os: macos-latest
python-version: 3.10
- os: windows-latest
python-version: 3.9
- os: windows-latest
python-version: 3.10
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip Linux
uses: actions/cache@v3
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache pip macOS
uses: actions/cache@v3
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache pip Windows
uses: actions/cache@v3
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m venv venv || virtualenv venv
. venv/bin/activate
pip install --upgrade pip # setuptools
# pip install .[test,lint,static,dist]
pip install tox
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
# - name: Lint with flake8
# run: |
# . venv/bin/activate
# # stop the build if there are Python syntax errors or undefined names
# # exit-zero treats all errors as warnings. The GitHub editor is 255 chars wide
# flake8
# - name: Static typing with mypy
# run: |
# . venv/bin/activate
# mypy
- name: Lint with flake8 & Static typing with mypy
run: |
. venv/bin/activate
TOX_PARALLEL_NO_SPINNER=1 tox --parallel -e lint,static
- name: pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Test
run: |
. venv/bin/activate
# pytest
# tox --parallel
tox -e py
- name: Upload coverage test results to Codecov
uses: codecov/codecov-action@v2
if: |
${{ matrix.python-version }} == '3.9' \
&& ${{ matrix.os-version }} == 'ubuntu-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: coverage.xml # optional
flags: unittests # optional
name: codecov-${{ matrix.project }} # optional
env_vars: OS,PYTHON
fail_ci_if_error: true # optional (default = false)
verbose: false # optional (default = false)
- name: Build distribution package
run: |
. venv/bin/activate
# python setup.py sdist bdist_wheel
pip install build
python -m build
ls -l dist
- name: Publish distribution package to TestPyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
verify_metadata: true
skip_existing: true
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
verify_metadata: true
skip_existing: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Uninstall Dependencies
run: |
. venv/bin/activate
if [ -f requirements.txt ]; then pip uninstall -y -r requirements.txt; fi