Skip to content
Open
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
112 changes: 112 additions & 0 deletions .github/workflows/cross-port-interop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ on:
paths:
- 'reference/PCF-SIG-v1.0/**'
- 'implementations/**/pcf-sig/**'
- 'reference/PCF-DCP-v1.0/**'
- 'implementations/**/pcf-dcp/**'
- 'implementations/ts/package.json'
- 'implementations/ts/package-lock.json'
- 'implementations/dotnet/Directory.Build.props'
Expand All @@ -25,6 +27,8 @@ on:
paths:
- 'reference/PCF-SIG-v1.0/**'
- 'implementations/**/pcf-sig/**'
- 'reference/PCF-DCP-v1.0/**'
- 'implementations/**/pcf-dcp/**'
- 'implementations/ts/package.json'
- 'implementations/ts/package-lock.json'
- 'implementations/dotnet/Directory.Build.props'
Expand Down Expand Up @@ -169,3 +173,111 @@ jobs:
/tmp/ts.bin
/tmp/php.bin
/tmp/dotnet.bin

cross-port-byte-exact-dcp:
name: all DCP writers produce identical bytes
runs-on: ubuntu-latest
# Expected SHA-256 of the canonical 700-byte DCP vector (spec Section 17).
env:
EXPECTED_SHA256: b9bb59794abed008863063886d8d0daa810c44939c1c5d29449475ced8156b90
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: implementations/ts/package-lock.json

- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: hash, mbstring
coverage: none
tools: composer:v2

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

# ---- Rust reference writer --------------------------------------------
- name: Generate Rust reference vector
run: cargo run -p pcf-dcp --example gen_testvector -- /tmp/rust.bin

# ---- TypeScript writer ------------------------------------------------
- name: Install npm deps and build pcf
working-directory: implementations/ts
run: |
npm ci
npm run build -w @kduma-oss/pcf
- name: Generate TS vector
working-directory: implementations/ts
run: npm run gen-testvector -w @kduma-oss/pcf-dcp -- /tmp/ts.bin

# ---- PHP writer -------------------------------------------------------
- name: Install composer deps
working-directory: implementations/php/pcf-dcp
run: composer install --prefer-dist --no-progress --no-interaction
- name: Generate PHP vector
working-directory: implementations/php/pcf-dcp
run: php examples/gen_testvector.php /tmp/php.bin

# ---- .NET writer ------------------------------------------------------
- name: Generate .NET vector
run: |
mkdir -p /tmp/dotnet-gen
cat > /tmp/dotnet-gen/GenTestVector.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(GITHUB_WORKSPACE)/implementations/dotnet/pcf-dcp/src/Pcf.Dcp/Pcf.Dcp.csproj" />
</ItemGroup>
</Project>
EOF
cat > /tmp/dotnet-gen/Program.cs <<'EOF'
using System.IO;
using Pcf.Dcp;
File.WriteAllBytes(args[0], ReferenceVector.Build());
EOF
dotnet run --project /tmp/dotnet-gen/GenTestVector.csproj -c Release -- /tmp/dotnet.bin

# ---- Compare ----------------------------------------------------------
- name: All four DCP writers agree on byte-exact output
run: |
set -euo pipefail
ls -l /tmp/rust.bin /tmp/ts.bin /tmp/php.bin /tmp/dotnet.bin
fail=0
for f in /tmp/rust.bin /tmp/ts.bin /tmp/php.bin /tmp/dotnet.bin; do
d=$(sha256sum "$f" | awk '{print $1}')
echo "$f -> $d"
if [ "$d" != "$EXPECTED_SHA256" ]; then
echo "::error::$f sha256 = $d (expected $EXPECTED_SHA256)"
fail=1
fi
if ! cmp -s /tmp/rust.bin "$f"; then
echo "::error::$f differs from /tmp/rust.bin"
fail=1
fi
done
if [ "$fail" != "0" ]; then
echo "Cross-port DCP writer interop FAILED"
exit 1
fi
echo "All four DCP writers produced sha256 = $EXPECTED_SHA256"

