Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade template #57

Merged
merged 14 commits into from
Mar 18, 2024
129 changes: 101 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ common: &common
command: |
python -m pip install --upgrade pip
python -m pip install tox
- run:
name: install pre-commit
command: python -m pip install --progress-bar=off pre-commit
- run:
name: run tox
command: python -m tox run -r
Expand All @@ -42,32 +39,65 @@ common: &common
orbs:
win: circleci/windows@5.0.0

windows_steps: &windows_steps
executor:
name: win/default
shell: bash.exe
working_directory: C:\Users\circleci\project\eth-typing
windows-wheel-steps:
windows-wheel-setup: &windows-wheel-setup
executor:
name: win/default
shell: bash.exe
working_directory: C:\Users\circleci\project\eth-typing
environment:
TOXENV: windows-wheel
restore-cache-step: &restore-cache-step
restore_cache:
keys:
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
install-pyenv-step: &install-pyenv-step
run:
name: install pyenv
command: |
pip install pyenv-win --target $HOME/.pyenv
echo 'export PYENV="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
echo 'export PYENV_ROOT="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
echo 'export PYENV_USERPROFILE="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
echo 'export PATH="$PATH:$HOME/.pyenv/pyenv-win/bin"' >> $BASH_ENV
echo 'export PATH="$PATH:$HOME/.pyenv/pyenv-win/shims"' >> $BASH_ENV
source $BASH_ENV
pyenv update
install-latest-python-step: &install-latest-python-step
run:
name: install latest python version and tox
command: |
LATEST_VERSION=$(pyenv install --list | grep -E "${MINOR_VERSION}\.[0-9]+$" | tail -1)
echo "installing python version $LATEST_VERSION"
pyenv install $LATEST_VERSION
pyenv global $LATEST_VERSION
python3 -m pip install --upgrade pip
python3 -m pip install tox
run-tox-step: &run-tox-step
run:
name: run tox
command: |
echo 'running tox with' $(python3 --version)
python3 -m tox run -r
save-cache-step: &save-cache-step
save_cache:
paths:
- .tox
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}

docs: &docs
docker:
- image: common
steps:
- checkout
- restore_cache:
keys:
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
- run:
name: install dependencies
name: install latexpdf dependencies
command: |
python -m pip install --upgrade pip
python -m pip install tox
- run:
name: run tox
command: python -m tox run -r
- save_cache:
paths:
- .tox
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
sudo apt-get update
sudo apt-get install latexmk tex-gyre texlive-fonts-extra

jobs:
docs:
<<: *common
<<: *docs
docker:
- image: cimg/python:3.8
environment:
Expand Down Expand Up @@ -97,6 +127,12 @@ jobs:
- image: cimg/python:3.11
environment:
TOXENV: py311-core
py312-core:
<<: *common
docker:
- image: cimg/python:3.12
environment:
TOXENV: py312-core

py38-lint:
<<: *common
Expand All @@ -122,6 +158,12 @@ jobs:
- image: cimg/python:3.11
environment:
TOXENV: py311-lint
py312-lint:
<<: *common
docker:
- image: cimg/python:3.12
environment:
TOXENV: py312-lint

py38-wheel:
<<: *common
Expand All @@ -147,11 +189,38 @@ jobs:
- image: cimg/python:3.11
environment:
TOXENV: py311-wheel
py312-wheel:
<<: *common
docker:
- image: cimg/python:3.12
environment:
TOXENV: py312-wheel

py311-wheel-windows:
<<: *windows_steps
environment:
TOXENV: py311-wheel-windows
py311-windows-wheel:
<<: *windows-wheel-setup
steps:
- checkout
- <<: *restore-cache-step
- <<: *install-pyenv-step
- run:
name: set minor version
command: echo "export MINOR_VERSION='3.11'" >> $BASH_ENV
- <<: *install-latest-python-step
- <<: *run-tox-step
- <<: *save-cache-step

py312-windows-wheel:
<<: *windows-wheel-setup
steps:
- checkout
- <<: *restore-cache-step
- <<: *install-pyenv-step
- run:
name: set minor version
command: echo "export MINOR_VERSION='3.12'" >> $BASH_ENV
- <<: *install-latest-python-step
- <<: *run-tox-step
- <<: *save-cache-step

