Skip to content

Commit 613e645

Browse files
authored
ci: first setup
* Add CI and PR validation workflows for automated testing and linting * Update GitHub Actions to use latest checkout and setup-dotnet actions * Make spent_outputs parameter nullable in NativeMethods * Refactor PR validation workflow to improve formatting check and remove PR title validation step * Refactor CI workflow to enhance test result handling and improve security scan output * Fix artifact naming in CI workflow to include OS in test results * Update test project dependencies to latest versions to resolve security issues.
1 parent e796b58 commit 613e645

5 files changed

Lines changed: 128 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-test:
11+
name: Build and Test
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest]
16+
dotnet-version: ['9.0.x']
17+
fail-fast: false
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v5
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v5
25+
with:
26+
dotnet-version: ${{ matrix.dotnet-version }}
27+
28+
- name: Restore dependencies
29+
run: dotnet restore
30+
31+
- name: Build
32+
run: dotnet build --configuration Release --no-restore
33+
34+
- name: Test with dotnet
35+
run: dotnet test --no-restore --logger trx --results-directory "TestResults-${{ matrix.dotnet-version }}"
36+
37+
- name: Upload dotnet test results
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: dotnet-results--${{ matrix.os }}
41+
path: TestResults--${{ matrix.os }}
42+
if: ${{ always() }}
43+
44+
lint:
45+
name: Lint/Format Check
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v5
51+
52+
- name: Setup .NET
53+
uses: actions/setup-dotnet@v5
54+
with:
55+
dotnet-version: '9.0.x'
56+
57+
- name: Restore dependencies
58+
run: dotnet restore
59+
60+
- name: Check formatting
61+
run: dotnet format --verify-no-changes --verbosity diagnostic
62+
63+
security:
64+
name: Security Scan
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v5
70+
71+
- name: Setup .NET
72+
uses: actions/setup-dotnet@v5
73+
with:
74+
dotnet-version: '9.0.x'
75+
76+
- name: Restore dependencies
77+
run: dotnet restore
78+
79+
- name: Checking for external vulnerabilites
80+
run: |
81+
dotnet list package --vulnerable --include-transitive 2>&1 | tee vuln.log
82+
echo "Analyze dotnet list package..."
83+
! grep -q -i "has the following vulnerable packages" vuln.log
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
validate:
9+
name: Validate PR
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v5
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v5
20+
with:
21+
dotnet-version: '9.0.x'
22+
23+
- name: Restore dependencies
24+
run: dotnet restore
25+
26+
- name: Build
27+
run: dotnet build --configuration Debug --no-restore
28+
29+
- name: Check for compilation warnings
30+
run: dotnet build --configuration Release --no-restore --warnaserror
31+
32+
- name: Run tests
33+
run: dotnet test --configuration Release --no-build --verbosity normal
34+
35+
- name: Check formatting
36+
run: dotnet format style --no-restore --verify-no-changes

src/BitcoinKernel.Interop/NativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public static extern int ScriptPubkeyVerify(
427427
IntPtr script_pubkey,
428428
long amount,
429429
IntPtr tx_to,
430-
IntPtr[] spent_outputs,
430+
IntPtr[]? spent_outputs,
431431
nuint spent_outputs_len,
432432
uint input_index,
433433
uint flags,

tests/BitcoinKernel.Core.Tests/BitcoinKernel.Core.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="coverlet.collector" Version="6.0.0" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
16-
<PackageReference Include="xunit" Version="2.5.3" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
14+
<PackageReference Include="coverlet.collector" Version="6.0.4" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
16+
<PackageReference Include="xunit" Version="2.9.3" />
17+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

tests/BitcoinKernel.Tests/BitcoinKernel.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="coverlet.collector" Version="6.0.0" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
16-
<PackageReference Include="xunit" Version="2.5.3" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
14+
<PackageReference Include="coverlet.collector" Version="6.0.4" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
16+
<PackageReference Include="xunit" Version="2.9.3" />
17+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

0 commit comments

Comments
 (0)