Skip to content

Commit

Permalink
add final coverage handling (#11778)
Browse files Browse the repository at this point in the history
* add final coverage handling

* switch to development coverage

* correct url

* only run one directory for now

* only 3.10

* delete windows data for now

* drop the 35% failure point

* recover full test matrix

* Use regular coverage

* Update test.yml

* put coverage reporting into an artifact

* oops

* oopsy

* pytest-cov

* maybe

* maybe help out flakes

* farm the spend bundle...

* some more

* more funds for the did test?

* more...

* report chia/ and tests/ separately

* job_timeout = 45 for core

* tidy and disable diff-cover

* remove job_timeout = 45

* --rcfile=.coveragerc

* Update .github/workflows/test.yml

* revert time and blocks

* assert spend is in mempool, lower times and block count

* remove sleep

* lint

* up timeout

* cat test - farm blocks until spend is included

* add spend check for nft endpoints

* fix nft endpoint test

* remove unused code

* 4

Co-authored-by: almog <almogdepaz@gmail.com>
  • Loading branch information
altendky and almogdepaz committed Sep 16, 2022
1 parent cf8fcf9 commit a9cce0f
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 11 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/test-single.yml
Expand Up @@ -197,22 +197,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
Expand Up @@ -74,3 +74,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/
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
Expand Up @@ -45,11 +45,13 @@
"astroid!=2.12.6, !=2.12.7",
"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
2 changes: 1 addition & 1 deletion tests/core/data_layer/config.py
@@ -1,3 +1,3 @@
parallel = True
parallel = 4
job_timeout = 30
checkout_blocks_and_plots = True
6 changes: 4 additions & 2 deletions tests/wallet/rpc/test_wallet_rpc.py
Expand Up @@ -647,6 +647,7 @@ 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"])
await time_out_assert(5, check_mempool_spend_count, True, full_node_api, 1)
Expand Down Expand Up @@ -892,8 +893,9 @@ 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)

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

0 comments on commit a9cce0f

Please sign in to comment.