workflows:
version: 2
Expand All @@ -162,12 +231,16 @@ workflows:
- py39-core
- py310-core
- py311-core
- py312-core
- py38-lint
- py39-lint
- py310-lint
- py311-lint
- py312-lint
- py38-wheel
- py39-wheel
- py310-wheel
- py311-wheel
- py311-wheel-windows
- py312-wheel
- py311-windows-wheel
- py312-windows-wheel
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ repos:
hooks:
- id: mypy
exclude: tests/
- repo: https://github.com/PrincetonUniversity/blocklint
rev: v0.2.4
hooks:
- id: blocklint
exclude: 'docs/Makefile|docs/release_notes.rst|tox.ini'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this find all other files in the repo? I think I was trying with listing directories to include but if this works I like it better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried sticking blocked words in various files and it hasn't missed one yet.

12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ build-docs:
$(MAKE) -C docs html
$(MAKE) -C docs doctest

validate-docs:
build-docs-ci:
$(MAKE) -C docs latexpdf
$(MAKE) -C docs epub

validate-newsfragments:
python ./newsfragments/validate_files.py
towncrier build --draft --version preview

check-docs: build-docs validate-docs
check-docs: build-docs validate-newsfragments

check-docs-ci: build-docs build-docs-ci validate-newsfragments

docs: check-docs
open docs/_build/html/index.html
Expand All @@ -56,7 +62,7 @@ ifndef bump
$(error bump must be set, typically: major, minor, patch, or devnum)
endif

notes: check-bump
notes: check-bump validate-newsfragments
# Let UPCOMING_VERSION be the version that is used for the current bump
$(eval UPCOMING_VERSION=$(shell bumpversion $(bump) --dry-run --list | grep new_version= | sed 's/new_version=//g'))
# Now generate the release notes to have them included in the release commit
Expand Down
1 change: 1 addition & 0 deletions newsfragments/57.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add python3.12 support
1 change: 1 addition & 0 deletions newsfragments/57.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Merge template updates, adding build tests for all docs formats, add ``blocklint`` to lint tools
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def test_import():
def test_import_and_version():
import eth_typing

assert isinstance(eth_typing.__version__, str)
23 changes: 15 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tox]
envlist=
py{38,39,310,311}-core
py{38,39,310,311}-lint
py{38,39,310,311}-wheel
py311-wheel-windows
py{38,39,310,311,312}-core
py{38,39,310,311,312}-lint
py{38,39,310,311,312}-wheel
windows-wheel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe:

Suggested change
windows-wheel
py{311,312}-windows-wheel

for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is, it just keeps circleci config drier. See .circleci/config.yml -> windows-wheel-steps -> windows-wheel-setup. If specified different TOXENVs, the whole windows-wheel-setup step would need to be duplicated for each job. Happy to make the change if you think it helps with clarity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, I think it's good as-is. ✨

docs

[flake8]
Expand All @@ -12,28 +12,34 @@ extend-ignore=E203
max-line-length=88
per-file-ignores=__init__.py:F401

[blocklint]
max_issue_threshold=1

[testenv]
usedevelop=True
commands=
core: pytest {posargs:tests/core}
docs: make check-docs
docs: make check-docs-ci
basepython=
docs: python
windows-wheel: python
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11
py312: python3.12
extras=
test
docs
allowlist_externals=make,pre-commit

[testenv:py{38,39,310,311}-lint]
[testenv:py{38,39,310,311,312}-lint]
deps=pre-commit
commands=
pre-commit install
pre-commit run --all-files --show-diff-on-failure

[testenv:py{38,39,310,311}-wheel]
[testenv:py{38,39,310,311,312}-wheel]
deps=
wheel
build[virtualenv]
Expand All @@ -48,13 +54,14 @@ commands=
python -c "import eth_typing"
skip_install=true

[testenv:py311-wheel-windows]
[testenv:windows-wheel]
deps=
wheel
build[virtualenv]
allowlist_externals=
bash.exe
commands=
python --version
python -m pip install --upgrade pip
bash.exe -c "rm -rf build dist"
python -m build
Expand Down