Skip to content

Commit

Permalink
Merge pull request #1185 from eth-brownie/ci/multiple-jobs
Browse files Browse the repository at this point in the history
Split CI into multiple workflows
  • Loading branch information
iamdefinitelyahuman authored Aug 7, 2021
2 parents 32ef160 + 402d1cd commit 6953d3f
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 133 deletions.
114 changes: 1 addition & 113 deletions .github/workflows/main.yaml → .github/workflows/core-ganache.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on: ["push", "pull_request"]

name: brownie workflow
name: core (ganache)

env:
ETHERSCAN_TOKEN: 9MKURTHE8FNA9NRUUJBHMUEVY6IQ5K1EGY
Expand All @@ -9,118 +9,6 @@ env:

jobs:

linting:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
job: [lint, docs-local]
experimental: [false]
include:
- job: docs-external
experimental: true

steps:
- uses: actions/checkout@v2

- name: Setup Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Tox
run: pip install tox

- name: Run Tox
run: tox -e ${{ matrix.job }}
continue-on-error: ${{ matrix.experimental }}


functionality:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
job: [plugintest, pmtest]

steps:
- uses: actions/checkout@v2

- name: Cache Solidity Installations
uses: actions/cache@v2
with:
path: |
~/.solcx
~/.vvm
key: ${{ runner.os }}-compiler-cache

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Install Ganache
run: npm install -g ganache-cli@6.12.2

- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Tox
run: pip install tox

- name: Run Tox
run: tox -e ${{ matrix.job }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml


evm:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
job: [evm-byzantium, evm-petersburg, evm-istanbul, evm-latest]

steps:
- uses: actions/checkout@v2

- name: Cache Solidity Installations
uses: actions/cache@v2
with:
path: |
~/.solcx
~/.vvm
key: ${{ runner.os }}-compiler-cache

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Install Ganache
run: npm install -g ganache-cli@6.12.2

- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Tox
run: pip install tox

- name: Run Tox
run: tox -e ${{ matrix.job }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml


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

Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/evm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on: ["push", "pull_request"]

name: evm tests

env:
ETHERSCAN_TOKEN: 9MKURTHE8FNA9NRUUJBHMUEVY6IQ5K1EGY
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WEB3_INFURA_PROJECT_ID: 44c6300c5e5b4b2da5fc42b06bf18a8e

jobs:

evm:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
job: [evm-byzantium, evm-petersburg, evm-istanbul, evm-latest]

steps:
- uses: actions/checkout@v2

- name: Cache Solidity Installations
uses: actions/cache@v2
with:
path: |
~/.solcx
~/.vvm
key: ${{ runner.os }}-compiler-cache

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Install Ganache
run: npm install -g ganache-cli@6.12.2

- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Tox
run: pip install tox

- name: Run Tox
run: tox -e ${{ matrix.job }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
51 changes: 51 additions & 0 deletions .github/workflows/functionality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on: ["push", "pull_request"]

name: functionality

env:
ETHERSCAN_TOKEN: 9MKURTHE8FNA9NRUUJBHMUEVY6IQ5K1EGY
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WEB3_INFURA_PROJECT_ID: 44c6300c5e5b4b2da5fc42b06bf18a8e

jobs:

functionality:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
job: [plugintest, pmtest]

steps:
- uses: actions/checkout@v2

- name: Cache Solidity Installations
uses: actions/cache@v2
with:
path: |
~/.solcx
~/.vvm
key: ${{ runner.os }}-compiler-cache

- name: Setup Node.js
uses: actions/setup-node@v1

- name: Install Ganache
run: npm install -g ganache-cli@6.12.2

- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Tox
run: pip install tox

- name: Run Tox
run: tox -e pmtest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
37 changes: 37 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on: ["push", "pull_request"]

name: linting

env:
ETHERSCAN_TOKEN: 9MKURTHE8FNA9NRUUJBHMUEVY6IQ5K1EGY
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WEB3_INFURA_PROJECT_ID: 44c6300c5e5b4b2da5fc42b06bf18a8e

jobs:

linting:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
job: [lint, docs-local]
experimental: [false]
include:
- job: docs-external
experimental: true

steps:
- uses: actions/checkout@v2

- name: Setup Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Tox
run: pip install tox

- name: Run Tox
run: tox -e ${{ matrix.job }}
continue-on-error: ${{ matrix.experimental }}
27 changes: 21 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"pm": "package_test",
"plugin": "plugintester",
}
_dev_network = "development"


def pytest_addoption(parser):
Expand All @@ -43,10 +44,19 @@ def pytest_addoption(parser):
metavar=("solc_versions", "evm_rulesets", "optimizer_runs"),
help="Run evm tests against a matrix of solc versions, evm versions, and compiler runs.",
)
parser.addoption(
"--network",
choices=["development", "hardhat"],
default="development",
)


# remove tests based on config flags and fixture names
def pytest_collection_modifyitems(config, items):
if config.getoption("--network"):
global _dev_network
_dev_network = config.getoption("--network")

if config.getoption("--evm"):
target = "evm"
else:
Expand Down Expand Up @@ -107,6 +117,11 @@ def pytest_sessionstart(session):
)


