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

add final coverage handling #11778

Merged
merged 40 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0c9d948
add final coverage handling
altendky Jun 3, 2022
238ec66
Merge branch 'main' into coverage
altendky Jun 20, 2022
73e5824
switch to development coverage
altendky Jun 20, 2022
dae06fc
correct url
altendky Jun 20, 2022
6345a35
only run one directory for now
altendky Jun 20, 2022
e259dd8
only 3.10
altendky Jun 20, 2022
ecb1312
delete windows data for now
altendky Aug 19, 2022
4132d41
drop the 35% failure point
altendky Aug 19, 2022
9419f6e
recover full test matrix
altendky Aug 19, 2022
54a749d
Use regular coverage
altendky Aug 19, 2022
e525fc7
Update test.yml
altendky Aug 19, 2022
0dea8f3
put coverage reporting into an artifact
altendky Aug 20, 2022
08af555
oops
altendky Aug 20, 2022
a5f347a
oopsy
altendky Aug 20, 2022
9b6c47f
Merge branch 'main' into coverage
altendky Aug 20, 2022
9bc9752
pytest-cov
altendky Aug 20, 2022
39fb1e4
maybe
altendky Aug 20, 2022
04ac63b
maybe help out flakes
altendky Aug 20, 2022
5303f8a
farm the spend bundle...
altendky Aug 20, 2022
2123de0
some more
altendky Aug 20, 2022
d0a7f72
more funds for the did test?
altendky Aug 21, 2022
4828d05
more...
altendky Aug 21, 2022
d505527
report chia/ and tests/ separately
altendky Aug 21, 2022
30008ad
job_timeout = 45 for core
altendky Aug 21, 2022
57a161c
tidy and disable diff-cover
altendky Aug 21, 2022
e39e6a8
remove job_timeout = 45
altendky Aug 22, 2022
50cab11
--rcfile=.coveragerc
altendky Aug 22, 2022
be90246
Update .github/workflows/test.yml
altendky Aug 22, 2022
a94426e
revert time and blocks
almogdepaz Aug 24, 2022
6695527
assert spend is in mempool, lower times and block count
almogdepaz Aug 25, 2022
ec6e142
remove sleep
almogdepaz Aug 25, 2022
4a76c85
lint
almogdepaz Aug 25, 2022
bd5cfa9
up timeout
almogdepaz Aug 25, 2022
3895e28
cat test - farm blocks until spend is included
almogdepaz Aug 25, 2022
70256fc
add spend check for nft endpoints
almogdepaz Aug 29, 2022
5456291
fix nft endpoint test
almogdepaz Aug 29, 2022
00ae5aa
remove unused code
almogdepaz Aug 29, 2022
7432e28
Merge pull request #13163 from Chia-Network/debug_test_flakes
altendky Aug 29, 2022
b3a29a0
Merge branch 'main' into coverage
altendky Sep 15, 2022
3d95eec
4
altendky Sep 15, 2022
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
15 changes: 7 additions & 8 deletions .github/workflows/test-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,21 @@ jobs:
env:
ENABLE_PYTEST_MONITOR: ${{ matrix.os.matrix == 'ubuntu' && matrix.configuration.enable_pytest_monitor || '' }}
run: |
coverage run --rcfile=.coveragerc --module pytest --durations=10 ${{ matrix.configuration.pytest_parallel_args[matrix.os.matrix] }} -m "not benchmark" ${{ env.ENABLE_PYTEST_MONITOR }} ${{ matrix.configuration.test_files }}
pytest --cov=chia --cov=tests --cov-config=.coveragerc --cov-report= --durations=10 ${{ matrix.configuration.pytest_parallel_args[matrix.os.matrix] }} -m "not benchmark" ${{ env.ENABLE_PYTEST_MONITOR }} ${{ matrix.configuration.test_files }}

- name: Process coverage data
run: |
coverage combine --rcfile=.coveragerc
coverage xml --rcfile=.coveragerc -o coverage.xml
mkdir coverage_reports
cp .coverage "coverage_reports/.coverage.${{ env.JOB_FILE_NAME }}"
cp coverage.xml "coverage_reports/coverage.${{ env.JOB_FILE_NAME }}.xml"
mkdir coverage-data
cp .coverage "coverage-data/.coverage.${{ env.JOB_FILE_NAME }}"
cp coverage.xml "coverage-data/coverage.${{ env.JOB_FILE_NAME }}.xml"
coverage report --rcfile=.coveragerc --show-missing

