generated from dciborow/action-pylint
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
174 lines (161 loc) · 4.75 KB
/
action.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
name: 'Run Actions based for Python Project'
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: false
bandit:
description: |
Run Bandit
Default is false.
default: false
pylint:
description: |
Run Pylint
Default is false.
default: false
pyright:
description: |
Run Pyright
Default is false.
default: false
flake8:
description: |
Run Flake8
Default is false.
default: false
pytest:
description: |
Run tests with PyTest
Default is false.
default: false
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/action-bandit@0.0.2
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/action-pylint@0.0.4
with:
github_token: ${{ inputs.github_token }}
workdir: ${{ inputs.root }}/${{ inputs.workdir }}
- if: ${{ inputs.pytest == 'true' || inputs.pypi_publish == 'true' || inputs.pyright == 'true'}}
uses: actions/setup-python@v1
with:
python-version: '3.7'
- if: ${{ inputs.pytest == 'true' || inputs.pyright == 'true'}}
run: |
python -m pip install --upgrade pip
python -m pip install pytest flit
cd "${{ inputs.root }}"
python -m flit install
shell: bash
- if: ${{ inputs.pyright == 'true' }}
uses: jakebailey/pyright-action@v1.1.0
with:
working-directory: ${{ inputs.root }}
project: ${{ inputs.toml }}
- if: ${{ inputs.pytest == 'true' }}
run: |
python -m pip install pytest
cd "${{ inputs.root }}"
python -m pytest '${{ inputs.args }}' tests
shell: bash
- if: ${{ inputs.pypi_publish == 'true' }}
run: |
python -m pip install flit
cd "${{ inputs.root }}"
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'