Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"

- name: Install Dependencies
run: pip install commitizen

- name: Check commit history
run: cz check --rev-range $(git rev-list --all --reverse | head -1)..HEAD
run: uvx commitizen check --rev-range HEAD~1..HEAD
20 changes: 17 additions & 3 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ on:
pull_request:
types: [opened, synchronize]

concurrency:
# Cancel older, in-progress jobs from the same PR, same workflow.
# use run_id if the job is triggered by a push to ensure
# push-triggered jobs to not get canceled.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
docs:
runs-on: ubuntu-latest
Expand All @@ -16,13 +23,20 @@ jobs:
contents: write

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"

- name: Install Dependencies
run: uv sync --group docs

- name: Add venv to PATH
run: echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
# NOTE: Otherwise the next action nukes the path when it starts

- name: Ape Docs
uses: apeworx/sphinx-ape@main
with:
Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/prtitle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,11 @@ on:
- synchronize

jobs:
check:
runs-on: ubuntu-latest
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
steps:
- uses: astral-sh/setup-uv@v7

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install Dependencies
run: pip install commitizen

- name: Check PR Title
env:
TITLE: ${{ github.event.pull_request.title }}
run: cz check --message "$TITLE"
- name: Check PR Title
run: uvx commitlint "${{ github.event.pull_request.title }}"
20 changes: 6 additions & 14 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[release]

- name: Build
run: python setup.py sdist bdist_wheel
run: uv build

- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/* --verbose
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
80 changes: 24 additions & 56 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,94 +14,62 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[lint]
run: uv sync --group lint

- name: Run Black
run: black --check .
- name: Run Ruff Lint
run: uv run ruff check .

- name: Run isort
run: isort --check-only .

- name: Run flake8
run: flake8 .
- name: Run Ruff Format
run: uv run ruff format --check .

- name: Run mdformat
run: mdformat . --check
run: uv run mdformat --check README.md CONTRIBUTING.md docs

type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[lint,test]
run: uv sync --group lint --group test

- name: Run MyPy
run: mypy .
run: uv run mypy .

functional:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest] # eventually add `windows-latest`
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]

os: [ubuntu-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
env:
WEB3_INFURA_PROJECT_ID: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
run: uv sync --group test

- name: Run Tests
run: pytest -m "not fuzzing" -s --cov=src -n auto
env:
WEB3_INFURA_PROJECT_ID: ${{ secrets.WEB3_INFURA_PROJECT_ID }}

# NOTE: uncomment this block after you've marked tests with @pytest.mark.fuzzing
# fuzzing:
# runs-on: ubuntu-latest
#
# strategy:
# fail-fast: true
#
# steps:
# - uses: actions/checkout@v4
#
# - name: Setup Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
#
# - name: Install Dependencies
# run: |
# python -m pip install --upgrade pip
# pip install .[test]
#
# - name: Run Tests
# run: pytest -m "fuzzing" --no-cov -s
run: uv run ape test -m "not fuzzing" -n 0 -s --cov

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ version.py
**/.DS_Store
*.swp
*.swo

uv.lock
31 changes: 13 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,29 @@ repos:
hooks:
- id: check-yaml

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking]
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
rev: v1.19.1
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-requests, types-setuptools, pydantic]
additional_dependencies: [types-setuptools, types-requests, types-PyYAML, pydantic]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.21
rev: 1.0.0
hooks:
- id: mdformat
additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject]

- repo: https://github.com/opensource-nepal/commitlint
rev: v1.3.0
hooks:
- id: commitlint

default_language_version:
python: python3
60 changes: 13 additions & 47 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,23 @@ To get started with working on the codebase, use the following steps prepare you
git clone https://github.com/ApeWorX/ape-infura.git
cd ape-infura

# create and load a virtual environment
python3 -m venv venv
source venv/bin/activate

# install ape-infura into the virtual environment
python setup.py install

# install the developer dependencies (-e is interactive mode)
pip install -e .'[dev]'
```

## Pre-Commit Hooks

We use [`pre-commit`](https://pre-commit.com/) hooks to simplify linting and ensure consistent formatting among contributors.
Use of `pre-commit` is not a requirement, but is highly recommended.

Install `pre-commit` locally from the root folder:

```bash
pip install pre-commit
pre-commit install
```

Committing will now automatically run the local hooks and ensure that your commit passes all lint checks.

## Running the docs locally

First, make sure you have the docs-related tooling installed:

```bash
pip install -e .'[doc]'
# install the developer dependencies
uv sync --group dev
```

Then, run the following from the root project directory:
## Prek Hooks

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

For the best viewing experience, use a local server:
Install hooks locally from the repo root:

```bash
sphinx-ape serve .
uv run prek install
```

Then, open your browser to `127.0.0.1:1337` and click the `ape` directory link.

You can also use the `--open` flag to automatically open the docs:

```bash
sphinx-ape serve . --open
```
Committing will now automatically run the local hooks and ensure that your commit passes all lint
checks.

## Pull Requests

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

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

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

Join the ApeWorX [Discord](https://discord.gg/apeworx) if you have any questions.
Loading
Loading