From 517d1193fa5565fb39f0908a4bc6ca77501fb251 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 16 Nov 2025 16:06:19 +0100 Subject: [PATCH 1/7] Add CI and PR validation workflows for automated testing and linting --- .github/workflows/ci.yml | 83 +++++++++++++++++++++++++++++ .github/workflows/pr-validation.yml | 53 ++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pr-validation.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..13ff314 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-test: + name: Build and Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + dotnet-version: ['9.0.x'] + fail-fast: false + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ matrix.dotnet-version }} + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Run tests + run: dotnet test --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" + + - name: Upload test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: test-results-${{ matrix.os }} + path: '**/TestResults/*.trx' + + lint: + name: Lint and Format Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Check formatting + run: dotnet format --verify-no-changes --verbosity diagnostic + + - name: Run code analysis + run: dotnet build --configuration Release /p:TreatWarningsAsErrors=false + + security: + name: Security Scan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Check for vulnerable packages + run: dotnet list package --vulnerable --include-transitive diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml new file mode 100644 index 0000000..ab02257 --- /dev/null +++ b/.github/workflows/pr-validation.yml @@ -0,0 +1,53 @@ +name: PR Validation + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + validate: + name: Validate PR + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Debug --no-restore + + - name: Check for compilation warnings + run: dotnet build --configuration Release --no-restore --warnaserror + + - name: Run tests + run: dotnet test --configuration Release --no-build --verbosity normal + + - name: Check formatting + run: dotnet format --verify-no-changes || echo "Code formatting issues detected. Run 'dotnet format' locally." + + - name: PR title validation + uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + feat + fix + docs + style + refactor + perf + test + build + ci + chore From 7566746b0bf82266a01245986067f7112171dc17 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 16 Nov 2025 16:20:25 +0100 Subject: [PATCH 2/7] Update GitHub Actions to use latest checkout and setup-dotnet actions --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/pr-validation.yml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13ff314..422b007 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: ${{ matrix.dotnet-version }} @@ -47,10 +47,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: '9.0.x' @@ -69,10 +69,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: '9.0.x' diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index ab02257..99a1a9b 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -11,12 +11,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: '9.0.x' From c40f16d5cd7c95f0057b8a92b81393026196663d Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 Nov 2025 12:44:12 +0100 Subject: [PATCH 3/7] Make spent_outputs parameter nullable in NativeMethods --- src/BitcoinKernel.Interop/NativeMethods.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BitcoinKernel.Interop/NativeMethods.cs b/src/BitcoinKernel.Interop/NativeMethods.cs index 20e8601..744d767 100644 --- a/src/BitcoinKernel.Interop/NativeMethods.cs +++ b/src/BitcoinKernel.Interop/NativeMethods.cs @@ -427,7 +427,7 @@ public static extern int ScriptPubkeyVerify( IntPtr script_pubkey, long amount, IntPtr tx_to, - IntPtr[] spent_outputs, + IntPtr[]? spent_outputs, nuint spent_outputs_len, uint input_index, uint flags, From 08067d23e5b3e498d3aa34ff7d6cae7594eeb62f Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 Nov 2025 12:57:16 +0100 Subject: [PATCH 4/7] Refactor PR validation workflow to improve formatting check and remove PR title validation step --- .github/workflows/pr-validation.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 99a1a9b..3d04bff 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -33,21 +33,4 @@ jobs: run: dotnet test --configuration Release --no-build --verbosity normal - name: Check formatting - run: dotnet format --verify-no-changes || echo "Code formatting issues detected. Run 'dotnet format' locally." - - - name: PR title validation - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - types: | - feat - fix - docs - style - refactor - perf - test - build - ci - chore + run: dotnet format style --no-restore --verify-no-changes From 4b2d3d5db678fdc734c50dff7d95a09f5d1035cb Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 Nov 2025 13:17:04 +0100 Subject: [PATCH 5/7] Refactor CI workflow to enhance test result handling and improve security scan output --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 422b007..cc9a21f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,18 +31,18 @@ jobs: - name: Build run: dotnet build --configuration Release --no-restore - - name: Run tests - run: dotnet test --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" + - name: Test with dotnet + run: dotnet test --no-restore --logger trx --results-directory "TestResults-${{ matrix.dotnet-version }}" - - name: Upload test results + - name: Upload dotnet test results uses: actions/upload-artifact@v4 - if: always() with: - name: test-results-${{ matrix.os }} - path: '**/TestResults/*.trx' + name: dotnet-results-${{ matrix.dotnet-version }} + path: TestResults-${{ matrix.dotnet-version }} + if: ${{ always() }} lint: - name: Lint and Format Check + name: Lint/Format Check runs-on: ubuntu-latest steps: @@ -60,9 +60,6 @@ jobs: - name: Check formatting run: dotnet format --verify-no-changes --verbosity diagnostic - - name: Run code analysis - run: dotnet build --configuration Release /p:TreatWarningsAsErrors=false - security: name: Security Scan runs-on: ubuntu-latest @@ -79,5 +76,8 @@ jobs: - name: Restore dependencies run: dotnet restore - - name: Check for vulnerable packages - run: dotnet list package --vulnerable --include-transitive + - name: Checking for external vulnerabilites + run: | + dotnet list package --vulnerable --include-transitive 2>&1 | tee vuln.log + echo "Analyze dotnet list package..." + ! grep -q -i "has the following vulnerable packages" vuln.log From 5d40e0c72ff727a706160ac9ef82e47864fea0a5 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 Nov 2025 13:22:05 +0100 Subject: [PATCH 6/7] Fix artifact naming in CI workflow to include OS in test results --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc9a21f..f7dabfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,8 @@ jobs: - name: Upload dotnet test results uses: actions/upload-artifact@v4 with: - name: dotnet-results-${{ matrix.dotnet-version }} - path: TestResults-${{ matrix.dotnet-version }} + name: dotnet-results--${{ matrix.os }} + path: TestResults--${{ matrix.os }} if: ${{ always() }} lint: From 2beab4f989e042ff7c1be4a49260aeb29329f355 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 Nov 2025 13:34:29 +0100 Subject: [PATCH 7/7] Update test project dependencies to latest versions to resolve security issues. --- .../BitcoinKernel.Core.Tests.csproj | 8 ++++---- tests/BitcoinKernel.Tests/BitcoinKernel.Tests.csproj | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/BitcoinKernel.Core.Tests/BitcoinKernel.Core.Tests.csproj b/tests/BitcoinKernel.Core.Tests/BitcoinKernel.Core.Tests.csproj index 9a568f4..11925a3 100644 --- a/tests/BitcoinKernel.Core.Tests/BitcoinKernel.Core.Tests.csproj +++ b/tests/BitcoinKernel.Core.Tests/BitcoinKernel.Core.Tests.csproj @@ -11,10 +11,10 @@ - - - - + + + + diff --git a/tests/BitcoinKernel.Tests/BitcoinKernel.Tests.csproj b/tests/BitcoinKernel.Tests/BitcoinKernel.Tests.csproj index aae6995..f48e5a5 100644 --- a/tests/BitcoinKernel.Tests/BitcoinKernel.Tests.csproj +++ b/tests/BitcoinKernel.Tests/BitcoinKernel.Tests.csproj @@ -11,10 +11,10 @@ - - - - + + + +