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
7 changes: 7 additions & 0 deletions .github/actions/print-build-versions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
description: "Path to Cargo.lock used as a fallback source for the wasm-bindgen version"
required: false
default: "src/Cargo.lock"
jacoco-version:
description: "JaCoCo version, resolved by Gradle during the build rather than from a runner CLI"
required: false
default: ""

runs:
using: composite
Expand All @@ -18,6 +22,7 @@ runs:
shell: bash
env:
CARGO_LOCK: ${{ inputs.cargo-lock }}
JACOCO_VERSION: ${{ inputs.jacoco-version }}
run: |
echo "::group::Build tool versions ($(uname -s) $(uname -m))"
echo "os: $(uname -srm)"
Expand Down Expand Up @@ -64,4 +69,6 @@ runs:
fi
if command -v cargo-about >/dev/null 2>&1; then echo "cargo-about: $(cargo-about --version 2>/dev/null | head -1)"; else echo "cargo-about: not installed"; fi
if command -v cargo-audit >/dev/null 2>&1; then echo "cargo-audit: $(cargo-audit --version 2>/dev/null | head -1)"; else echo "cargo-audit: not installed"; fi
if command -v cargo-llvm-cov >/dev/null 2>&1; then echo "cargo-llvm-cov: $(cargo-llvm-cov --version 2>/dev/null | head -1)"; else echo "cargo-llvm-cov: not installed"; fi
if [ -n "$JACOCO_VERSION" ]; then echo "jacoco: $JACOCO_VERSION (resolved by Gradle)"; fi
echo "::endgroup::"
12 changes: 12 additions & 0 deletions .github/workflows/configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ on:
cargo-audit-version:
description: "cargo-audit version"
value: ${{ jobs.get-configs.outputs.cargo-audit-version }}
cargo-llvm-cov-version:
description: "cargo-llvm-cov version"
value: ${{ jobs.get-configs.outputs.cargo-llvm-cov-version }}
jacoco-version:
description: "JaCoCo version for the JVM binding coverage report"
value: ${{ jobs.get-configs.outputs.jacoco-version }}

permissions:
contents: read
Expand All @@ -67,6 +73,8 @@ jobs:
WASM_PACK_VERSION: '0.14.0'
CARGO_ABOUT_VERSION: '0.9.0'
CARGO_AUDIT_VERSION: '0.22.2'
CARGO_LLVM_COV_VERSION: '0.8.7'
JACOCO_VERSION: '0.8.13' # keep in sync with bindings-jvm/tests/kotlin/build.gradle.kts
outputs:
app-name: ${{ env.APP_NAME }}
working-dir: ${{ env.WORKING_DIR }}
Expand All @@ -82,6 +90,8 @@ jobs:
wasm-pack-version: ${{ env.WASM_PACK_VERSION }}
cargo-about-version: ${{ env.CARGO_ABOUT_VERSION }}
cargo-audit-version: ${{ env.CARGO_AUDIT_VERSION }}
cargo-llvm-cov-version: ${{ env.CARGO_LLVM_COV_VERSION }}
jacoco-version: ${{ env.JACOCO_VERSION }}
steps:
- name: Provide configs
run: |
Expand All @@ -99,3 +109,5 @@ jobs:
echo "wasm-pack-version = ${{ env.WASM_PACK_VERSION }}"
echo "cargo-about-version = ${{ env.CARGO_ABOUT_VERSION }}"
echo "cargo-audit-version = ${{ env.CARGO_AUDIT_VERSION }}"
echo "cargo-llvm-cov-version = ${{ env.CARGO_LLVM_COV_VERSION }}"
echo "jacoco-version = ${{ env.JACOCO_VERSION }}"
16 changes: 13 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
test:
needs: [ format, lint, audit, get-configs ]
runs-on: ubuntu-latest
env:
WORKING_DIR: ${{ needs.get-configs.outputs.working-dir }}
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -105,18 +107,24 @@
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ needs.get-configs.outputs.rust-toolchain }}
components: llvm-tools-preview

- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ needs.get-configs.outputs.working-dir }}
workspaces: ${{ env.WORKING_DIR }}

- name: Install cargo-llvm-cov ${{ needs.get-configs.outputs.cargo-llvm-cov-version }}
uses: taiki-e/install-action@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow or composite action Medium

Unpinned 3rd party Action 'Validate' step
Uses Step
uses 'taiki-e/install-action' with ref 'v2', not a pinned commit hash
with:
tool: cargo-llvm-cov@${{ needs.get-configs.outputs.cargo-llvm-cov-version }}

- name: Log tool versions
uses: ./.github/actions/print-build-versions

- name: Test
working-directory: ${{ needs.get-configs.outputs.working-dir }}
run: cargo test --locked --release --workspace --no-fail-fast
working-directory: ${{ env.WORKING_DIR }}
run: cargo llvm-cov --locked --release --workspace --no-fail-fast

