Skip to content

Commit 53f9790

Browse files
committed
refactor: modernize python tooling
1 parent 4fee040 commit 53f9790

18 files changed

Lines changed: 282 additions & 336 deletions
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v6
1313
with:
1414
fetch-depth: 0
1515

16-
- name: Setup Python
17-
uses: actions/setup-python@v4
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v7
1818
with:
1919
python-version: "3.10"
2020

21-
- name: Install Dependencies
22-
run: pip install commitizen
23-
2421
- name: Check commit history
25-
run: cz check --rev-range $(git rev-list --all --reverse | head -1)..HEAD
22+
run: uvx commitizen check --rev-range HEAD~1..HEAD

.github/workflows/docs.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ on:
88
pull_request:
99
types: [opened, synchronize]
1010

11+
concurrency:
12+
# Cancel older, in-progress jobs from the same PR, same workflow.
13+
# use run_id if the job is triggered by a push to ensure
14+
# push-triggered jobs to not get canceled.
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
1118
jobs:
1219
docs:
1320
runs-on: ubuntu-latest
@@ -16,13 +23,20 @@ jobs:
1623
contents: write
1724

1825
steps:
19-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v6
2027

21-
- name: Setup Python
22-
uses: actions/setup-python@v5
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v7
2330
with:
2431
python-version: "3.10"
2532

33+
- name: Install Dependencies
34+
run: uv sync --group docs
35+
36+
- name: Add venv to PATH
37+
run: echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
38+
# NOTE: Otherwise the next action nukes the path when it starts
39+
2640
- name: Ape Docs
2741
uses: apeworx/sphinx-ape@main
2842
with:

.github/workflows/prtitle.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: PR Title
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: astral-sh/setup-uv@v7
16+
17+
- name: Check PR Title
18+
run: uvx commitlint "${{ github.event.pull_request.title }}"

.github/workflows/publish.yaml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v6
1414

15-
- name: Set up Python
16-
uses: actions/setup-python@v4
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v7
1717
with:
1818
python-version: "3.10"
1919

20-
- name: Install dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install -e .[release]
24-
2520
- name: Build
26-
run: python setup.py sdist bdist_wheel
21+
run: uv build
2722

