Skip to content

Commit

Permalink
feat: speed up imports (#130)
Browse files Browse the repository at this point in the history
* ci: run mypy in tox through pre-commit
* ci: update pip constraints and pre-commit config
* ci: update CD workflow
* style: sort tox jobs

Co-authored-by: GitHub <noreply@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 6, 2021
1 parent 579eb55 commit 9a23a1c
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 111 deletions.
13 changes: 6 additions & 7 deletions .constraints/py3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ babel==2.9.1
backcall==0.2.0
backports.entry-points-selectable==1.1.1
beautifulsoup4==4.10.0
black==21.11b1
black==21.12b0
bleach==4.1.0
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
charset-normalizer==2.0.8
charset-normalizer==2.0.9
click==7.1.2
colorama==0.4.4
coverage==6.2
Expand Down Expand Up @@ -56,7 +56,7 @@ imagesize==1.3.0
importlib-metadata==4.8.2
iniconfig==1.1.1
ipykernel==6.6.0
ipython==7.30.0
ipython==7.30.1
ipython-genutils==0.2.0
ipywidgets==7.6.5
isort==5.10.1
Expand Down Expand Up @@ -95,7 +95,7 @@ nbclient==0.5.9
nbconvert==6.3.0
nbdime==3.1.1
nbformat==5.1.3
nbmake==1.0
nbmake==1.1
nest-asyncio==1.5.4
nodeenv==1.6.0
notebook==6.4.6
Expand Down Expand Up @@ -126,7 +126,7 @@ pydocstyle==6.1.1
pydot==1.4.2
pyflakes==2.4.0
pygments==2.10.0
pylint==2.12.1
pylint==2.12.2
pyparsing==3.0.6
pyrsistent==0.18.0
pytest==6.2.5
Expand All @@ -140,8 +140,7 @@ pytz==2021.3
pyyaml==6.0
pyzmq==22.3.0
qtconsole==5.2.1
qtpy==1.11.2
regex==2021.11.10
qtpy==1.11.3
requests==2.26.0
restructuredtext-lint==1.3.2
send2trash==1.8.0
Expand Down
11 changes: 5 additions & 6 deletions .constraints/py3.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ babel==2.9.1
backcall==0.2.0
backports.entry-points-selectable==1.1.1
beautifulsoup4==4.10.0
black==21.11b1
black==21.12b0
bleach==4.1.0
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
charset-normalizer==2.0.8
charset-normalizer==2.0.9
click==7.1.2
colorama==0.4.4
contextvars==2.4
Expand Down Expand Up @@ -97,7 +97,7 @@ nbclient==0.5.9
nbconvert==6.0.7
nbdime==3.1.1
nbformat==5.1.3
nbmake==1.0
nbmake==1.1
nest-asyncio==1.5.4
nodeenv==1.6.0
notebook==6.4.6
Expand Down Expand Up @@ -128,7 +128,7 @@ pydocstyle==6.1.1
pydot==1.4.2
pyflakes==2.4.0
pygments==2.10.0
pylint==2.12.1
pylint==2.12.2
pyparsing==3.0.6
pyrsistent==0.18.0
pytest==6.2.5
Expand All @@ -142,8 +142,7 @@ pytz==2021.3
pyyaml==6.0
pyzmq==22.3.0
qtconsole==5.2.1
qtpy==1.11.2
regex==2021.11.10
qtpy==1.11.3
requests==2.26.0
restructuredtext-lint==1.3.2
send2trash==1.8.0
Expand Down
13 changes: 6 additions & 7 deletions .constraints/py3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ babel==2.9.1
backcall==0.2.0
backports.entry-points-selectable==1.1.1
beautifulsoup4==4.10.0
black==21.11b1
black==21.12b0
bleach==4.1.0
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
charset-normalizer==2.0.8
charset-normalizer==2.0.9
click==7.1.2
colorama==0.4.4
coverage==6.2
Expand Down Expand Up @@ -57,7 +57,7 @@ importlib-metadata==4.2.0
importlib-resources==5.4.0
iniconfig==1.1.1
ipykernel==6.6.0
ipython==7.30.0
ipython==7.30.1
ipython-genutils==0.2.0
ipywidgets==7.6.5
isort==5.10.1
Expand Down Expand Up @@ -96,7 +96,7 @@ nbclient==0.5.9
nbconvert==6.3.0
nbdime==3.1.1
nbformat==5.1.3
nbmake==1.0
nbmake==1.1
nest-asyncio==1.5.4
nodeenv==1.6.0
notebook==6.4.6
Expand Down Expand Up @@ -127,7 +127,7 @@ pydocstyle==6.1.1
pydot==1.4.2
pyflakes==2.4.0
pygments==2.10.0
pylint==2.12.1
pylint==2.12.2
pyparsing==3.0.6
pyrsistent==0.18.0
pytest==6.2.5
Expand All @@ -141,8 +141,7 @@ pytz==2021.3
pyyaml==6.0
pyzmq==22.3.0
qtconsole==5.2.1
qtpy==1.11.2
regex==2021.11.10
qtpy==1.11.3
requests==2.26.0
restructuredtext-lint==1.3.2
send2trash==1.8.0
Expand Down
13 changes: 6 additions & 7 deletions .constraints/py3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ babel==2.9.1
backcall==0.2.0
backports.entry-points-selectable==1.1.1
beautifulsoup4==4.10.0
black==21.11b1
black==21.12b0
bleach==4.1.0
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
charset-normalizer==2.0.8
charset-normalizer==2.0.9
click==7.1.2
colorama==0.4.4
coverage==6.2
Expand Down Expand Up @@ -57,7 +57,7 @@ importlib-metadata==4.8.2
importlib-resources==5.4.0
iniconfig==1.1.1
ipykernel==6.6.0
ipython==7.30.0
ipython==7.30.1
ipython-genutils==0.2.0
ipywidgets==7.6.5
isort==5.10.1
Expand Down Expand Up @@ -96,7 +96,7 @@ nbclient==0.5.9
nbconvert==6.3.0
nbdime==3.1.1
nbformat==5.1.3
nbmake==1.0
nbmake==1.1
nest-asyncio==1.5.4
nodeenv==1.6.0
notebook==6.4.6
Expand Down Expand Up @@ -127,7 +127,7 @@ pydocstyle==6.1.1
pydot==1.4.2
pyflakes==2.4.0
pygments==2.10.0
pylint==2.12.1
pylint==2.12.2
pyparsing==3.0.6
pyrsistent==0.18.0
pytest==6.2.5
Expand All @@ -141,8 +141,7 @@ pytz==2021.3
pyyaml==6.0
pyzmq==22.3.0
qtconsole==5.2.1
qtpy==1.11.2
regex==2021.11.10
qtpy==1.11.3
requests==2.26.0
restructuredtext-lint==1.3.2
send2trash==1.8.0
Expand Down
13 changes: 6 additions & 7 deletions .constraints/py3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ babel==2.9.1
backcall==0.2.0
backports.entry-points-selectable==1.1.1
beautifulsoup4==4.10.0
black==21.11b1
black==21.12b0
bleach==4.1.0
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
charset-normalizer==2.0.8
charset-normalizer==2.0.9
click==7.1.2
colorama==0.4.4
coverage==6.2
Expand Down Expand Up @@ -56,7 +56,7 @@ imagesize==1.3.0
importlib-metadata==4.8.2
iniconfig==1.1.1
ipykernel==6.6.0
ipython==7.30.0
ipython==7.30.1
ipython-genutils==0.2.0
ipywidgets==7.6.5
isort==5.10.1
Expand Down Expand Up @@ -95,7 +95,7 @@ nbclient==0.5.9
nbconvert==6.3.0
nbdime==3.1.1
nbformat==5.1.3
nbmake==1.0
nbmake==1.1
nest-asyncio==1.5.4
nodeenv==1.6.0
notebook==6.4.6
Expand Down Expand Up @@ -126,7 +126,7 @@ pydocstyle==6.1.1
pydot==1.4.2
pyflakes==2.4.0
pygments==2.10.0
pylint==2.12.1
pylint==2.12.2
pyparsing==3.0.6
pyrsistent==0.18.0
pytest==6.2.5
Expand All @@ -140,8 +140,7 @@ pytz==2021.3
pyyaml==6.0
pyzmq==22.3.0
qtconsole==5.2.1
qtpy==1.11.2
regex==2021.11.10
qtpy==1.11.3
requests==2.26.0
restructuredtext-lint==1.3.2
send2trash==1.8.0
Expand Down
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"asdot",
"astuple",
"autoupdate",
"bdist",
"cano",
"celltoolbar",
"codacy",
Expand Down Expand Up @@ -180,6 +181,7 @@
"precommit",
"prefactor",
"preorder",
"prereleased",
"pygments",
"pylance",
"pylintrc",
Expand All @@ -190,6 +192,7 @@
"rightarrow",
"risch",
"rtfd",
"sdist",
"seealso",
"sharex",
"startswith",
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# cspell:ignore bdist noreply prereleased sdist

name: CD

on:
Expand All @@ -10,16 +8,27 @@ on:

jobs:
push:
name: Push to stable branch
name: Push to version branches
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- name: Push to stable branch
- name: Configure Git credentials
run: |
git config --global user.name "GitHub Action"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git push origin HEAD:refs/heads/stable -f
- name: Push to stable branch
run: |
git push origin HEAD:refs/heads/stable --force
- name: Push to matching minor version branch
env:
TAG: ${{ github.ref_name }}
run: |
re='^([0-9]+)\.([0-9]+)\.[0-9]+'
if [[ $TAG =~ $re ]]; then
MINOR_VERSION_BRANCH="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.x"
git push origin HEAD:refs/heads/$MINOR_VERSION_BRANCH --force
fi
pypi:
name: Publish to PyPI
Expand Down
49 changes: 29 additions & 20 deletions .github/workflows/requirements-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,28 @@ on:
- epic/*

jobs:
pip-constraints:
name: Update pip constraints files
diff:
name: Check dependency changes
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Determine dependency changes
run: |
DIFF="$(git diff origin/main --color -- .constraints .pre-commit-config.yaml setup.cfg)"
echo ::set-output name=diff::"${DIFF}"
id: diff
outputs:
diff: ${{ steps.diff.outputs.diff }}

pip-constraints:
name: Update pip constraints
needs: diff
if: >
github.event.pull_request.head.repo.full_name == github.repository &&
needs.diff.outputs.diff != ''
# Only run if PR does not come from a fork
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
runs-on: ubuntu-20.04
Expand All @@ -24,39 +43,29 @@ jobs:
- "3.10"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if there are dependency changes
run: |
DIFF="$(git diff origin/main --color -- .constraints setup.cfg)"
echo ::set-output name=diff::"${DIFF}"
id: diff
- uses: ComPWA/update-pip-constraints@main
if: steps.diff.outputs.diff != ''
with:
python-version: ${{ matrix.python-version }}

pre-commit:
name: pre-commit autoupdate
if: github.event.pull_request.head.repo.full_name == github.repository
needs: diff
if: >
github.event.pull_request.head.repo.full_name == github.repository &&
needs.diff.outputs.diff != ''
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if there are changes to pre-commit config
run: |
DIFF="$(git diff origin/main --color -- .pre-commit-config.yaml)"
echo ::set-output name=diff::"${DIFF}"
id: diff
- uses: ComPWA/update-pre-commit@main
if: steps.diff.outputs.diff != ''

push:
name: Push changes
if: github.event.pull_request.head.repo.full_name == github.repository
if: >
github.event.pull_request.head.repo.full_name == github.repository &&
needs.diff.outputs.diff != ''
runs-on: ubuntu-20.04
needs:
- diff
- pip-constraints
- pre-commit
steps:
Expand Down
Loading

0 comments on commit 9a23a1c

Please sign in to comment.