|
11 | 11 | # Minimum hermetic-unit statement coverage the `coverage` gate enforces. Set as a |
12 | 12 | # ratchet just below the current level; raise it as coverage grows (never lower). |
13 | 13 | COVERAGE_MIN: "48" |
| 14 | + # Package ratchets prevent well-covered parsing packages from masking a |
| 15 | + # regression in the orchestration layers. Keep these just below the measured |
| 16 | + # hermetic baseline and only move them upward. |
| 17 | + COVERAGE_CLI_MIN: "28" |
| 18 | + COVERAGE_DOCKER_MIN: "77" |
| 19 | + COVERAGE_LIFECYCLE_MIN: "73" |
| 20 | + COVERAGE_OCI_MIN: "85" |
14 | 21 |
|
15 | 22 | tasks: |
16 | 23 | default: |
@@ -81,6 +88,27 @@ tasks: |
81 | 88 | if (t+0 < m+0) { printf "FAIL: coverage %.1f%% is below the %s%% floor\n", t, m; exit 1 } |
82 | 89 | printf "OK: coverage %.1f%% >= %s%% floor\n", t, m |
83 | 90 | }' |
| 91 | + # Weighted statement coverage per package. This catches the failure mode |
| 92 | + # where gains in parsers hide lost coverage in CLI/OCI orchestration. |
| 93 | + - cmd: | |
| 94 | + check_pkg() { |
| 95 | + pkg="$1"; min="$2" |
| 96 | + result=$(awk -v p="github.com/devcontainers/cli/internal/${pkg}/" ' |
| 97 | + NR > 1 && index($1,p)==1 { total += $2; if ($3 > 0) covered += $2 } |
| 98 | + END { if (total == 0) print "missing"; else printf "%.1f", covered*100/total } |
| 99 | + ' coverage.out) |
| 100 | + if [ "$result" = missing ]; then |
| 101 | + echo "FAIL: no coverage data for internal/$pkg"; return 1 |
| 102 | + fi |
| 103 | + awk -v p="$pkg" -v t="$result" -v m="$min" 'BEGIN { |
| 104 | + if (t+0 < m+0) { printf "FAIL: internal/%s coverage %.1f%% is below %s%%\n", p,t,m; exit 1 } |
| 105 | + printf "OK: internal/%s coverage %.1f%% >= %s%%\n", p,t,m |
| 106 | + }' |
| 107 | + } |
| 108 | + check_pkg cli {{.COVERAGE_CLI_MIN}} |
| 109 | + check_pkg docker {{.COVERAGE_DOCKER_MIN}} |
| 110 | + check_pkg lifecycle {{.COVERAGE_LIFECYCLE_MIN}} |
| 111 | + check_pkg oci {{.COVERAGE_OCI_MIN}} |
84 | 112 |
|
85 | 113 | coverage:e2e: |
86 | 114 | desc: Measure the real in-process E2E paths (requires Docker) |
@@ -108,6 +136,37 @@ tasks: |
108 | 136 | - go tool covdata textfmt -i=artifacts/coverage/data/contract -o=artifacts/coverage/parity-contract.out |
109 | 137 | - go tool cover -func=artifacts/coverage/parity-contract.out |
110 | 138 |
|
| 139 | + coverage:parity-runtime: |
| 140 | + desc: Measure the instrumented Go binary through the full Docker parity lane |
| 141 | + deps: [build:coverage, reference:compile] |
| 142 | + preconditions: |
| 143 | + - sh: docker info >/dev/null 2>&1 |
| 144 | + msg: Docker is required for runtime parity coverage |
| 145 | + - sh: | |
| 146 | + d=$(mktemp -d) && printf 'FROM busybox\n' > "$d/Dockerfile" && \ |
| 147 | + docker buildx build --cache-to=type=local,dest="$d/c" -t parity-coverage-builder-probe "$d" >/dev/null 2>&1; \ |
| 148 | + rc=$?; rm -rf "$d" >/dev/null 2>&1; exit $rc |
| 149 | + msg: The Docker builder must support cache export for runtime parity coverage |
| 150 | + cmds: |
| 151 | + - rm -rf artifacts/coverage/data/runtime |
| 152 | + - mkdir -p artifacts/coverage/data/runtime |
| 153 | + - GOCOVERDIR={{.ROOT_DIR}}/artifacts/coverage/data/runtime CLI_GO={{.ROOT_DIR}}/artifacts/coverage/bin/{{.BINARY}} PARITY_REPORT_FILE={{.ROOT_DIR}}/artifacts/parity-runtime.json PARITY_STRICT=true PARITY_LANE=all go test ./internal/cli -run '^TestParityMatrix$' -count=1 -parallel {{.PARITY_PARALLEL | default "2"}} -timeout 60m -v {{.CLI_ARGS}} |
| 154 | + - go tool covdata textfmt -i=artifacts/coverage/data/runtime -o=artifacts/coverage/parity-runtime.out |
| 155 | + - go tool cover -func=artifacts/coverage/parity-runtime.out |
| 156 | + |
| 157 | + coverage:parity-publish: |
| 158 | + desc: Measure real feature/template publication against an ephemeral OCI registry |
| 159 | + deps: [build:coverage, reference:compile] |
| 160 | + preconditions: |
| 161 | + - sh: docker info >/dev/null 2>&1 |
| 162 | + msg: Docker is required for publish parity coverage |
| 163 | + cmds: |
| 164 | + - rm -rf artifacts/coverage/data/publish |
| 165 | + - mkdir -p artifacts/coverage/data/publish |
| 166 | + - GOCOVERDIR={{.ROOT_DIR}}/artifacts/coverage/data/publish CLI_GO={{.ROOT_DIR}}/artifacts/coverage/bin/{{.BINARY}} go test ./internal/cli -run '^TestPublishParity$' -count=1 -timeout 10m -v {{.CLI_ARGS}} |
| 167 | + - go tool covdata textfmt -i=artifacts/coverage/data/publish -o=artifacts/coverage/parity-publish.out |
| 168 | + - go tool cover -func=artifacts/coverage/parity-publish.out |
| 169 | + |
111 | 170 | test:e2e: |
112 | 171 | desc: Run Go E2E tests with Docker |
113 | 172 | deps: [build] |
|
0 commit comments