forked from AdamOswald/Huggingface-Space
-
Notifications
You must be signed in to change notification settings - Fork 0
294 lines (272 loc) · 7.3 KB
/
microsoft-action-python.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
- name: Python Actions Collection
uses: microsoft/[email protected]
inputs:
black:
description: |
Run Black
Default is false.
default: true
bandit:
description: |
Run Bandit
Default is false.
default: true
pylint:
description: |
Run Pylint
Default is false.
default: true
pyright:
description: |
Run Pyright
Default is false.
default: true
flake8:
description: |
Run Flake8
Default is false.
default: true
testing:
description: |
Run tests with PyTest
Default is false.
default: true
publish:
description: |
Publish to PyPi
Default is false
default: false
publish_url:
description: |
PyPi Target. Use this to point to private or test locations.
Default https://pypi.org
defualt: 'https://pypi.org'
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
default: 'src'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].'
default: 'github-pr-check'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false]
Default is `false`.
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
toml:
description: |
pyproject.toml location.
Default pyproject.toml
default: 'pyproject.toml'
pylint_rc:
description: '.pylintrc configuration file'
default: '.pylintrc'
name: Pull Request
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Black
uses: dciborow/[email protected]
with:
black: true
- name: Bandit
uses: dciborow/[email protected]
with:
bandit: true
- name: Pylint
uses: dciborow/[email protected]
with:
pylint: true
- name: Pyright
uses: dciborow/[email protected]
with:
pyright: true
- name: Flake8
uses: dciborow/[email protected]
with:
flake8: true
testing:
runs-on: ubuntu-latest
steps:
- name: Pytest
uses: dciborow/[email protected]
with:
testing: true
name: 'Python Actions Collection'
description: 'Run actions for Python Project on pull requests to improve code review experience.'
author: 'dciborow'
inputs:
# Python Project Configuration is expected to be in a pyproject.toml
root:
description: |
Project root directory.
Default '.'
default: '.'
toml:
description: |
pyproject.toml location.
Default pyproject.toml
default: 'pyproject.toml'
# Python Tooling
black:
description: |
Run Black
Default is false.
default: true
bandit:
description: |
Run Bandit
Default is false.
default: true
pylint:
description: |
Run Pylint
Default is false.
default: true
pyright:
description: |
Run Pyright
Default is false.
default: true
flake8:
description: |
Run Flake8
Default is false.
default: true
pytest:
description: |
Run tests with PyTest
Default is false.
default: true
pypi_publish:
description: |
Publish to PyPi
Default is false
default: false
# Advanced Settings
args:
description: |
Customize which tests run with Pytest Markers
default: ''
pypi_repo:
description: |
PyPi Target. Use this to point to private or test locations.
Default testpypi
default: 'pypi'
pypi_password:
description: |
Credentials for PyPi
default: ''
version_suffix:
description: |
Value to append to version in order to produce unique id for PyPi.
Examples include:
'-rc {{ github.run_attempt }}'
'-dev {{ github.run_attempt }}'
default: ''
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
default: 'src'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].'
default: 'github-pr-check'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false]
Default is `false`.
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
runs:
using: "composite"
steps:
- if: ${{ inputs.black == 'true' }}
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "--config ${{ inputs.root }}/${{ inputs.toml }} ${{ inputs.root }}/${{ inputs.workdir }} ${{ inputs.root }}/tests"
- if: steps.action_black.outputs.is_formatted == 'true'
uses: reviewdog/action-suggester@v1
with:
tool_name: blackfmt
fail_on_error: true
- if: ${{ inputs.bandit == 'true' }}
uses: dciborow/[email protected]
with:
workdir: ${{ inputs.root }}
- if: ${{ inputs.flake8 == 'true' }}
uses: reviewdog/action-flake8@v3
with:
github_token: ${{ inputs.github_token }}
workdir: ${{ inputs.root }}/${{ inputs.workdir }}
- if: ${{ inputs.pylint == 'true' }}
uses: dciborow/[email protected]
with:
github_token: ${{ inputs.github_token }}
workdir: ${{ inputs.root }}/${{ inputs.workdir }}
- if: ${{ inputs.pyright == 'true' }}
uses: jakebailey/[email protected]
with:
working-directory: ${{ inputs.root }}
project: ${{ inputs.toml }}
- if: ${{ inputs.pytest == 'true' || inputs.pypi_publish == 'true' }}
uses: actions/setup-python@v1
with:
python-version: '3.7'
- if: ${{ inputs.pytest == 'true' }}
run: |
python -m pip install --upgrade pip
python -m pip install pytest flit
cd "${{ inputs.root }}"
python -m flit install
python -m pytest '${{ inputs.args }}' tests
shell: bash
- if: ${{ inputs.pypi_publish == 'true' }}
run: |
cd "${{ inputs.root }}"
python -m pip install --upgrade pip
python -m pip install flit
sed -i -r 's/[0-9]\.[0-9]\.[0-9]+/&${{ inputs.version_suffix }}/g' src/*/__init__.py
python -m flit publish $repository --repository ${{ inputs.pypi_repo }} --pypirc .pypirc
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ inputs.pypi_password }}
shell: bash
# Ref: https://haya14busa.github.io/github-action-brandings/
branding:
icon: 'check'
color: 'blue'