@pytest.fixture(scope="session")
def network_name():
return _dev_network


# worker ID for xdist process, as an integer
@pytest.fixture(scope="session")
def xdist_id(worker_id):
Expand All @@ -117,7 +132,7 @@ def xdist_id(worker_id):

# ensure a clean data folder, and set unique ganache ports for each xdist worker
@pytest.fixture(scope="session", autouse=True)
def _base_config(tmp_path_factory, xdist_id):
def _base_config(tmp_path_factory, xdist_id, network_name):
brownie._config.DATA_FOLDER = tmp_path_factory.mktemp(f"data-{xdist_id}")
brownie._config._make_data_folders(brownie._config.DATA_FOLDER)

Expand All @@ -128,7 +143,7 @@ def _base_config(tmp_path_factory, xdist_id):

if xdist_id:
port = 8545 + xdist_id
brownie._config.CONFIG.networks["development"]["cmd_settings"]["port"] = port
brownie._config.CONFIG.networks[network_name]["cmd_settings"]["port"] = port


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -220,9 +235,9 @@ def evmtester(_project_factory, project, tmp_path, accounts, request):


@pytest.fixture
def plugintesterbase(project, testdir, monkeypatch):
def plugintesterbase(project, testdir, monkeypatch, network_name):
brownie.test.coverage.clear()
brownie.network.connect()
brownie.network.connect(network_name)
monkeypatch.setattr("brownie.network.connect", lambda k: None)
testdir.plugins.extend(["pytest-brownie", "pytest-cov"])
yield testdir
Expand All @@ -244,8 +259,8 @@ def plugintester(_project_factory, plugintesterbase, request):

# launches and connects to ganache, yields the brownie.network module
@pytest.fixture
def devnetwork(network, rpc, chain):
brownie.network.connect("development")
def devnetwork(network, rpc, chain, network_name):
brownie.network.connect(network_name)
yield brownie.network
if rpc.is_active():
chain.reset()
Expand Down
4 changes: 2 additions & 2 deletions tests/network/account/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
addr = "0x14b0Ed2a7C4cC60DD8F676AE44D0831d3c9b2a9E"


def test_repopulate(accounts, network, chain, rpc):
def test_repopulate(accounts, network, chain, rpc, network_name):
assert len(accounts) > 0
a = list(accounts)
chain.reset()
Expand All @@ -20,7 +20,7 @@ def test_repopulate(accounts, network, chain, rpc):
network.disconnect()
assert len(accounts) == 0
assert not rpc.is_active()
network.connect("development")
network.connect(network_name)
assert len(accounts) == len(a)


Expand Down
6 changes: 3 additions & 3 deletions tests/network/rpc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def original_port(xdist_id):


@pytest.fixture(scope="module")
def _no_rpc_setup(rpc, chain, web3, temp_port, original_port):
CONFIG.networks["development"]["cmd_settings"]["port"] = temp_port
def _no_rpc_setup(rpc, chain, web3, temp_port, original_port, network_name):
CONFIG.networks[network_name]["cmd_settings"]["port"] = temp_port
web3.connect(f"http://127.0.0.1:{temp_port}")
proc = rpc.process
reset_id = chain._reset_id
Expand All @@ -28,7 +28,7 @@ def _no_rpc_setup(rpc, chain, web3, temp_port, original_port):
# rpc.launch = _launch
_notify_registry(0)
yield
CONFIG.networks["development"]["cmd_settings"]["port"] = original_port
CONFIG.networks[network_name]["cmd_settings"]["port"] = original_port
web3.connect(f"http://127.0.0.1:{original_port}")
# rpc.launch = rpc._launch
rpc.kill(False)
Expand Down
Loading

0 comments on commit 6953d3f

Please sign in to comment.