-
-
Notifications
You must be signed in to change notification settings - Fork 180
182 lines (143 loc) · 5.5 KB
/
Copy pathtest.yaml
File metadata and controls
182 lines (143 loc) · 5.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
on: ["push", "pull_request"]
name: Test
permissions:
contents: read
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_ETH_APE: "0.8.999"
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:
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