- name: Publish coverage
- name: Publish coverage data
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage_reports/*
name: coverage-data
path: coverage-data/*
if-no-files-found: error

- name: Check resource usage
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,77 @@ jobs:
concurrency_name: windows
configuration: ${{ needs.configure.outputs.configuration }}
runs-on: windows-latest

coverage:
name: Coverage
runs-on: ${{ matrix.os.runs-on }}
needs:
- macos
- ubuntu
- windows
strategy:
fail-fast: false
matrix:
os:
- emoji: 🐧
matrix: ubuntu
name: Ubuntu
runs-on: ubuntu-latest
python:
- name: '3.9'
action: '3.9'
apt: '3.9'
install_sh: '3.9'
matrix: '3.9'

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

- name: Download Coverage
uses: actions/download-artifact@v3
with:
name: coverage-data
path: coverage-data

- name: Set up ${{ matrix.python.name }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python.action }}

- uses: ./.github/actions/install
with:
python-version: ${{ matrix.python.action }}
development: true

- uses: chia-network/actions/activate-venv@main

- name: Coverage Processing
run: |
# skip windows until https://github.com/nedbat/coveragepy/issues/991 is resolved
rm coverage-data/*.tests_windows_* coverage-data/.*.tests_windows_*
coverage combine--rcfile=.coveragerc --data-file coverage-reports/.coverage coverage-data/
altendky marked this conversation as resolved.
Show resolved Hide resolved
coverage xml --rcfile=.coveragerc --data-file coverage-reports/.coverage -o coverage-reports/coverage.xml
coverage html --rcfile=.coveragerc --data-file coverage-reports/.coverage --directory coverage-reports/html/

- name: Coverage report (chia/)
run: |
coverage report --rcfile=.coveragerc --data-file coverage-reports/.coverage --include='chia/*' --show-missing | tee coverage-reports/coverage-chia-stdout

- name: Coverage report (tests/)
run: |
coverage report --rcfile=.coveragerc --data-file coverage-reports/.coverage --include='tests/*' --show-missing | tee coverage-reports/coverage-tests-stdout

# needs some debugging since it just reports no changes
# - name: Coverage report (diff)
# run: |
# diff-cover --compare-branch=${{ fromJSON(format('[{0}, {1}]', toJSON(github.event.before), toJSON(format('origin/{0}', github.base_ref))))[github.base_ref != ''] }} coverage-reports/coverage.xml | tee coverage-reports/diff-cover-stdout

- name: Publish coverage reports
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-reports
path: coverage-reports/*
if-no-files-found: error
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
dev_dependencies = [
"build",
"coverage",
"diff-cover",
"pre-commit",
"py3createtorrent",
"pylint",
"pytest",
"pytest-asyncio>=0.18.1", # require attribute 'fixture'
"pytest-cov",
"pytest-monitor; sys_platform == 'linux'",
"pytest-xdist",
"twine",
Expand Down
26 changes: 16 additions & 10 deletions tests/wallet/rpc/test_wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,10 @@ async def test_cat_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
assert name == next(iter(DEFAULT_CATS.items()))[1]["name"]

# TODO: Investigate why farming only one block here makes it flaky
await farm_transaction_block(full_node_api, wallet_node)
await farm_transaction_block(full_node_api, wallet_node)
for _ in range(5):
await farm_transaction_block(full_node_api, wallet_node)

await time_out_assert(15, wallet_is_synced, True, wallet_node, full_node_api)
await time_out_assert(20, get_confirmed_balance, 20, client, cat_0_id)
bal_0 = await client.get_wallet_balance(cat_0_id)
assert bal_0["pending_coin_removal_count"] == 0
Expand Down Expand Up @@ -634,12 +635,13 @@ async def test_offer_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment)

# Creates a CAT wallet with 20 mojos
res = await wallet_1_rpc.create_new_cat_and_wallet(uint64(20))
assert res["success"]
cat_wallet_id = res["wallet_id"]
cat_asset_id = bytes32.fromhex(res["asset_id"])
# TODO: Investigate why farming only two blocks here makes it flaky
await farm_transaction_block(full_node_api, wallet_node)
await farm_transaction_block(full_node_api, wallet_node)
await farm_transaction_block(full_node_api, wallet_node)
for _ in range(5):
await farm_transaction_block(full_node_api, wallet_node)
await time_out_assert(15, wallet_is_synced, True, wallet_node, full_node_api)
await time_out_assert(20, get_confirmed_balance, 20, wallet_1_rpc, cat_wallet_id)

# Creates a wallet for the same CAT on wallet_2 and send 4 CAT from wallet_1 to it
Expand Down Expand Up @@ -755,7 +757,7 @@ async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
full_node_api: FullNodeSimulator = env.full_node.api
wallet_1_id = wallet_1.id()

await generate_funds(env.full_node.api, env.wallet_1, 5)
await generate_funds(env.full_node.api, env.wallet_1, 10)

# Create a DID wallet
res = await wallet_1_rpc.create_new_did_wallet(amount=1, name="Profile 1")
Expand Down Expand Up @@ -788,8 +790,11 @@ async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
res = await wallet_1_rpc.create_did_backup_file(did_wallet_id_0, "backup.did")
assert res["success"]

for _ in range(3):
for _ in range(20):
await farm_transaction_block(full_node_api, wallet_1_node)
import asyncio

await asyncio.sleep(0.5)

# Update recovery list
res = await wallet_1_rpc.update_did_recovery_list(did_wallet_id_0, [did_id_0], 1)
Expand Down Expand Up @@ -868,16 +873,17 @@ async def test_nft_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
)
assert res["success"]

for _ in range(3):
await farm_transaction_block(full_node_api, wallet_1_node)
spend_bundle = SpendBundle.from_json_dict(json_dict=res["spend_bundle"])

await farm_transaction(full_node_api, wallet_1_node, spend_bundle)
almogdepaz marked this conversation as resolved.
Show resolved Hide resolved

await time_out_assert(15, wallet_is_synced, True, wallet_1_node, full_node_api)
nft_wallet: NFTWallet = wallet_1_node.wallet_state_manager.wallets[nft_wallet_id]

def have_nfts():
return len(nft_wallet.get_current_nfts()) > 0

await time_out_assert(15, have_nfts, True)
await time_out_assert(30, have_nfts, True)

# Test with the hex version of nft_id
nft_id = nft_wallet.get_current_nfts()[0].coin.name().hex()
Expand Down