Skip to content

Commit 8bb0b22

Browse files
authored
Merge pull request #3 from KeetaNetwork/fix/naming-alignment
Chore: Better Align Project to TS Naming
2 parents 1e3f74a + 42be529 commit 8bb0b22

48 files changed

Lines changed: 1064 additions & 596 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 33 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
pull_request:
77
branches: [main]
88

9-
env:
10-
RUST_TOOLCHAIN: "1.94.0"
11-
129
jobs:
1310
build-test:
1411
name: Build & Test (${{ matrix.os }})
@@ -22,17 +19,17 @@ jobs:
2219
runs-on: ${{ matrix.os }}
2320
steps:
2421
- uses: actions/checkout@v4
22+
with:
23+
# SonarCloud needs the parent branch information.
24+
fetch-depth: 0
2525

2626
- name: Set up .NET
2727
uses: actions/setup-dotnet@v4
2828
with:
2929
global-json-file: global.json
3030

3131
- name: Set up Rust
32-
uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
33-
with:
34-
toolchain: "1.94.0"
35-
targets: wasm32-wasip1
32+
uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1
3633

3734
- name: Cache wasm build
3835
uses: actions/cache@v4
@@ -41,7 +38,7 @@ jobs:
4138
~/.cargo/registry
4239
~/.cargo/git
4340
.wasm-build
44-
key: wasm-${{ runner.os }}-${{ hashFiles('scripts/build-wasm.sh') }}
41+
key: wasm-${{ runner.os }}-${{ hashFiles('scripts/build-wasm.sh', 'rust-toolchain.toml') }}
4542

4643
- name: Set up Node.js
4744
uses: actions/setup-node@v4
@@ -56,7 +53,7 @@ jobs:
5653

5754
- name: Build node harness
5855
shell: bash
59-
run: npm ci && npm run build
56+
run: npm ci --ignore-scripts && npm rebuild sqlite3 && npm run build
6057
working-directory: tests/node-harness
6158
env:
6259
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -68,7 +65,29 @@ jobs:
6865
run: dotnet build KeetaNet.Anchor.slnx -c Release --no-restore
6966

7067
- name: Test
71-
run: dotnet test KeetaNet.Anchor.slnx -c Release --no-build
68+
run: >
69+
dotnet test KeetaNet.Anchor.slnx -c Release --no-build
70+
-- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
71+
72+
# Run SonarCloud on the coverage this test run
73+
- name: Convert coverage to SonarQube format
74+
if: matrix.os == 'ubuntu-latest-l' && github.repository == 'KeetaNetwork/anchor-csharp'
75+
run: |
76+
dotnet tool install --global dotnet-reportgenerator-globaltool
77+
reportgenerator \
78+
"-reports:**/TestResults/**/coverage.cobertura.xml" \
79+
"-targetdir:.sonar-coverage" \
80+
"-reporttypes:SonarQube"
81+
82+
- name: SonarCloud Scan
83+
if: matrix.os == 'ubuntu-latest-l' && github.repository == 'KeetaNetwork/anchor-csharp'
84+
uses: SonarSource/sonarqube-scan-action@689fb39b34b9aa95ebc5f8f119343ddd51542402 # v4.2.2
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
88+
with:
89+
args: >
90+
-Dproject.settings=./sonar-project.properties
7291
7392
lint:
7493
name: Lint
@@ -92,7 +111,7 @@ jobs:
92111
scope: "@keetanetwork"
93112

94113
- name: Check formatting and linting
95-
run: make lint
114+
run: make do-lint-ci
96115
env:
97116
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98117

@@ -108,10 +127,7 @@ jobs:
108127
global-json-file: global.json
109128

110129
- name: Set up Rust
111-
uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
112-
with:
113-
toolchain: "1.94.0"
114-
targets: wasm32-wasip1
130+
uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1
115131

116132
- name: Cache wasm build
117133
uses: actions/cache@v4
@@ -120,13 +136,13 @@ jobs:
120136
~/.cargo/registry
121137
~/.cargo/git
122138
.wasm-build
123-
key: wasm-${{ runner.os }}-${{ hashFiles('scripts/build-wasm.sh') }}
139+
key: wasm-${{ runner.os }}-${{ hashFiles('scripts/build-wasm.sh', 'rust-toolchain.toml') }}
124140

125141
- name: Build wasm core
126142
run: bash scripts/build-wasm.sh
127143

128144
- name: Pack
129-
run: dotnet pack src/KeetaNet.Anchor/KeetaNet.Anchor.csproj -c Release -o artifacts
145+
run: dotnet pack KeetaNet.Anchor.slnx -c Release -o artifacts
130146