- uses: actions/upload-artifact@v4
if: always()
with:
name: cross-port-vectors-dcp
path: |
/tmp/rust.bin
/tmp/ts.bin
/tmp/php.bin
/tmp/dotnet.bin
4 changes: 3 additions & 1 deletion .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
paths:
- 'implementations/dotnet/pcf/**'
- 'implementations/dotnet/pcf-sig/**'
- 'implementations/dotnet/pcf-dcp/**'
- 'implementations/dotnet/Directory.Build.props'
- '.github/workflows/dotnet-ci.yml'
pull_request:
branches: [master]
paths:
- 'implementations/dotnet/pcf/**'
- 'implementations/dotnet/pcf-sig/**'
- 'implementations/dotnet/pcf-dcp/**'
- 'implementations/dotnet/Directory.Build.props'
- '.github/workflows/dotnet-ci.yml'

Expand All @@ -24,7 +26,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
package: [pcf, pcf-sig]
package: [pcf, pcf-sig, pcf-dcp]
defaults:
run:
working-directory: implementations/dotnet/${{ matrix.package }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/php-split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
package:
- { dir: 'implementations/php/pcf', repo: 'PHP-PCF-lib' }
- { dir: 'implementations/php/pcf-sig', repo: 'PHP-PCF-SIG-lib' }
- { dir: 'implementations/php/pcf-dcp', repo: 'PHP-PCF-DCP-lib' }
steps:
- uses: actions/checkout@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3', '8.4']
package: [pcf, pcf-sig]
package: [pcf, pcf-sig, pcf-dcp]
defaults:
run:
working-directory: implementations/php/${{ matrix.package }}
Expand Down Expand Up @@ -47,6 +47,7 @@ jobs:
include:
- { package: pcf, output: pcf_testvector.bin, expected: 395 }
- { package: pcf-sig, output: pcfsig_testvector.bin, expected: 966 }
- { package: pcf-dcp, output: pcf_dcp_testvector.bin, expected: 700 }
defaults:
run:
working-directory: implementations/php/${{ matrix.package }}
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,21 @@ jobs:
sed -i 's/^version = "[^"]*"/version = "'"$NEW"'"/' reference/PCF-DCP-v1.0/Cargo.toml
sed -i 's/^version = "[^"]*"/version = "'"$NEW"'"/' tools/pcf-debug/Cargo.toml
sed -i 's/^version = "[^"]*"/version = "'"$NEW"'"/' tools/pcf-compact/Cargo.toml
sed -i 's/^version = "[^"]*"/version = "'"$NEW"'"/' tools/pcf-sig/Cargo.toml
# path-dep version pins on pcf
sed -i 's|pcf = { path = "\.\./PCF-v1.0", version = "[^"]*" }|pcf = { path = "../PCF-v1.0", version = "'"$NEW"'" }|' reference/PFS-MS-v1.0/Cargo.toml
sed -i 's|pcf = { path = "\.\./PCF-v1.0", version = "[^"]*" }|pcf = { path = "../PCF-v1.0", version = "'"$NEW"'" }|' reference/PCF-SIG-v1.0/Cargo.toml
sed -i 's|pcf = { path = "\.\./PCF-v1.0", version = "[^"]*" }|pcf = { path = "../PCF-v1.0", version = "'"$NEW"'" }|' reference/PCF-DCP-v1.0/Cargo.toml
# PFS-MS also pins the PCF-SIG library and the pcf-sig CLI library
sed -i 's|pcf-sig = { path = "\.\./PCF-SIG-v1.0", version = "[^"]*" }|pcf-sig = { path = "../PCF-SIG-v1.0", version = "'"$NEW"'" }|' reference/PFS-MS-v1.0/Cargo.toml
sed -i 's|pcf-sig-cli = { path = "\.\./\.\./tools/pcf-sig", version = "[^"]*" }|pcf-sig-cli = { path = "../../tools/pcf-sig", version = "'"$NEW"'" }|' reference/PFS-MS-v1.0/Cargo.toml
sed -i 's|pcf = { path = "\.\./\.\./reference/PCF-v1.0", version = "[^"]*" }|pcf = { path = "../../reference/PCF-v1.0", version = "'"$NEW"'" }|' tools/pcf-debug/Cargo.toml
sed -i 's|pcf-sig = { path = "\.\./\.\./reference/PCF-SIG-v1.0", version = "[^"]*" }|pcf-sig = { path = "../../reference/PCF-SIG-v1.0", version = "'"$NEW"'" }|' tools/pcf-debug/Cargo.toml
sed -i 's|pcf-dcp = { path = "\.\./\.\./reference/PCF-DCP-v1.0", version = "[^"]*" }|pcf-dcp = { path = "../../reference/PCF-DCP-v1.0", version = "'"$NEW"'" }|' tools/pcf-debug/Cargo.toml
sed -i 's|pcf = { path = "\.\./\.\./reference/PCF-v1.0", version = "[^"]*" }|pcf = { path = "../../reference/PCF-v1.0", version = "'"$NEW"'" }|' tools/pcf-compact/Cargo.toml
# pcf-sig CLI pins on pcf and pcf-sig
sed -i 's|pcf = { path = "\.\./\.\./reference/PCF-v1.0", version = "[^"]*" }|pcf = { path = "../../reference/PCF-v1.0", version = "'"$NEW"'" }|' tools/pcf-sig/Cargo.toml
sed -i 's|pcf-sig = { path = "\.\./\.\./reference/PCF-SIG-v1.0", version = "[^"]*" }|pcf-sig = { path = "../../reference/PCF-SIG-v1.0", version = "'"$NEW"'" }|' tools/pcf-sig/Cargo.toml

- name: Bump TypeScript packages
shell: bash
Expand All @@ -102,6 +109,13 @@ jobs:
sed -i 's|"kduma/pcf": "\^[^"]*"|"kduma/pcf": "^'"$NEW"'"|' implementations/php/pcf-sig/composer.json
sed -i 's|"versions": { "kduma/pcf": "[^"]*" }|"versions": { "kduma/pcf": "'"$NEW"'" }|' implementations/php/pcf-sig/composer.json

- name: Bump PHP pcf-dcp dependency on pcf
shell: bash
run: |
NEW='${{ steps.version.outputs.version }}'
sed -i 's|"kduma/pcf": "\^[^"]*"|"kduma/pcf": "^'"$NEW"'"|' implementations/php/pcf-dcp/composer.json
sed -i 's|"versions": { "kduma/pcf": "[^"]*" }|"versions": { "kduma/pcf": "'"$NEW"'" }|' implementations/php/pcf-dcp/composer.json

- name: Bump .NET Directory.Build.props
shell: bash
run: |
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ jobs:
- run: npm ci
- run: npm run build -w @kduma-oss/pcf
- run: npm run build -w @kduma-oss/pcf-sig
- run: npm run build -w @kduma-oss/pcf-dcp
- name: npm publish pcf (OIDC trusted publishing, auto-provenance)
run: |
if [ "${{ needs.resolve.outputs.dry_run }}" = "true" ]; then
Expand All @@ -204,6 +205,13 @@ jobs:
else
npm publish -w @kduma-oss/pcf-sig --access public
fi
- name: npm publish pcf-dcp
run: |
if [ "${{ needs.resolve.outputs.dry_run }}" = "true" ]; then
npm publish -w @kduma-oss/pcf-dcp --access public --dry-run
else
npm publish -w @kduma-oss/pcf-dcp --access public
fi

publish-nuget:
name: Publish to NuGet
Expand Down Expand Up @@ -291,6 +299,49 @@ jobs:
name: nuget-package-sig
path: implementations/dotnet/pcf-sig/out/*.nupkg

publish-nuget-dcp:
name: Publish KDuma.Pcf.Dcp to NuGet
needs: [resolve, publish-nuget]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
defaults:
run:
working-directory: implementations/dotnet/pcf-dcp
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- run: dotnet restore
- name: dotnet pack
run: |
dotnet pack src/Pcf.Dcp/Pcf.Dcp.csproj \
-c Release \
-p:Version='${{ needs.resolve.outputs.version }}' \
-o out
- name: NuGet login (OIDC trusted publishing)
id: nuget-login
if: needs.resolve.outputs.dry_run != 'true'
uses: NuGet/login@v1
with:
user: krystianduma
- name: dotnet nuget push
if: needs.resolve.outputs.dry_run != 'true'
run: |
dotnet nuget push out/*.nupkg \
--source https://api.nuget.org/v3/index.json \
--api-key '${{ steps.nuget-login.outputs.NUGET_API_KEY }}' \
--skip-duplicate
- name: Dry-run note
if: needs.resolve.outputs.dry_run == 'true'
run: 'echo "Dry-run - skipping dotnet nuget push. Package would be out/*.nupkg."'
- uses: actions/upload-artifact@v4
with:
name: nuget-package-dcp
path: implementations/dotnet/pcf-dcp/out/*.nupkg

split-php:
name: Split PHP to packagist source repo
needs: resolve
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/ts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- run: npm ci
- run: npm run build -w @kduma-oss/pcf
- run: npm run build -w @kduma-oss/pcf-sig
- run: npm run build -w @kduma-oss/pcf-dcp

test:
name: test (${{ matrix.os }})
Expand All @@ -41,10 +42,11 @@ jobs:
cache-dependency-path: implementations/ts/package-lock.json
- run: npm ci
- run: npm test -w @kduma-oss/pcf
# pcf-sig imports the compiled @kduma-oss/pcf dist/; build pcf first
# so the workspace dependency resolves before vitest runs.
# pcf-sig and pcf-dcp import the compiled @kduma-oss/pcf dist/; build pcf
# first so the workspace dependency resolves before vitest runs.
- run: npm run build -w @kduma-oss/pcf
- run: npm test -w @kduma-oss/pcf-sig
- run: npm test -w @kduma-oss/pcf-dcp

test-vector:
name: regenerate spec test vector
Expand All @@ -71,12 +73,19 @@ jobs:
run: |
ls -l pcf-sig/pcfsig_testvector.bin
test "$(wc -c < pcf-sig/pcfsig_testvector.bin)" = "966"
- name: Build and run the PCF-DCP test-vector example
run: npm run gen-testvector -w @kduma-oss/pcf-dcp -- pcf_dcp_testvector.bin
- name: Inspect PCF-DCP test vector
run: |
ls -l pcf-dcp/pcf_dcp_testvector.bin
test "$(wc -c < pcf-dcp/pcf_dcp_testvector.bin)" = "700"
- uses: actions/upload-artifact@v4
with:
name: pcf-testvector-ts
path: |
implementations/ts/pcf/pcf_testvector.bin
implementations/ts/pcf-sig/pcfsig_testvector.bin
implementations/ts/pcf-dcp/pcf_dcp_testvector.bin

coverage:
name: code coverage
Expand All @@ -95,9 +104,12 @@ jobs:
run: npm run build -w @kduma-oss/pcf
- name: Generate PCF-SIG coverage report (enforces >=90% line / 100% function)
run: npm run coverage -w @kduma-oss/pcf-sig
- name: Generate PCF-DCP coverage report (enforces >=85% line / 90% function)
run: npm run coverage -w @kduma-oss/pcf-dcp
- uses: actions/upload-artifact@v4
with:
name: coverage-lcov-ts
path: |
implementations/ts/pcf/coverage/lcov.info
implementations/ts/pcf-sig/coverage/lcov.info
implementations/ts/pcf-dcp/coverage/lcov.info
Loading
Loading