Skip to content

Commit 0ce913f

Browse files
committed
fix(ci): publish coverage prerequisites atomically
1 parent 3688d87 commit 0ce913f

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎.github/workflows/code-qa.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,17 @@ jobs:
164164
shell: bash
165165
run: |
166166
test -s src/coverage/unit/lcov.info
167-
grep -q '^SF:' src/coverage/unit/lcov.info
168-
grep -Eq '^LH:[1-9][0-9]*$' src/coverage/unit/lcov.info
167+
awk '
168+
/^SF:/ { if (in_record) invalid=1; in_record=1; covered=0; next }
169+
/^LH:[1-9][0-9]*$/ { if (!in_record) invalid=1; covered=1; next }
170+
/^end_of_record$/ {
171+
if (!in_record) invalid=1
172+
any_covered = any_covered || covered
173+
in_record=0
174+
covered=0
175+
}
176+
END { exit !(any_covered && !in_record && !invalid) }
177+
' src/coverage/unit/lcov.info
169178
- name: Save Turbo cache
170179
if: steps.turbo-cache.outputs.cache-hit != 'true'
171180
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0

‎src/scripts/copy-tree-sitter-wasms.mjs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "node:fs"
22
import path from "node:path"
3+
import process from "node:process"
34
import { fileURLToPath } from "node:url"
45

56
const srcDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
@@ -10,6 +11,14 @@ fs.mkdirSync(distDir, { recursive: true })
1011

1112
for (const filename of fs.readdirSync(wasmDir)) {
1213
if (filename.endsWith(".wasm")) {
13-
fs.copyFileSync(path.join(wasmDir, filename), path.join(distDir, filename))
14+
const destination = path.join(distDir, filename)
15+
const temporary = `${destination}.${process.pid}.tmp`
16+
17+
try {
18+
fs.copyFileSync(path.join(wasmDir, filename), temporary)
19+
fs.renameSync(temporary, destination)
20+
} finally {
21+
fs.rmSync(temporary, { force: true })
22+
}
1423
}
1524
}

0 commit comments

Comments
 (0)