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

test: parametrize CI over EVM versions #3842

Merged
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f0f7907
feat[test]: parametrize over evm versions in the test suite
charles-cooper Mar 7, 2024
4c30b21
update the strategy matrix
charles-cooper Mar 7, 2024
6e9c81b
fix options passed to pytest
charles-cooper Mar 7, 2024
85bce5c
fix job name
charles-cooper Mar 7, 2024
f955d6e
Merge branch 'master' into chore/test-transient-storage
charles-cooper Mar 8, 2024
a8f4514
fix dependencies
charles-cooper Mar 8, 2024
b21790f
fix evm version option list
charles-cooper Mar 8, 2024
1d9a9f6
fix an option
charles-cooper Mar 8, 2024
d513af4
disable 3.12 for now
charles-cooper Mar 8, 2024
f7e280f
fix the matrix
charles-cooper Mar 8, 2024
1e4ea23
fix lint
charles-cooper Mar 8, 2024
aec8376
fix the matrix again
charles-cooper Mar 8, 2024
85d9342
fix the matrix, again
charles-cooper Mar 8, 2024
963ecf6
missing brackets
charles-cooper Mar 8, 2024
0344147
Merge branch 'master' into chore/test-transient-storage
charles-cooper Mar 13, 2024
e5a4cac
update the matrix
charles-cooper Mar 13, 2024
dbad4ad
matrix major column
charles-cooper Mar 13, 2024
b4b7375
fix pytest command
charles-cooper Mar 14, 2024
50d58e7
fix a test
charles-cooper Mar 14, 2024
34e3c4d
set evm version properly
charles-cooper Mar 14, 2024
5abacec
fix a py-evm configuration value
charles-cooper Mar 14, 2024
27f9777
fix a test for pre-shanghai versions
charles-cooper Mar 14, 2024
97f9476
disable cancun
charles-cooper Mar 14, 2024
1a0d2b2
add a note
charles-cooper Mar 14, 2024
98e7785
remove more stuff from tox.ini
charles-cooper Mar 14, 2024
b55af3f
fix install deps steps
charles-cooper Mar 14, 2024
ac5a89f
Revert changes to fuzzing and memorymock jobs
charles-cooper Mar 14, 2024
617b156
remove placeholder
charles-cooper Mar 14, 2024
55cda80
use pytest.skip
charles-cooper Mar 15, 2024
c21776d
fix lint
charles-cooper Mar 15, 2024
e2d7e88
add a comma
charles-cooper Mar 15, 2024
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
50 changes: 41 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,42 @@ jobs:
strategy:
matrix:
python-version: [["3.11", "311"]]
# run in modes: --optimize [gas, none, codesize]
opt-mode: ["gas", "none", "codesize"]
evm-version: [shanghai]
debug: [true, false]
# run across other python versions.# we don't really need to run all
# modes across all python versions - one is enough

# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
include:
# test default settings with 3.11 across all supported evm versions
- python-version: ["3.11", "311"]
debug: false
opt-mode: gas
evm-version: london
- python-version: ["3.11", "311"]
debug: false
opt-mode: gas
evm-version: paris
- python-version: ["3.11", "311"]
debug: false
opt-mode: gas
evm-version: shanghai
# enable when py-evm makes it work:
#- python-version: ["3.11", "311"]
# debug: false
# opt-mode: gas
# evm-version: cancun

# run across other python versions. we don't really need to run all
# modes across all python versions - one is enough
- python-version: ["3.10", "310"]
opt-mode: gas
debug: false
evm-version: shanghai

# TODO 3.12 doesn't work yet, investigate - may be hypothesis issue
#- python-version: ["3.12", "312"]

name: py${{ matrix.python-version[1] }}-opt-${{ matrix.opt-mode }}${{ matrix.debug && '-debug' || '' }}
name: py${{ matrix.python-version[1] }}-opt-${{ matrix.opt-mode }}${{ matrix.debug && '-debug' || '' }}-${{ matrix.evm-version }}

steps:
- uses: actions/checkout@v4
Expand All @@ -86,11 +111,18 @@ jobs:
python-version: ${{ matrix.python-version[0] }}
cache: "pip"

- name: Install Tox
run: pip install tox

- name: Run Tox
run: TOXENV=py${{ matrix.python-version[1] }} tox -r -- --optimize ${{ matrix.opt-mode }} ${{ matrix.debug && '--enable-compiler-debug-mode' || '' }} -r aR tests/
- name: Install dependencies
run: pip install .[test]

- name: Run tests
run: |
pytest \
-m "not fuzzing" \
--optimize ${{ matrix.opt-mode }} \
--evm-version ${{ matrix.evm-version }} \
${{ matrix.debug && '--enable-compiler-debug-mode' || '' }} \
--showlocals -r aR \
tests/

- name: Upload Coverage
uses: codecov/codecov-action@v4
Expand Down
24 changes: 21 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from web3.contract import Contract
from web3.providers.eth_tester import EthereumTesterProvider

import vyper.evm.opcodes as evm
from tests.utils import working_directory
from vyper import compiler
from vyper.ast.grammar import parse_vyper_source
Expand All @@ -38,7 +39,7 @@


def set_evm_verbose_logging():
logger = logging.getLogger("eth.vm.computation.Computation")
logger = logging.getLogger("eth.vm.computation.BaseComputation")
setup_DEBUG2_logging()
logger.setLevel("DEBUG2")

Expand All @@ -59,6 +60,13 @@ def pytest_addoption(parser):
)
parser.addoption("--enable-compiler-debug-mode", action="store_true")

parser.addoption(
"--evm-version",
choices=list(evm.EVM_VERSIONS.keys()),
default="shanghai",
help="set evm version",
)


@pytest.fixture(scope="module")
def output_formats():
Expand All @@ -81,6 +89,18 @@ def debug(pytestconfig):
_set_debug_mode(debug)


@pytest.fixture(scope="session", autouse=True)
def evm_version(pytestconfig):
# note: we configure the evm version that we emit code for,
# but eth-tester is only configured with the latest mainnet
# version.
evm_version_str = pytestconfig.getoption("evm_version")
evm.DEFAULT_EVM_VERSION = evm_version_str
# this should get overridden by anchor_evm_version,
# but set it anyway
evm.active_evm_version = evm.EVM_VERSIONS[evm_version_str]


@pytest.fixture
def chdir_tmp_path(tmp_path):
# this is useful for when you want imports to have relpaths
Expand Down Expand Up @@ -308,7 +328,6 @@ def _get_contract(
**kwargs,
):
settings = Settings()
settings.evm_version = kwargs.pop("evm_version", None)
settings.optimize = override_opt_level or optimize
out = compiler.compile_code(
source_code,
Expand Down Expand Up @@ -383,7 +402,6 @@ def _deploy_blueprint_for(
w3, source_code, optimize, output_formats, initcode_prefix=ERC5202_PREFIX, **kwargs
):
settings = Settings()
settings.evm_version = kwargs.pop("evm_version", None)
settings.optimize = optimize
out = compiler.compile_code(
source_code,
Expand Down
Loading
Loading