131147
- name: Upload package
132148
uses: actions/upload-artifact@v4
@@ -155,57 +171,3 @@ jobs:
155171
echo "::error::Vulnerable packages found"
156172
exit 1
157173
fi
158-
159-
sonar:
160-
name: SonarCloud
161-
runs-on: ubuntu-latest-l
162-
if: github.repository == 'KeetaNetwork/anchor-csharp'
163-
steps:
164-
- uses: actions/checkout@v4
165-
with:
166-
fetch-depth: 0
167-
168-
- name: Set up .NET
169-
uses: actions/setup-dotnet@v4
170-
with:
171-
global-json-file: global.json
172-
173-
- name: Set up Rust
174-
uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
175-
with:
176-
toolchain: "1.94.0"
177-
targets: wasm32-wasip1
178-
179-
- name: Cache wasm build
180-
uses: actions/cache@v4
181-
with:
182-
path: |
183-
~/.cargo/registry
184-
~/.cargo/git
185-
.wasm-build
186-
key: wasm-${{ runner.os }}-${{ hashFiles('scripts/build-wasm.sh') }}
187-
188-
- name: Build wasm core
189-
run: bash scripts/build-wasm.sh
190-
191-
- name: Test with coverage
192-
run: >
193-
dotnet test tests/KeetaNet.Anchor.Tests/KeetaNet.Anchor.Tests.csproj -c Release
194-
-- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
195-
196-
- name: Convert coverage to SonarQube format
197-
run: |
198-
dotnet tool install --global dotnet-reportgenerator-globaltool
199-
reportgenerator \
200-
"-reports:**/TestResults/**/coverage.cobertura.xml" \
201-
"-targetdir:.sonar-coverage" \
202-
"-reporttypes:SonarQube"
203-
204-
- name: SonarCloud Scan
205-
uses: SonarSource/sonarqube-scan-action@689fb39b34b9aa95ebc5f8f119343ddd51542402 # v4.2.2
206-
env:
207-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
208-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
209-
with:
210-
args: >
211-
-Dproject.settings=./sonar-project.properties

.github/workflows/publish.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ jobs:
2424
global-json-file: global.json
2525

2626
- name: Set up Rust
27-
uses: dtolnay/rust-toolchain@stable
28-
with:
29-
toolchain: "1.94.0"
30-
targets: wasm32-wasip1
27+
uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1
3128

3229
- name: Build wasm core
3330
run: bash scripts/build-wasm.sh
@@ -41,7 +38,7 @@ jobs:
4138
4239
- name: Pack
4340
run: >
44-
dotnet pack src/KeetaNet.Anchor/KeetaNet.Anchor.csproj -c Release -o artifacts
41+
dotnet pack KeetaNet.Anchor.slnx -c Release -o artifacts
4542
${{ startsWith(github.ref, 'refs/tags/releases/v') && format('-p:Version={0}', steps.version.outputs.value) || '' }}
4643
4744
- name: Attest build provenance
@@ -50,8 +47,10 @@ jobs:
5047
subject-path: "artifacts/*.nupkg"
5148

5249
- name: Push
50+
env:
51+
NUGET_API_KEY: ${{ secrets.GITHUB_TOKEN }}
5352
run: >
5453
dotnet nuget push "artifacts/*.nupkg"
5554
--source "https://nuget.pkg.github.com/KeetaNetwork/index.json"
56-
--api-key "${{ secrets.GITHUB_TOKEN }}"
55+
--api-key "$NUGET_API_KEY"
5756
--skip-duplicate

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
1. Install the .NET SDK matching [`global.json`](global.json) and Rust with the `wasm32-wasip1` target (`rustup target add wasm32-wasip1`).
66
2. Run `make developer` to restore, build, and test. The first build runs `make wasm` to produce the embedded wasm core from the pinned crates.io release.
77
3. Make changes. Use hard tabs for indentation (spaces only where the format requires them, ex. YAML).
8-
4. Run `make lint` and `make test` before opening a pull request.
8+
4. Run `make do-lint` and `make test` before opening a pull request.
99

1010
Always drive tasks through the `Makefile`, never raw `dotnet`.
1111

Directory.Packages.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
<ItemGroup>
99
<PackageVersion Include="Wasmtime" Version="44.0.0" />
10+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2" />
1011
</ItemGroup>
1112

1213
<ItemGroup Label="Test">
1314
<PackageVersion Include="xunit.v3" Version="3.2.2" />
15+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
1416
<!--
1517
Must stay on the Microsoft.Testing.Platform 1.x line: xunit.v3 stable
1618
ships an MTP v1 adapter (xunit.v3.core.mtp-v1 -> MTP 1.9.1), and the

KeetaNet.Anchor.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Solution>
22
<Folder Name="/src/">
33
<Project Path="src/KeetaNet.Anchor/KeetaNet.Anchor.csproj" />
4+
<Project Path="src/KeetaNet.Anchor.Extensions.DependencyInjection/KeetaNet.Anchor.Extensions.DependencyInjection.csproj" />
45
</Folder>
56
<Folder Name="/tests/">
67
<Project Path="tests/KeetaNet.Anchor.Tests/KeetaNet.Anchor.Tests.csproj" />

Makefile

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
.PHONY: help developer restore build rebuild format lint test coverage pack clean wasm node-harness release
1+
.PHONY: help developer restore build rebuild do-lint do-lint-ci test pack clean wasm node-harness release
22

33
# Build configuration (Debug or Release)
44
CONFIG ?= Release
55

66
# Solution under build
77
SLN := KeetaNet.Anchor.slnx
88

9-
# Unit test project
10-
UNIT_TESTS := tests/KeetaNet.Anchor.Tests/KeetaNet.Anchor.Tests.csproj
11-
129
# TypeScript interop harness (reference anchor + in-memory test node)
1310
HARNESS_DIR := tests/node-harness
1411
HARNESS_SOURCES := $(wildcard $(HARNESS_DIR)/src/*.ts)
@@ -32,38 +29,37 @@ build: restore $(WASM_DEST)
3229
# Clean then build
3330
rebuild: clean build
3431

35-
# Apply formatting fixes
36-
format:
32+
# Lint code (applies formatting fixes; C# + the TypeScript harness, one command)
33+
do-lint: node-harness
3734
dotnet format $(SLN)
35+
npx --yes cspell --config cspell.yaml --no-progress "src/**/*.cs" "tests/**/*.cs" "tests/node-harness/src/**" "scripts/**" "Makefile" "*.md"
36+
cd $(HARNESS_DIR) && npm run lint
3837

39-
# Verify formatting, spelling, and the harness lint without writing changes
40-
lint: node-harness
38+
# Lint code for CI (check only, no fixes)
39+
do-lint-ci: node-harness
4140
dotnet format $(SLN) --verify-no-changes
4241
npx --yes cspell --config cspell.yaml --no-progress "src/**/*.cs" "tests/**/*.cs" "tests/node-harness/src/**" "scripts/**" "Makefile" "*.md"
4342
cd $(HARNESS_DIR) && npm run lint
4443

45-
# Run all tests: unit + e2e against the live TypeScript reference anchor
44+
# Run all tests (unit + e2e against the live TypeScript reference anchor)
45+
# with code coverage (cobertura, for SonarCloud conversion)
4646
test: build node-harness
47-
dotnet test $(SLN) -c $(CONFIG) --no-build
47+
dotnet test $(SLN) -c $(CONFIG) --no-build \
48+
-- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
4849

4950
# Build the TypeScript harnesses (installs deps + compiles every entry)
5051
$(HARNESS_DIR)/node_modules/.package-lock.json: $(HARNESS_DIR)/package-lock.json
51-
cd $(HARNESS_DIR) && npm ci
52+
cd $(HARNESS_DIR) && npm ci --ignore-scripts && npm rebuild sqlite3
5253

5354
$(HARNESS_DIR)/dist/.built: $(HARNESS_DIR)/node_modules/.package-lock.json $(HARNESS_SOURCES)
5455
cd $(HARNESS_DIR) && npm run build
5556
touch $@
5657

5758
node-harness: $(HARNESS_DIR)/dist/.built
5859

59-
# Run unit tests with code coverage (cobertura, for SonarCloud conversion)
60-
coverage: build
61-
dotnet test $(UNIT_TESTS) -c $(CONFIG) --no-build \
62-
-- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
63-
64-
# Produce the NuGet package (.nupkg + .snupkg)
60+
# Produce the NuGet packages (.nupkg + .snupkg)
6561
pack: build
66-
dotnet pack src/KeetaNet.Anchor/KeetaNet.Anchor.csproj -c Release --no-build -o $(ARTIFACTS)
62+
dotnet pack $(SLN) -c Release --no-build -o $(ARTIFACTS)
6763

6864
# Build the P1 wasm core from the pinned crates.io release
6965
wasm:
@@ -102,14 +98,15 @@ help:
10298
@echo " make restore - Restore NuGet dependencies"
10399
@echo " make build - Build the solution (CONFIG=$(CONFIG))"
104100
@echo " make rebuild - Clean then build"
105-
@echo " make test - Run all tests (builds node-harness; unit + e2e)"
101+
@echo " make test - Run all tests with coverage (builds node-harness; unit + e2e)"
106102
@echo " make node-harness - Install + build the TypeScript interop harnesses"
107-
@echo " make coverage - Run unit tests with code coverage"
108-
@echo " make format - Apply formatting fixes"
109-
@echo " make lint - Verify formatting + spelling"
110-
@echo " make pack - Produce the NuGet package into $(ARTIFACTS)/"
103+
@echo " make do-lint - Lint code with formatting fixes (C# + harness + spelling)"
104+
@echo " make pack - Produce the NuGet packages into $(ARTIFACTS)/"
111105
@echo " make wasm - Build the P1 wasm core from the pinned crates.io release"
112106
@echo " make clean - Remove build outputs"
113107
@echo ""
108+
@echo "CI Commands:"
109+
@echo " make do-lint-ci - Lint code for CI (check only, no fixes)"
110+
@echo ""
114111
@echo "Release commands:"
115112
@echo " make release vX.Y.Z - Create a signed releases/vX.Y.Z tag"

0 commit comments

Comments
 (0)