Skip to content

Commit 8886efa

Browse files
authored
Add Darken action to check for pep8 violations in diffs (#3954)
* Adds darken+flake8 action to lint PRs
1 parent 526cdd5 commit 8886efa

File tree

2 files changed

+50
-26
lines changed

2 files changed

+50
-26
lines changed

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

.github/workflows/gh-ci.yaml

+48-26
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,13 @@ jobs:
233233
steps:
234234
- uses: actions/checkout@v3
235235

236-
- name: setup_miniconda
237-
uses: conda-incubator/setup-miniconda@v2
236+
- uses: actions/setup-python@v4
238237
with:
239238
python-version: 3.8
240-
auto-update-conda: true
241-
channel-priority: flexible
242-
channels: conda-forge
243-
add-pip-as-python-dependency: true
244-
architecture: x64
245239

246240
- name: install
247241
run: |
248-
which pip
249-
which python
250-
pip install pylint
242+
python -m pip install pylint
251243
252244
- name: pylint
253245
env:
@@ -256,37 +248,67 @@ jobs:
256248
pylint package/MDAnalysis && pylint testsuite/MDAnalysisTests
257249
258250
251+
darker_lint:
252+
if: "github.repository == 'MDAnalysis/mdanalysis'"
253+
runs-on: ubuntu-latest
254+
defaults:
255+
run:
256+
shell: bash
257+
258+
steps:
259+
- uses: actions/checkout@v3
260+
with:
261+
fetch-depth: 0
262+
263+
- uses: actions/setup-python@v4
264+
with:
265+
python-version: 3.8
266+
267+
- name: darker main code
268+
uses: akaihola/[email protected]
269+
with:
270+
version: "@master"
271+
options: "--check --diff --color"
272+
src: "./package/MDAnalysis"
273+
revision: "HEAD^"
274+
lint: "flake8"
275+
276+
- name: darker test code
277+
uses: akaihola/[email protected]
278+
if: success() || failure()
279+
with:
280+
version: "@master"
281+
options: "--check --diff --color"
282+
src: "./testsuite/MDAnalysisTests"
283+
revision: "HEAD^"
284+
lint: "flake8"
285+
286+
259287
pypi_check:
260288
if: "github.repository == 'MDAnalysis/mdanalysis'"
261289
runs-on: ubuntu-latest
290+
defaults:
291+
run:
292+
working-directory: ./package
262293

263294
steps:
264295
- uses: actions/checkout@v3
265296

266-
- name: setup_miniconda
267-
uses: conda-incubator/setup-miniconda@v2
297+
- uses: actions/setup-python@v4
268298
with:
269299
python-version: 3.8
270-
auto-update-conda: true
271-
channel-priority: flexible
272-
channels: conda-forge
273-
add-pip-as-python-dependency: true
274-
# mamba not enabled as install longer than deps install
275-
architecture: x64
276300

277-
- name: install_pip_conda
301+
- name: install_deps
278302
run: |
279-
# Issue 3612 - readme_renderer is outdated on conda-forge
280-
conda install setuptools cython numpy twine
281-
pip install "readme-renderer>=34.0"
303+
python -m pip install twine "readme-renderer>=34.0"
282304
283-
- name: install_mdanalysis
305+
- name: build_sdist
284306
run: |
285-
cd package && python setup.py sdist
307+
pipx run build --sdist
286308
287309
- name: check_package_build
288310
run: |
289-
DISTRIBUTION=$(ls -t1 package/dist/MDAnalysis-*.tar.gz | head -n 1)
290-
test -n "${DISTRIBUTION}" || { echo "no distribution package/dist/MDAnalysis-*.tar.gz found"; exit 1; }
311+
DISTRIBUTION=$(ls -t1 dist/MDAnalysis-*.tar.gz | head -n 1)
312+
test -n "${DISTRIBUTION}" || { echo "no distribution dist/MDAnalysis-*.tar.gz found"; exit 1; }
291313
echo "twine check $DISTRIBUTION"
292314
twine check $DISTRIBUTION

0 commit comments

Comments
 (0)