diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml new file mode 100644 index 0000000..2e56f43 --- /dev/null +++ b/.github/workflows/codacy.yml @@ -0,0 +1,26 @@ +name: Codacy Coverage Reporter + +on: + workflow_run: + workflows: + - Build and Test + types: + - completed + +permissions: + contents: read + +jobs: + report-coverage: + runs-on: ubuntu-latest + steps: + - name: Download coverage report + uses: actions/download-artifact@v4 + with: + name: coverage-report + path: ./coverage + - name: Run codacy-coverage-reporter + uses: codacy/codacy-coverage-reporter-action@v1.3.0 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: ./coverage/coverage.cobertura.xml \ No newline at end of file diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 00987d7..3b50f57 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -41,11 +41,17 @@ jobs: run: dotnet build --no-restore - name: Run unit tests - run: dotnet test BTCPayServer.Plugins.Monero.UnitTests --verbosity normal + run: dotnet test BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=json /p:CoverletOutput=../coverage/coverage.json - name: Run integration tests run: docker compose -f BTCPayServer.Plugins.IntegrationTests/docker-compose.yml run tests - name: Cleanup Docker containers if: always() - run: docker compose -f BTCPayServer.Plugins.IntegrationTests/docker-compose.yml down -v \ No newline at end of file + run: docker compose -f BTCPayServer.Plugins.IntegrationTests/docker-compose.yml down -v + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/coverage.cobertura.xml \ No newline at end of file diff --git a/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj b/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj index 6a35ecb..288d75b 100644 --- a/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj +++ b/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj @@ -16,6 +16,14 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml b/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml index 4fa17f4..da87f8d 100644 --- a/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml +++ b/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml @@ -19,6 +19,8 @@ services: - xmr_wallet extra_hosts: - "tests:127.0.0.1" + volumes: + - ../coverage:/coverage # The dev container is not used, it is just handy to run `docker-compose up dev` to start all services dev: diff --git a/BTCPayServer.Plugins.IntegrationTests/docker-entrypoint.sh b/BTCPayServer.Plugins.IntegrationTests/docker-entrypoint.sh index 2547c2b..72b3db1 100755 --- a/BTCPayServer.Plugins.IntegrationTests/docker-entrypoint.sh +++ b/BTCPayServer.Plugins.IntegrationTests/docker-entrypoint.sh @@ -6,4 +6,4 @@ if [ ! -z "$TEST_FILTERS" ]; then FILTERS="--filter $TEST_FILTERS" fi -dotnet test -c ${CONFIGURATION_NAME} $FILTERS --no-build -v n --logger "console;verbosity=normal" < /dev/null +dotnet test -c ${CONFIGURATION_NAME} $FILTERS --no-build -v n --logger "console;verbosity=normal" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=/coverage/coverage.cobertura.xml /p:MergeWith=/coverage/coverage.json< /dev/null \ No newline at end of file diff --git a/BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj b/BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj index cac904c..602a640 100644 --- a/BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj +++ b/BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj @@ -6,9 +6,19 @@ enable false BTCPayServer.Plugins.Monero.UnitTests + $(MSBuildProjectDirectory)/coverage/ + true + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -23,10 +33,6 @@ - - true - - diff --git a/README.md b/README.md index 1b8d309..2f1479d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/btcpay-monero/btcpayserver-monero-plugin/dotnet.yml?branch=master) + [![Codacy Badge](https://app.codacy.com/project/badge/Grade/a86461725075418b95ae501256839500)](https://app.codacy.com/gh/btcpay-monero/btcpayserver-monero-plugin/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) + [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/a86461725075418b95ae501256839500)](https://app.codacy.com/gh/btcpay-monero/btcpayserver-monero-plugin/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) [![Matrix rooms](https://img.shields.io/badge/%F0%9F%92%AC%20Matrix-%23btcpay--monero-blue)](https://matrix.to/#/#btcpay-monero:matrix.org)
@@ -38,7 +40,20 @@ To build and run unit tests, run the following commands: dotnet build btcpay-monero-plugin.sln dotnet test BTCPayServer.Plugins.Monero.UnitTests --verbosity normal ``` -This will build the plugin and run the unit tests. +To run unit tests with coverage, run the following command: + +```bash +dotnet test BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=json /p:CoverletOutput=../coverage/coverage.json +``` + +To build and run integration tests, run the following commands: + +```bash +dotnet build btcpay-monero-plugin.sln +docker compose -f BTCPayServer.Plugins.IntegrationTests/docker-compose.yml run tests +``` + +**BTCPAY_XMR_CASHCOW_WALLET_DAEMON_URI** | **Optional**. The URI of the [monero-wallet-rpc](https://getmonero.dev/interacting/monero-wallet-rpc.html) interface for the cashcow wallet. This is used to create a second wallet for testing purposes in regtest mode. | http:// If you are a developer maintaining this plugin, in order to maintain this plugin, you need to clone this repository with `--recurse-submodules`: