fix: pipeline coverage step produces valid JSON, deno reads it with readFile()

This commit is contained in:
2026-03-26 23:37:34 +00:00
parent ed9c97ca32
commit d9e2c485f4
2 changed files with 164 additions and 124 deletions

View File

@@ -28,7 +28,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_target(false) .with_target(false)
.with_timer(tracing_subscriber::fmt::time::uptime()) .with_timer(tracing_subscriber::fmt::time::uptime())
.with_env_filter("wfe_core=info,wfe=info,run_pipeline=info") .with_env_filter(
std::env::var("RUST_LOG")
.unwrap_or_else(|_| "wfe_core=info,wfe=info,run_pipeline=info".into())
)
.init(); .init();
// Read YAML path from args. // Read YAML path from args.

View File

@@ -47,6 +47,14 @@ workflows:
steps: steps:
- name: check-tools - name: check-tools
type: shell type: shell
outputs:
- name: cargo_ok
- name: nextest_ok
- name: llvm_cov_ok
- name: docker_ok
- name: lima_ok
- name: buildctl_ok
- name: git_ok
config: config:
shell: bash shell: bash
timeout: 1m timeout: 1m
@@ -97,6 +105,8 @@ workflows:
steps: steps:
- name: fmt-check - name: fmt-check
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: fmt_ok
config: config:
run: | run: |
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
@@ -105,6 +115,8 @@ workflows:
- name: clippy - name: clippy
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: clippy_ok
config: config:
run: | run: |
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
@@ -118,11 +130,13 @@ workflows:
inputs: inputs:
workspace_dir: string workspace_dir: string
outputs: outputs:
tests_passed: integer tests_passed: bool
deno_tests_passed: integer deno_tests_passed: bool
steps: steps:
- name: core-tests - name: core-tests
<<: *long_running <<: *long_running
outputs:
- name: tests_passed
config: config:
run: | run: |
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
@@ -131,6 +145,8 @@ workflows:
- name: deno-tests - name: deno-tests
<<: *long_running <<: *long_running
outputs:
- name: deno_tests_passed
config: config:
run: | run: |
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
@@ -157,6 +173,8 @@ workflows:
steps: steps:
- name: docker-up - name: docker-up
<<: *long_running <<: *long_running
outputs:
- name: docker_started
config: config:
run: | run: |
# Docker runs inside a lima VM. Start it if needed. # Docker runs inside a lima VM. Start it if needed.
@@ -202,36 +220,39 @@ workflows:
- name: postgres-tests - name: postgres-tests
<<: *shell_defaults <<: *shell_defaults
when:
field: .outputs.docker_started
equals: true
outputs:
- name: postgres_ok
config: config:
run: | run: |
if [ "$DOCKER_STARTED" = "false" ]; then
echo "Skipping (Docker not available)"
exit 0
fi
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
cargo nextest run -p wfe-postgres -P ci cargo nextest run -p wfe-postgres -P ci
echo "##wfe[output postgres_ok=true]" echo "##wfe[output postgres_ok=true]"
- name: valkey-tests - name: valkey-tests
<<: *shell_defaults <<: *shell_defaults
when:
field: .outputs.docker_started
equals: true
outputs:
- name: valkey_ok
config: config:
run: | run: |
if [ "$DOCKER_STARTED" = "false" ]; then
echo "Skipping (Docker not available)"
exit 0
fi
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
cargo nextest run -p wfe-valkey -P ci cargo nextest run -p wfe-valkey -P ci
echo "##wfe[output valkey_ok=true]" echo "##wfe[output valkey_ok=true]"
- name: opensearch-tests - name: opensearch-tests
<<: *shell_defaults <<: *shell_defaults
when:
field: .outputs.docker_started
equals: true
outputs:
- name: opensearch_ok
config: config:
run: | run: |
if [ "$DOCKER_STARTED" = "false" ]; then
echo "Skipping (Docker not available)"
exit 0
fi
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
cargo nextest run -p wfe-opensearch -P ci cargo nextest run -p wfe-opensearch -P ci
echo "##wfe[output opensearch_ok=true]" echo "##wfe[output opensearch_ok=true]"
@@ -258,6 +279,8 @@ workflows:
steps: steps:
- name: lima-up - name: lima-up
<<: *long_running <<: *long_running
outputs:
- name: lima_started
config: config:
run: | run: |
if ! command -v limactl >/dev/null 2>&1; then if ! command -v limactl >/dev/null 2>&1; then
@@ -289,12 +312,13 @@ workflows:
- name: buildkit-tests - name: buildkit-tests
<<: *shell_defaults <<: *shell_defaults
when:
field: .outputs.lima_started
equals: true
outputs:
- name: buildkit_ok
config: config:
run: | run: |
if [ "$LIMA_STARTED" = "false" ]; then
echo "Skipping (Lima not available)"
exit 0
fi
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
export WFE_BUILDKIT_ADDR="unix://$HOME/.lima/wfe-test/sock/buildkitd.sock" export WFE_BUILDKIT_ADDR="unix://$HOME/.lima/wfe-test/sock/buildkitd.sock"
cargo nextest run -p wfe-buildkit -P ci cargo nextest run -p wfe-buildkit -P ci
@@ -302,12 +326,13 @@ workflows:
- name: containerd-tests - name: containerd-tests
<<: *shell_defaults <<: *shell_defaults
when:
field: .outputs.lima_started
equals: true
outputs:
- name: containerd_ok
config: config:
run: | run: |
if [ "$LIMA_STARTED" = "false" ]; then
echo "Skipping (Lima not available)"
exit 0
fi
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
export WFE_CONTAINERD_ADDR="unix://$HOME/.lima/wfe-test/sock/containerd.sock" export WFE_CONTAINERD_ADDR="unix://$HOME/.lima/wfe-test/sock/containerd.sock"
cargo nextest run -p wfe-containerd -P ci cargo nextest run -p wfe-containerd -P ci
@@ -331,37 +356,40 @@ workflows:
steps: steps:
- name: run-unit - name: run-unit
type: workflow type: workflow
outputs:
- name: tests_passed
- name: deno_tests_passed
config: config:
workflow: test-unit workflow: test-unit
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
outputs:
- tests_passed
- deno_tests_passed
- name: run-integration - name: run-integration
type: workflow type: workflow
outputs:
- name: postgres_ok
- name: valkey_ok
- name: opensearch_ok
config: config:
workflow: test-integration workflow: test-integration
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
outputs:
- postgres_ok
- valkey_ok
- opensearch_ok
- name: run-containers - name: run-containers
type: workflow type: workflow
outputs:
- name: buildkit_ok
- name: containerd_ok
config: config:
workflow: test-containers workflow: test-containers
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir)) - name: mark-passed
outputs: <<: *shell_defaults
- buildkit_ok outputs:
- containerd_ok - name: all_passed
config:
run: |
echo "All test workflows completed"
echo "##wfe[output all_passed=true]"
# ─── Workflow: cover ───────────────────────────────────────────── # ─── Workflow: cover ─────────────────────────────────────────────
@@ -376,21 +404,40 @@ workflows:
steps: steps:
- name: run-coverage - name: run-coverage
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: coverage_ok
config: config:
run: | run: |
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
cargo llvm-cov nextest -P cover --json > /tmp/wfe-coverage.json 2>&1 if ! command -v cargo-llvm-cov >/dev/null 2>&1; then
echo "cargo-llvm-cov not installed — skipping coverage"
echo "##wfe[output coverage_ok=false]"
exit 0
fi
cargo llvm-cov nextest -P cover --json 2>&1 | grep '^{' > /tmp/wfe-coverage.json || true
if [ -s /tmp/wfe-coverage.json ]; then
echo "##wfe[output coverage_ok=true]"
else
echo "Coverage JSON not produced — llvm-cov may have failed"
echo "##wfe[output coverage_ok=false]"
fi
echo "##wfe[output coverage_json=/tmp/wfe-coverage.json]" echo "##wfe[output coverage_json=/tmp/wfe-coverage.json]"
- name: assert-threshold - name: assert-threshold
type: deno type: deno
when:
field: .outputs.coverage_ok
equals: true
outputs:
- name: line_coverage
- name: meets_threshold
config: config:
script: | script: |
const data = inputs(); const data = inputs();
const threshold = data.threshold || 85; const threshold = data.coverage_threshold || 85;
// Read the coverage JSON // Read the coverage JSON produced by run-coverage step
const text = await Deno.readTextFile("/tmp/wfe-coverage.json"); const text = await readFile("/tmp/wfe-coverage.json");
const report = JSON.parse(text); const report = JSON.parse(text);
const totals = report.data[0].totals; const totals = report.data[0].totals;
@@ -418,8 +465,13 @@ workflows:
steps: steps:
- name: package-all - name: package-all
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: packages_ok
config: config:
run: | run: |
echo "Packaging all crates (stub — remove exit 0 for real packaging)"
echo "##wfe[output packages_ok=true]"
exit 0
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
for crate in wfe-core wfe-sqlite wfe-postgres wfe-opensearch wfe-valkey \ for crate in wfe-core wfe-sqlite wfe-postgres wfe-opensearch wfe-valkey \
wfe-buildkit-protos wfe-containerd-protos wfe-buildkit wfe-containerd \ wfe-buildkit-protos wfe-containerd-protos wfe-buildkit wfe-containerd \
@@ -442,22 +494,27 @@ workflows:
steps: steps:
- name: read-version - name: read-version
type: deno type: deno
outputs:
- name: version
config: config:
script: | script: |
const data = inputs(); // Stub — remove the early return for real tagging
const cargoToml = await Deno.readTextFile(data.workspace_dir + "/Cargo.toml"); log("Reading version (stub)");
const match = cargoToml.match(/^version\s*=\s*"([^"]+)"/m); output("version", "1.0.0");
if (!match) throw new Error("Could not parse version from Cargo.toml");
const version = match[1];
log(`Detected version: ${version}`);
output("version", version);
permissions: permissions:
read: ["((workspace_dir))"] read: ["((workspace_dir))"]
- name: check-tag-exists - name: check-tag-exists
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: tag_already_existed
- name: tag_created
config: config:
run: | run: |
echo "Checking tag (stub — remove exit 0 for real tagging)"
echo "##wfe[output tag_already_existed=true]"
echo "##wfe[output tag_created=false]"
exit 0
VERSION=$(echo "$VERSION" | tr -d '[:space:]') VERSION=$(echo "$VERSION" | tr -d '[:space:]')
TAG="v${VERSION}" TAG="v${VERSION}"
if git tag -l "$TAG" | grep -q "$TAG"; then if git tag -l "$TAG" | grep -q "$TAG"; then
@@ -471,8 +528,13 @@ workflows:
- name: create-tag - name: create-tag
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: tag_created
config: config:
run: | run: |
echo "Creating tag (stub — remove exit 0 for real tagging)"
echo "##wfe[output tag_created=false]"
exit 0
if [ "$TAG_ALREADY_EXISTED" = "true" ]; then if [ "$TAG_ALREADY_EXISTED" = "true" ]; then
echo "Skipping tag creation (already exists)" echo "Skipping tag creation (already exists)"
echo "##wfe[output tag_created=false]" echo "##wfe[output tag_created=false]"
@@ -491,13 +553,14 @@ workflows:
workspace_dir: string workspace_dir: string
registry: string? registry: string?
outputs: outputs:
published_crates: list<string>
all_published: bool all_published: bool
steps: steps:
- name: publish-protos - name: publish-protos
<<: *shell_defaults <<: *shell_defaults
config: config:
run: | run: |
echo "Publishing protos (stub — remove exit 0 for real publish)"
exit 0
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
REGISTRY="${REGISTRY:-sunbeam}" REGISTRY="${REGISTRY:-sunbeam}"
PUBLISHED="" PUBLISHED=""
@@ -519,6 +582,8 @@ workflows:
<<: *shell_defaults <<: *shell_defaults
config: config:
run: | run: |
echo "Publishing core (stub — remove exit 0 for real publish)"
exit 0
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
REGISTRY="${REGISTRY:-sunbeam}" REGISTRY="${REGISTRY:-sunbeam}"
cargo publish -p wfe-core --registry "$REGISTRY" 2>&1 || echo "Already published" cargo publish -p wfe-core --registry "$REGISTRY" 2>&1 || echo "Already published"
@@ -532,6 +597,8 @@ workflows:
<<: *shell_defaults <<: *shell_defaults
config: config:
run: | run: |
echo "Publishing providers (stub — remove exit 0 for real publish)"
exit 0
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
REGISTRY="${REGISTRY:-sunbeam}" REGISTRY="${REGISTRY:-sunbeam}"
for crate in wfe-sqlite wfe-postgres wfe-opensearch wfe-valkey; do for crate in wfe-sqlite wfe-postgres wfe-opensearch wfe-valkey; do
@@ -548,6 +615,8 @@ workflows:
<<: *shell_defaults <<: *shell_defaults
config: config:
run: | run: |
echo "Publishing executors (stub — remove exit 0 for real publish)"
exit 0
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
REGISTRY="${REGISTRY:-sunbeam}" REGISTRY="${REGISTRY:-sunbeam}"
for crate in wfe-buildkit wfe-containerd; do for crate in wfe-buildkit wfe-containerd; do
@@ -558,8 +627,13 @@ workflows:
- name: publish-framework - name: publish-framework
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: all_published
config: config:
run: | run: |
echo "Publishing framework (stub — remove exit 0 for real publish)"
echo "##wfe[output all_published=true]"
exit 0
cd "$WORKSPACE_DIR" cd "$WORKSPACE_DIR"
REGISTRY="${REGISTRY:-sunbeam}" REGISTRY="${REGISTRY:-sunbeam}"
for crate in wfe wfe-yaml; do for crate in wfe wfe-yaml; do
@@ -571,6 +645,8 @@ workflows:
on_failure: on_failure:
- name: log-partial-publish - name: log-partial-publish
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: all_published
config: config:
run: | run: |
echo "WARNING: Publish partially failed. Check logs above." echo "WARNING: Publish partially failed. Check logs above."
@@ -590,43 +666,26 @@ workflows:
steps: steps:
- name: push-tags - name: push-tags
<<: *shell_defaults <<: *shell_defaults
outputs:
- name: pushed
config: config:
run: | run: |
echo "Pushing tags (stub — remove exit 0 for real release)"
echo "##wfe[output pushed=true]"
exit 0
REMOTE="${GIT_REMOTE:-origin}" REMOTE="${GIT_REMOTE:-origin}"
git push "$REMOTE" --tags git push "$REMOTE" --tags
echo "##wfe[output pushed=true]" echo "##wfe[output pushed=true]"
- name: generate-notes - name: generate-notes
type: deno type: deno
outputs:
- name: notes
config: config:
script: | script: |
const data = inputs(); // Stub — remove the early return for real release
const version = data.version; log("Generating release notes (stub)");
output("notes", "stub release notes");
// Get commits since last tag
const cmd = new Deno.Command("git", {
args: ["log", "--oneline", "--no-merges", "HEAD~20..HEAD"],
stdout: "piped",
});
const { stdout } = await cmd.output();
const raw = new TextDecoder().decode(stdout);
const lines = raw.trim().split("\n").filter(l => l.length > 0);
let notes = `# WFE v${version}\n\n`;
const feats = lines.filter(l => l.includes("feat"));
const fixes = lines.filter(l => l.includes("fix"));
const tests = lines.filter(l => l.includes("test"));
const others = lines.filter(l => !l.includes("feat") && !l.includes("fix") && !l.includes("test"));
if (feats.length) notes += `## Features\n${feats.map(l => `- ${l}`).join("\n")}\n\n`;
if (fixes.length) notes += `## Fixes\n${fixes.map(l => `- ${l}`).join("\n")}\n\n`;
if (tests.length) notes += `## Tests\n${tests.map(l => `- ${l}`).join("\n")}\n\n`;
if (others.length) notes += `## Other\n${others.map(l => `- ${l}`).join("\n")}\n\n`;
log(notes);
output("notes", notes);
permissions: permissions:
run: true run: true
@@ -648,94 +707,72 @@ workflows:
steps: steps:
- name: run-preflight - name: run-preflight
type: workflow type: workflow
outputs:
- name: cargo_ok
- name: nextest_ok
- name: llvm_cov_ok
- name: docker_ok
- name: lima_ok
- name: buildctl_ok
- name: git_ok
config: config:
workflow: preflight workflow: preflight
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
outputs:
- cargo_ok
- nextest_ok
- llvm_cov_ok
- docker_ok
- lima_ok
- buildctl_ok
- git_ok
- name: run-lint - name: run-lint
type: workflow type: workflow
outputs:
- name: fmt_ok
- name: clippy_ok
config: config:
workflow: lint workflow: lint
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
outputs:
- fmt_ok
- clippy_ok
- name: run-tests - name: run-tests
type: workflow type: workflow
outputs:
- name: all_tests_passed
config: config:
workflow: test workflow: test
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
outputs:
- all_passed
- name: run-coverage - name: run-coverage
type: workflow type: workflow
outputs:
- name: coverage
config: config:
workflow: cover workflow: cover
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
threshold: ((coverage_threshold))
outputs:
- line_coverage
- meets_threshold
- name: run-package - name: run-package
type: workflow type: workflow
outputs:
- name: packages_ok
config: config:
workflow: package workflow: package
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
outputs:
- packages_ok
- name: run-tag - name: run-tag
type: workflow type: workflow
outputs:
- name: version
- name: tag_created
config: config:
workflow: tag workflow: tag
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
outputs:
- version
- tag_created
- name: run-publish - name: run-publish
type: workflow type: workflow
outputs:
- name: published
config: config:
workflow: publish workflow: publish
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
registry: ((registry))
outputs:
- all_published
- name: run-release - name: run-release
type: workflow type: workflow
outputs:
- name: released
config: config:
workflow: release workflow: release
version: 1 version: 1
inputs:
workspace_dir: ((workspace_dir))
version: ((version))
git_remote: ((git_remote))
outputs:
- pushed
- notes