28-
- name: Publish
29-
env:
30-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
31-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
32-
run: twine upload dist/* --verbose
23+
- name: Publish to PyPI
24+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yaml

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,90 +14,60 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v6
1818

19-
- name: Setup Python
20-
uses: actions/setup-python@v4
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v7
2121
with:
2222
python-version: "3.10"
2323

2424
- name: Install Dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install .[lint]
25+
run: uv sync --group lint
2826

29-
- name: Run Black
30-
run: black --check .
27+
- name: Run Ruff Lint
28+
run: uv run ruff check .
3129

32-
- name: Run isort
33-
run: isort --check-only .
34-
35-
- name: Run flake8
36-
run: flake8 .
30+
- name: Run Ruff Format
31+
run: uv run ruff format --check .
3732

3833
- name: Run mdformat
39-
run: mdformat . --check
34+
run: uv run mdformat --check README.md CONTRIBUTING.md docs
4035

4136
type-check:
4237
runs-on: ubuntu-latest
4338

4439
steps:
45-
- uses: actions/checkout@v3
40+
- uses: actions/checkout@v6
4641

47-
- name: Setup Python
48-
uses: actions/setup-python@v4
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v7
4944
with:
5045
python-version: "3.10"
5146

5247
- name: Install Dependencies
53-
run: |
54-
python -m pip install --upgrade pip
55-
pip install .[lint,test]
48+
run: uv sync --group lint --group test
5649

5750
- name: Run MyPy
58-
run: mypy .
51+
run: uv run mypy .
5952

6053
functional:
6154
runs-on: ${{ matrix.os }}
6255

6356
strategy:
6457
matrix:
65-
os: [ubuntu-latest, macos-latest] # eventually add `windows-latest`
66-
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
67-
58+
os: [ubuntu-latest, macos-latest]
59+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
6860
steps:
69-
- uses: actions/checkout@v3
61+
- uses: actions/checkout@v6
7062

71-
- name: Setup Python
72-
uses: actions/setup-python@v4
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@v7
7365
with:
7466
python-version: ${{ matrix.python-version }}
7567

7668
- name: Install Dependencies
77-
run: |
78-
python -m pip install --upgrade pip
79-
pip install .[test]
69+
run: uv sync --group test
8070

8171
- name: Run Tests
82-
run: pytest -m "not fuzzing" -n 0 -s --cov
83-
84-
# NOTE: uncomment this block after you've marked tests with @pytest.mark.fuzzing
85-
# fuzzing:
86-
# runs-on: ubuntu-latest
87-
#
88-
# strategy:
89-
# fail-fast: true
90-
#
91-
# steps:
92-
# - uses: actions/checkout@v3
93-
#
94-
# - name: Setup Python
95-
# uses: actions/setup-python@v4
96-
# with:
97-
# python-version: "3.10"
98-
#
99-
# - name: Install Dependencies
100-
# run: pip install .[test]
101-
#
102-
# - name: Run Tests
103-
# run: pytest -m "fuzzing" --no-cov -s
72+
run: uv run ape test -m "not fuzzing" -n 0 -s --cov
73+

.github/workflows/title.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,5 @@ version.py
122122
*.swo
123123

124124
.build/*
125+
126+
uv.lock

.pre-commit-config.yaml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,29 @@ repos:
44
hooks:
55
- id: check-yaml
66

7-
- repo: https://github.com/PyCQA/isort
8-
rev: 5.13.2
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: v0.14.14
99
hooks:
10-
- id: isort
11-
12-
- repo: https://github.com/psf/black
13-
rev: 24.10.0
14-
hooks:
15-
- id: black
16-
name: black
17-
18-
- repo: https://github.com/pycqa/flake8
19-
rev: 7.1.1
20-
hooks:
21-
- id: flake8
22-
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking]
10+
- id: ruff
11+
args: [--fix]
12+
- id: ruff-format
2313

2414
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.13.0
15+
rev: v1.19.1
2616
hooks:
2717
- id: mypy
28-
additional_dependencies: [types-setuptools, pydantic]
18+
additional_dependencies: [types-setuptools, types-requests, types-PyYAML, pydantic]
2919

3020
- repo: https://github.com/executablebooks/mdformat
31-
rev: 0.7.19
21+
rev: 1.0.0
3222
hooks:
3323
- id: mdformat
3424
additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject]
3525

26+
- repo: https://github.com/opensource-nepal/commitlint
27+
rev: v1.3.0
28+
hooks:
29+
- id: commitlint
30+
3631
default_language_version:
3732
python: python3

CONTRIBUTING.md

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,23 @@ To get started with working on the codebase, use the following steps prepare you
77
git clone https://github.com/ApeWorX/ape-ens.git
88
cd ape-ens
99

10-
# create and load a virtual environment
11-
python3 -m venv venv
12-
source venv/bin/activate
13-
14-
# install ape-ens into the virtual environment
15-
python setup.py install
16-
17-
# install the developer dependencies (-e is interactive mode)
18-
pip install -e .'[dev]'
19-
```
20-
21-
## Pre-Commit Hooks
22-
23-
We use [`pre-commit`](https://pre-commit.com/) hooks to simplify linting and ensure consistent formatting among contributors.
24-
Use of `pre-commit` is not a requirement, but is highly recommended.
25-
26-
Install `pre-commit` locally from the root folder:
27-
28-
```bash
29-
pip install pre-commit
30-
pre-commit install
31-
```
32-
33-
Committing will now automatically run the local hooks and ensure that your commit passes all lint checks.
34-
35-
## Running the docs locally
36-
37-
First, make sure you have the docs-related tooling installed:
38-
39-
```bash
40-
pip install -e .'[doc]'
10+
# install the developer dependencies
11+
uv sync --group dev
4112
```
4213

43-
Then, run the following from the root project directory:
14+
## Prek Hooks
4415

45-
```bash
46-
sphinx-ape build .
47-
```
16+
We use [`prek`](https://github.com/j178/prek) to run repository hooks and keep contributor workflows
17+
consistent. Use of `prek` is not a requirement, but is highly recommended.
4818

49-
For the best viewing experience, use a local server:
19+
Install hooks locally from the repo root:
5020

5121
```bash
52-
sphinx-ape serve .
22+
uv run prek install
5323
```
5424

55-
Then, open your browser to `127.0.0.1:1337` and click the `ape` directory link.
56-
57-
You can also use the `--open` flag to automatically open the docs:
58-
59-
```bash
60-
sphinx-ape serve . --open
61-
```
25+
Committing will now automatically run the local hooks and ensure that your commit passes all lint
26+
checks.
6227

6328
## Pull Requests
6429

@@ -68,10 +33,11 @@ Pull requests are welcomed! Please adhere to the following:
6833
- Include test cases for any new functionality
6934
- Include any relevant documentation updates
7035

71-
It's a good idea to make pull requests early on.
72-
A pull request represents the start of a discussion, and doesn't necessarily need to be the final, finished submission.
36+
It's a good idea to make pull requests early on. A pull request represents the start of a
37+
discussion, and doesn't necessarily need to be the final, finished submission.
7338

74-
If you are opening a work-in-progress pull request to verify that it passes CI tests, please consider
39+
If you are opening a work-in-progress pull request to verify that it passes CI tests, please
40+
consider
7541
[marking it as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests).
7642

77-
Join the Ethereum Python [Discord](https://discord.gg/PcEJ54yX) if you have any questions.
43+
Join the ApeWorX [Discord](https://discord.gg/apeworx) if you have any questions.

0 commit comments

Comments
 (0)