Skip to content

Commit

Permalink
Split linting and testing job (#596)
Browse files Browse the repository at this point in the history
Co-authored-by: giovp <giov.pll@gmail.com>
  • Loading branch information
michalk8 and giovp committed Sep 17, 2022
1 parent 2cf664f commit d24dd13
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 32 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint

on:
schedule:
- cron: 00 00 * * 1 # every Monday at 00:00
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: precommit-${{ env.pythonLocation }}-${{ hashFiles('**/.pre-commit-config.yaml') }}

- name: Install dependencies
run: |
sudo apt install pandoc
python -m pip install --upgrade pip
pip install tox
- name: Lint code
run: |
tox -e lint
- name: Lint documentation
run: |
tox -e check-docs
37 changes: 14 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,20 @@ on:
default: release

jobs:
lint:
runs-on: ubuntu-latest
cancel_previous_runs:
if: |
!endsWith(github.event.head_commit.message, '# ci skip') &&
(
startsWith(github.ref, 'refs/heads') ||
startsWith(github.ref, 'refs/tags') ||
github.event.pull_request.draft == false
)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- uses: actions/cache@v2
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.10.0
with:
path: ~/.cache/pre-commit
key: precommit-${{ env.pythonLocation }}-${{ hashFiles('**/.pre-commit-config.yaml') }}

- name: Install dependencies
run: |
sudo apt install pandoc
python -m pip install --upgrade pip
pip install tox
- name: Lint
run: |
tox -e lint,check-docs
access_token: ${{ github.token }}

test:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -121,7 +112,7 @@ jobs:
codecov --no-color --required --flags unittests
regenerate-notebooks:
needs: [lint, test]
needs: test
if: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason == 'release') }}
runs-on: ubuntu-latest
steps:
Expand All @@ -135,7 +126,7 @@ jobs:

release:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.reason == 'release' }}
needs: [lint, test]
needs: test
runs-on: ubuntu-latest
steps:
- name: Invoke deployment workflow
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ repos:
[numpy==1.21.0, scipy, pandas, types-requests]
exclude: .scripts/ci/download_data.py|squidpy/datasets/_(dataset|image).py # See https://github.com/pre-commit/mirrors-mypy/issues/33
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 22.8.0
hooks:
- id: black
additional_dependencies: [toml]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v3.0.0-alpha.0
hooks:
- id: prettier
- repo: https://github.com/timothycrosley/isort
Expand Down Expand Up @@ -68,7 +68,7 @@ repos:
- id: check-toml
- id: requirements-txt-fixer
- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v1.5.3
hooks:
- id: autoflake
args:
Expand Down Expand Up @@ -106,7 +106,7 @@ repos:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
rev: v2.38.0
hooks:
- id: pyupgrade
args: [--py3-plus, --py38-plus, --keep-runtime-typing]
Expand Down
11 changes: 8 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
-r ../requirements.txt
gitpython
ipython
Jinja2<3.1.0 # https://github.com/spatialaudio/nbsphinx/issues/641
ipywidgets>=8.0.0
# Jinja2<3.1.0 # https://github.com/spatialaudio/nbsphinx/issues/641
Jinja2>=3.1.1
nbconvert>=6.4.5
# very slow build
# nbsphinx>=0.8.1,<0.8.7
nbsphinx>=0.8.1,<0.8.7
pyenchant>=3.1.1
requests
sphinx>=4,<4.0.3 # https://github.com/spatialaudio/nbsphinx/issues/584
# sphinx>=4,<4.0.3 # https://github.com/spatialaudio/nbsphinx/issues/584
sphinx>=5.1.1
sphinx-autodoc-annotation
sphinx-autodoc-typehints>=1.10.3
sphinx_gallery>=0.8.2
sphinx_gallery>=0.8.2,<0.11 # https://github.com/spatialaudio/nbsphinx/pull/666
sphinx_rtd_theme
sphinxcontrib-bibtex>=2.2.0
sphinxcontrib-spelling
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ per-file-ignores =
# RST301 Unexpected indentation.
# RST306 Unknown target name:
# RST203 Definition list ends without a blank line; unexpected unindent.
ignore = D100,D107,B008,W503,D105,E203,P101,RST201,RST301,RST306,RST203
ignore = D100,D107,B008,W503,D105,E203,P101,RST201,RST301,RST306,RST203,B024
exclude =
.git
.tox
Expand Down Expand Up @@ -163,7 +163,7 @@ commands =
[testenv:lint]
description = Perform linting.
basepython = python3.9
deps = pre-commit>=2.9.3
deps = pre-commit>=2.20.0
skip_install = true
commands = pre-commit run --all-files --show-diff-on-failure {posargs:}

Expand Down

0 comments on commit d24dd13

Please sign in to comment.