Skip to content
Merged
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
338 changes: 174 additions & 164 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,167 +16,177 @@ concurrency:
cancel-in-progress: true

jobs:
linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Run Ruff Lint
run: uv run --only-group style ruff check .

- name: Run Ruff Format
run: uv run --only-group style ruff format --check .

- name: Run mdformat
run: uv run --only-group style mdformat --check *.md docs/**/*.md

type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Run MyPy
run: uv run --group lint --group test mypy .

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

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

env:
COVERAGE_ARGS: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && '--cov=src --cov-append' || '--no-cov' }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Install Test Environment
run: uv sync --no-default-groups --group test

- name: Install Geth
uses: ApeWorX/geth-action@v1

- name: Cache Solidity Compilers
uses: actions/cache@v5
with:
path: ~/.solcx
key: ${{ runner.os }}-solcx-${{ hashFiles('pyproject.toml', 'tests/**/*.sol') }}
restore-keys: |
${{ runner.os }}-solcx-

- name: Install Solidity Compilers
run: |
uv run --no-sync python -c "
import re
from pathlib import Path

from ape.utils import pragma_str_to_specifier_set
from solcx import get_installable_solc_versions, install_solc

def get_pragma_spec_from_path(path):
source = path.read_text(encoding='utf8')
pragma_match = next(
re.finditer(r'(?:\n|^)\s*pragma\s*solidity\s*([^;\n]*)', source),
None,
)
return pragma_str_to_specifier_set(pragma_match.groups()[0]) if pragma_match else None

def select_version(pragma_spec, options):
choices = sorted(pragma_spec.filter(options), reverse=True)
return choices[0] if choices else None

installable_versions = get_installable_solc_versions()
versions = set()
for path in Path('tests').rglob('*.sol'):
pragma_spec = get_pragma_spec_from_path(path)
if pragma_spec and (version := select_version(pragma_spec, installable_versions)):
versions.add(str(version))

versions = sorted(versions)
print('Installing Solidity compilers:', ', '.join(versions) or 'none')
for version in versions:
install_solc(version, show_progress=False)
"

- name: Cache Ape Packages
uses: actions/cache@v5
with:
path: ~/.ape/packages
key: ${{ runner.os }}-ape-packages-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-ape-packages-

- name: Install Project Dependencies
run: uv run --no-sync ape pm install

- name: Run Functional Tests
run: |
uv run --no-sync ape test \
-s -v ERROR \
-n auto --dist loadgroup \
-m "not hypothesis" \
$COVERAGE_ARGS \
tests/functional

- name: Run Integration Tests
run: |
uv run --no-sync ape test \
-s -v ERROR \
-n auto --dist loadgroup \
-m "not hypothesis" \
$COVERAGE_ARGS \
tests/integration

- name: Run Performance Tests
run: |
uv run --no-sync ape test \
-s -v ERROR \
tests/performance

fuzzing:
runs-on: ubuntu-latest

strategy:
fail-fast: true

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Install Test Environment
run: uv sync --no-default-groups --group test

- name: Run Tests
run: uv run --no-sync ape test -s -m "hypothesis" --no-cov
linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Run Ruff
run: |
echo "=== Ruff Version ==="
uv run --only-group style ruff --version
echo "=== Ruff Configuration ==="
uv run --only-group style ruff config
echo "=== Running Ruff Check ==="
uv run --only-group style ruff check .
echo "=== Running Ruff Format ==="
uv run --only-group style ruff format --check .

- name: Run Mdformat
run: |
echo "=== Mdformat Version ==="
uv run --only-group style mdformat --version
echo "=== Running Mdformat ==="
uv run --only-group style mdformat --check *.md docs/**/*.md

type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Run MyPy
run: |
echo "=== Mypy Version ==="
uv run --group lint --group test mypy --version
echo "=== Running Mypy ==="
uv run --group lint --group test mypy .

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

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

env:
COVERAGE_ARGS: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && '--cov=src --cov-append' || '--no-cov' }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Install Test Environment
run: uv sync --no-default-groups --group test

- name: Install Geth
uses: ApeWorX/geth-action@v1

- name: Cache Solidity Compilers
uses: actions/cache@v5
with:
path: ~/.solcx
key: ${{ runner.os }}-solcx-${{ hashFiles('pyproject.toml', 'tests/**/*.sol') }}
restore-keys: |
${{ runner.os }}-solcx-

- name: Install Solidity Compilers
run: |
uv run --no-sync python -c "
import re
from pathlib import Path

from ape.utils import pragma_str_to_specifier_set
from solcx import get_installable_solc_versions, install_solc

def get_pragma_spec_from_path(path):
source = path.read_text(encoding='utf8')
pragma_match = next(
re.finditer(r'(?:\n|^)\s*pragma\s*solidity\s*([^;\n]*)', source),
None,
)
return pragma_str_to_specifier_set(pragma_match.groups()[0]) if pragma_match else None

def select_version(pragma_spec, options):
choices = sorted(pragma_spec.filter(options), reverse=True)
return choices[0] if choices else None

installable_versions = get_installable_solc_versions()
versions = set()
for path in Path('tests').rglob('*.sol'):
pragma_spec = get_pragma_spec_from_path(path)
if pragma_spec and (version := select_version(pragma_spec, installable_versions)):
versions.add(str(version))

versions = sorted(versions)
print('Installing Solidity compilers:', ', '.join(versions) or 'none')
for version in versions:
install_solc(version, show_progress=False)
"

- name: Cache Ape Packages
uses: actions/cache@v5
with:
path: ~/.ape/packages
key: ${{ runner.os }}-ape-packages-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-ape-packages-

- name: Install Project Dependencies
run: uv run --no-sync ape pm install

- name: Run Functional Tests
run: |
uv run --no-sync ape test \
-s -v ERROR \
-n auto --dist loadgroup \
-m "not hypothesis" \
$COVERAGE_ARGS \
tests/functional

- name: Run Integration Tests
run: |
uv run --no-sync ape test \
-s -v ERROR \
-n auto --dist loadgroup \
-m "not hypothesis" \
$COVERAGE_ARGS \
tests/integration

- name: Run Performance Tests
run: |
uv run --no-sync ape test \
-s -v ERROR \
tests/performance

fuzzing:
runs-on: ubuntu-latest

strategy:
fail-fast: true

steps:
- uses: actions/checkout@v5

- name: Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Run Tests
run: uv run --only-group test ape test -s -m "hypothesis" --no-cov
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ ipython_config.py
# pyenv
.python-version

# uv pkg mngr
uv.lock

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-yaml

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10 # Latest ruff version
rev: v0.15.12 # Latest ruff version
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.1
rev: v2.3.1
hooks:
- id: mypy
additional_dependencies: [
Expand All @@ -27,7 +27,7 @@ repos:
]

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