test-jvm:
needs: [ format, lint, audit, get-configs ]
Expand Down Expand Up @@ -149,6 +157,8 @@

- name: Log tool versions
uses: ./.github/actions/print-build-versions
with:
jacoco-version: ${{ needs.get-configs.outputs.jacoco-version }}

- name: Test
working-directory: ${{ env.WORKING_DIR }}/bindings-jvm/tests
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ src/bindings-jvm/generated/**/*
# Node / WASM
**/node_modules/
**/package-lock.json
!src/bindings-wasm/package-lock.json

# Output (regenerable)
**/output/**
Expand All @@ -24,6 +25,7 @@ src/data-source/generated/patched_schemas/
src/**/reports/
**/cdk.out/
*.pyc
**/coverage/**

# IDE
**/*.iml
Expand Down
48 changes: 48 additions & 0 deletions src/bindings-jvm/tests/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
plugins {
kotlin("jvm") version "2.3.10"
jacoco
}

repositories {
mavenCentral()
}

jacoco {
toolVersion = "0.8.13"
}

val bindingsJar = file("${rootProject.projectDir}/../../generated/cloudformation-validate.jar")

dependencies {
Expand All @@ -27,6 +32,49 @@ tasks.test {
showStackTraces = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}

finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
classDirectories.setFrom(
zipTree(bindingsJar).matching {
include("com/amazonaws/cloudformation/validation/**/*.class")
exclude(
"**/FfiConverter*",
"**/ForeignBytes*",
"**/RustBuffer*",
"**/Uniffi*",
"**/*Cleaner*",
"**/NoPointer*",
"**/UByteArray*",
)
},
)

reports {
xml.required.set(true)
html.required.set(true)
}

doLast {
val reportFile = reports.xml.outputLocation.get().asFile
val factory = javax.xml.parsers.DocumentBuilderFactory.newInstance()
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
val report = factory.newDocumentBuilder().parse(reportFile).documentElement
val counters = report.childNodes
println("Kotlin coverage:")
for (i in 0 until counters.length) {
val node = counters.item(i)
if (node.nodeName != "counter") continue
val type = node.attributes.getNamedItem("type").nodeValue
val covered = node.attributes.getNamedItem("covered").nodeValue.toInt()
val missed = node.attributes.getNamedItem("missed").nodeValue.toInt()
val total = covered + missed
val pct = if (total > 0) 100.0 * covered / total else 0.0
println(" %-12s %6d/%-6d %6.2f%%".format(type, covered, total, pct))
}
}
}

kotlin {
Expand Down
2 changes: 1 addition & 1 deletion src/bindings-jvm/tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ KOTLIN_DIR="$SCRIPT_DIR/kotlin"

echo "Running Kotlin smoke tests..."
cd "$KOTLIN_DIR"
gradle test --no-daemon --rerun-tasks
gradle test jacocoTestReport --no-daemon --rerun-tasks --console=rich
2 changes: 1 addition & 1 deletion src/bindings-wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [ -f "$WASM_DTS" ] && ! grep -q "^export type JsonValue" "$WASM_DTS"; then
fi

cd "$SCRIPT_DIR"
npm ci --silent 2>/dev/null
npm ci --silent
npm run build:ts

# ── Package metadata ──────────────────────────────────────────────────────────
Expand Down
61 changes: 61 additions & 0 deletions src/bindings-wasm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/bindings-wasm/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"private": true,
"scripts": {
"test": "vitest run"
"test": "vitest run",
"test:coverage": "vitest run --coverage"
},
"devDependencies": {
"vitest": "4.1.8",
"@vitest/coverage-v8": "4.1.8",
"@types/node": "25.9.3"
}
}
4 changes: 2 additions & 2 deletions src/bindings-wasm/tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ BINDINGS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

echo "Running smoke tests..."
cd "$SCRIPT_DIR"
npm ci --silent 2>/dev/null
npm test
npm install --silent
npm run test:coverage
27 changes: 16 additions & 11 deletions src/bindings-wasm/tests/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { defineConfig } from "vitest/config";
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
testTimeout: 120_000,
hookTimeout: 120_000,
teardownTimeout: 120_000,
pool: "threads",
poolOptions: {
threads: {
singleThread: true,
},
root: '..',
test: {
include: ['tests/**/*.test.ts'],
testTimeout: 120_000,
hookTimeout: 120_000,
teardownTimeout: 120_000,
fileParallelism: false,
coverage: {
provider: 'v8',
include: ['dist/**/*.js'],
exclude: ['dist/package.json'],
reporter: ['text', 'lcov', 'json-summary'],
reportsDirectory: 'tests/coverage',
reportOnFailure: true,
},
},
},
});
Loading