-
Notifications
You must be signed in to change notification settings - Fork 13
211 lines (206 loc) · 6.15 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: CI-CD
on:
create:
tags:
- '^v[0-9]+.[0-9]+.[0-9]+(?:.dev[0-9])?$'
workflow_dispatch:
inputs:
py-act:
description: 'Python 3.X for GH Actions'
required: false
default: '3.8'
pip_opts:
description: Install options (pip)
required: false
default: '--upgrade --upgrade-strategy eager'
env:
ACTIONS_SETUP_PY3: ${{ github.event.inputs.py-act || '3.8' }}
PIP_INSTALL_OPTS: ${{ github.event.inputs.pip_opts || '--upgrade --upgrade-strategy eager' }}
PY_COLORS: 1
GHCR: ghcr.io
DOCKER_IMAGE: sbrg/pymodulon
jobs:
test:
runs-on: ${{ matrix.os }}
name: Test code (Python ${{ matrix.py }} - ${{ matrix.os }})
strategy:
max-parallel: 3
fail-fast: true
matrix:
os: [ubuntu-latest]
py: [3.7, 3.8]
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 ${{ env.PIP_INSTALL_OPTS }} pip setuptools tox tox-gh-actions coverage[toml]
sudo apt-get install ncbi-blast+
-
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
docs:
runs-on: ubuntu-latest
name: Check documentation
steps:
-
name: Checkout
id: checkout
uses: actions/checkout@v2
-
name: Set up Python ${{ env.ACTIONS_SETUP_PY3 }}
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 ${{ env.PIP_INSTALL_OPTS }} pip setuptools tox
-
name: Set up pandoc
id: pandoc
uses: r-lib/actions/setup-pandoc@v1
-
name: Run additional checks via tox
id: run-tox
run: |
python -m tox -e "docs, pypi-description"
publish-pypi:
needs: [test, docs]
runs-on: ubuntu-latest
name: Publish package to Python Packaging Index (PyPi)
if: 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 ${{ env.PIP_INSTALL_OPTS }} 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
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.SBRG_MACHINE_PYPI_TOKEN }}
push-to-registries:
needs: [publish-pypi]
name: Build and push Docker images to registries
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
-
name: Checkout
id: checkout
uses: actions/checkout@v2
-
name: Docker meta
id: docker-meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: |
${{ env.DOCKER_IMAGE }}
${{ env.GHCR }}/${{ env.DOCKER_IMAGE }}
tag-sha: true
tag-match: '^v[0-9]+.[0-9]+.[0-9]+(?:.dev[0-9])?$'
# e.g., v{MAJOR}.{MINOR}.{PATCH}(.dev{})
-
name: Set up Docker Buildx
id: docker-buildx-setupx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
id: docker-login
uses: docker/login-action@v1
with:
username: ${{ secrets.SBRG_MACHINE_DOCKERHUB_USERNAME }}
password: ${{ secrets.SBRG_MACHINE_DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
id: ghcr-login
uses: docker/login-action@v1
with:
registry: ${{ env.GHCR }}
username: ${{ secrets.SBRG_MACHINE_GHCR_USERNAME }}
password: ${{ secrets.SBRG_MACHINE_GHCR_TOKEN }}
-
name: Build and push image to registry
id: docker-build-push
uses: docker/build-push-action@v2
with:
file: Dockerfile
push: true
tags: ${{ steps.docker-meta.outputs.tags }}