generated from SBRG/MASS-project
-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (136 loc) · 3.77 KB
/
main.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
name: CI-CD
on:
push:
branches:
- main
- devel
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
- devel
workflow_dispatch:
env:
ACTIONS_SETUP_PY3: '3.9'
PY_COLORS: 1
jobs:
lint:
runs-on: ubuntu-latest
name: Lint using pre-commit hooks
steps:
-
name: Checkout repository
id: checkout
uses: actions/checkout@v2
-
name: Set up Python
id: setup
uses: actions/setup-python@v2
with:
python-version: ${{ env.ACTIONS_SETUP_PY3 }}
-
name: Run pre-commit
id: pre-commit
uses: pre-commit/[email protected]
test:
needs: lint
runs-on: ${{ matrix.os }}
name: Test code (Python ${{ matrix.py }} - ${{ matrix.os }})
strategy:
max-parallel: 4
fail-fast: false
matrix:
os: [ubuntu-latest]
py: [3.9]
steps:
-
name: Checkout repository
id: checkout
uses: actions/checkout@v2
-
name: Set up Python ${{ matrix.py }}
id: setup
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
-
name: Set Python ${{ matrix.py }} cache
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pydeps-${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}
-
name : Install dependencies
id: install-deps
run: |
python -m pip install --upgrade pip setuptools tox tox-gh-actions coverage[toml]
-
name: Run tests via tox
id: run-tox
run: |
python -m tox
-
name: Generate an XML report of coverage results
id: cov-report-xml
run: |
python -m coverage xml
-
name: Upload coverage report to Codecov.io
id: codecov-upload
uses: codecov/codecov-action@v1
with:
name: "py${{ matrix.py }}-${{ matrix.os }}"
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
publish-pypi:
needs: [test]
runs-on: ubuntu-latest
name: Publish package to Python Packaging Index (PyPi)
if: endsWith(github.ref, github.event.repository.default_branch) || ( github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') )
steps:
-
name: Checkout
id: checkout
uses: actions/checkout@v2
-
name: Set up Python
id: setup
uses: actions/setup-python@v2
with:
python-version: ${{ env.ACTIONS_SETUP_PY3 }}
-
name: Set Python ${{ env.ACTIONS_SETUP_PY3 }} cache
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pydeps-${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}
-
name : Install dependencies
id: install-deps
run: |
python -m pip install --upgrade pip setuptools wheel build
-
name: Build package
id: build
run: |
python -m build -s -w .
-
name: Publish package to Test PyPI
id: test-publish
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.SBRG_MACHINE_PYPI_TEST_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
-
name: Publish package to PyPI
id: publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.SBRG_MACHINE_PYPI_TOKEN }}