Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Codacy Coverage Reporter

on:
workflow_run:
workflows:
- Tests
types:
- completed
workflow_dispatch:

permissions:
contents: read

jobs:
report-coverage:
if: github.repository == 'everoddandeven/monero-python'
runs-on: ubuntu-latest
steps:
- name: Download coverage report
uses: actions/download-artifact@v5
with:
name: coverage-report
github-token: ${{ secrets.API_GITHUB }}
run-id: ${{ github.event.workflow_run.id }}

- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.info
23 changes: 21 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl autoconf libtool gperf nettle-dev libevent-dev debhelper python3-all python3-pip python3-pybind11 python3-pytest python3-pytest-rerunfailures
sudo apt install -y build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl autoconf libtool gperf nettle-dev libevent-dev debhelper python3-all python3-pip python3-pybind11 python3-pytest python3-pytest-rerunfailures lcov
pip3 install pybind11-stubgen pytest --break-system-packages

- name: Install expat
Expand Down Expand Up @@ -106,12 +106,19 @@ jobs:
- name: Install monero-python
run: |
mkdir -p build
pip3 install -vvv .
export CFLAGS="--coverage -O0 -g"
export CXXFLAGS="--coverage -O0 -g"
export LDFLAGS="--coverage"
COVERAGE=1 pip3 install -vvv .

- name: Setup test environment
run: |
docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2

- name: Reset coverage counters
run: |
lcov --directory . --zerocounters

- name: Run tests
env:
IN_CONTAINER: "true"
Expand All @@ -121,3 +128,15 @@ jobs:
- name: Cleanup test environment
if: always()
run: docker compose -f tests/docker-compose.yml down -v

- name: Generate coverage report
run: |
lcov --capture --directory . --ignore-errors mismatch,mismatch,inconsistent,source,source,gcov,gcov --output-file coverage_full.info
lcov --ignore-errors unused,unused --remove coverage_full.info '/usr/*' '*/external/*' '*/pybind11/*' '*monero-cpp/*' '*monero-project/*' --output-file coverage.info

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.info

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ test_wallets
.github/instructions/codacy.instructions.md
.idea
.codacy
coverage*
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import pybind11
import sys
import os

from setuptools import setup
from pathlib import Path
from pybind11.setup_helpers import Pybind11Extension, build_ext

coverage = os.environ.get("COVERAGE") == "1"
this_dir = Path(__file__).parent.resolve()
extra_compile_args = ['/std:c++17'] if sys.platform == "win32" else ['-std=c++17']
extra_link_args = []

if coverage:
extra_compile_args += ['-O0', '-g', '--coverage']
extra_link_args += ['--coverage']

ext_modules = [
Pybind11Extension(
Expand Down Expand Up @@ -39,7 +47,8 @@
],
libraries=['monero-cpp'],
language='c++',
extra_compile_args=['/std:c++17'] if sys.platform == "win32" else ['-std=c++17'],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
),
]

Expand Down