Skip to content
Merged
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
95 changes: 95 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Mixed-language coverage

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

on:
pull_request:
branches: [main]
paths:
- '.github/workflows/coverage.yml'
- 'Cargo.lock'
- 'Cargo.toml'
- 'bindings/js/**'
- 'bindings/py/**'
- 'crates/dynwinrt/**'
- 'eng/coverage/**'
- 'tests/e2e/**'
- 'tools/dynwinrt-codegen/**'
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: coverage-${{ github.ref }}
cancel-in-progress: true

jobs:
coverage:
runs-on: windows-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
cache-dependency-path: bindings/js/package-lock.json

- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip

- uses: NuGet/setup-nuget@v2

- name: Install cargo-llvm-cov
shell: pwsh
run: cargo install cargo-llvm-cov --version 0.8.7 --locked

- name: Install Win32 metadata
shell: pwsh
run: |
$root = Join-Path $env:RUNNER_TEMP 'win32metadata'
nuget install Microsoft.Windows.SDK.Win32Metadata `
-Version 71.0.14-preview `
-OutputDirectory $root `
-DirectDownload `
-NonInteractive
$winmd = Get-ChildItem $root -Filter Windows.Win32.winmd -File -Recurse |
Select-Object -First 1
if (-not $winmd) {
throw 'Microsoft.Windows.SDK.Win32Metadata did not contain Windows.Win32.winmd'
}
"DYNWINRT_WIN32_WINMD=$($winmd.FullName)" >> $env:GITHUB_ENV

- name: Run Rust, Python, JavaScript, and E2E coverage
shell: pwsh
run: |
.\eng\coverage\coverage.ps1 `
-Win32Winmd $env:DYNWINRT_WIN32_WINMD

- name: Publish coverage summary
if: always()
shell: pwsh
run: |
if (Test-Path artifacts\coverage\summary.md) {
Get-Content artifacts\coverage\summary.md >> $env:GITHUB_STEP_SUMMARY
}

- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: mixed-language-coverage
path: artifacts/coverage/
if-no-files-found: warn
retention-days: 14
20 changes: 19 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ cargo test -p dynwinrt
cargo test -p dynwinrt-codegen
```

### Coverage

Install the Rust coverage tool once:

```powershell
rustup component add llvm-tools-preview
cargo install cargo-llvm-cov --version 0.8.7 --locked
```

Run the mixed-language coverage pipeline:

```powershell
.\eng\coverage\coverage.ps1
```

The script builds instrumented Python and Node native modules, runs the
Rust/Python/JavaScript tests and E2E suite, and writes HTML, LCOV, XML, and JSON
reports under `artifacts\coverage`.

### Code Style

- Run `cargo clippy` before submitting PRs
Expand All @@ -60,4 +79,3 @@ Please use the provided issue templates when available.
5. Submit your pull request

Thank you for contributing!

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ license = "MIT"
opt-level = 3
lto = true
codegen-units = 1

[profile.coverage]
inherits = "dev"
incremental = false
lto = false
codegen-units = 1
debug = 2
4 changes: 2 additions & 2 deletions bindings/js/__test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ test('DynCom rejects SharedArrayBuffer-backed native storage', (t) => {
test('DynCom does not adopt borrowed raw pointer bits as owned COM references', (t) => {
const borrowed = DynCom.pointer(0n)
const error = t.throws(() => DynCom.adoptComPointer(borrowed))
t.regex(error.message, /only owned native outputs may be consumed/)
t.regex(error.message, /Borrowed provenance; expected ComOutput/)
})

test('DynCom exposes HSTRING and semantic HRESULT primitives', (t) => {
Expand Down Expand Up @@ -382,7 +382,7 @@ test('DynCom Automation wrappers preserve tags, values, bounds, and transfer', (
})
t.throws(
() => DynComSafeArray.interface(WinGuid.parse('ffffffff-ffff-ffff-ffff-ffffffffffff'), [activationFactory]),
{ message: /interface is not supported|No such interface supported/i },
{ message: /80004002|interface is not supported|No such interface supported/i },
)
const nullSafeArray = DynWinRtValue.nullValue()
t.is(DynCom.takeNullableSafeArray(nullSafeArray), null)
Expand Down
Loading
Loading