test(ci): read sparse android guard files from git · openclaw/openclaw@9ff7abc
vincentkoc
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Ci Workflow Guards tests cover ci workflow guards script behavior. |
2 | | -import { readdirSync, readFileSync } from "node:fs"; |
| 2 | +import { execFileSync } from "node:child_process"; |
| 3 | +import { existsSync, readdirSync, readFileSync } from "node:fs"; |
3 | 4 | import { describe, expect, it } from "vitest"; |
4 | 5 | import { parse } from "yaml"; |
5 | 6 | |
@@ -37,10 +38,17 @@ function readCriticalQualityWorkflow() {
|
37 | 38 | return readFileSync(".github/workflows/codeql-critical-quality.yml", "utf8"); |
38 | 39 | } |
39 | 40 | |
40 | | -function readAndroidCompileSdk(path: string): number { |
41 | | -const match = readFileSync(path, "utf8").match(/^\s*compileSdk\s*=\s*(\d+)\s*$/mu); |
| 41 | +function readTrackedText(relativePath: string): string { |
| 42 | +if (existsSync(relativePath)) { |
| 43 | +return readFileSync(relativePath, "utf8"); |
| 44 | +} |
| 45 | +return execFileSync("git", ["show", `:${relativePath}`], { encoding: "utf8" }); |
| 46 | +} |
| 47 | + |
| 48 | +function readAndroidCompileSdk(relativePath: string): number { |
| 49 | +const match = readTrackedText(relativePath).match(/^\s*compileSdk\s*=\s*(\d+)\s*$/mu); |
42 | 50 | if (!match) { |
43 | | -throw new Error(`Missing compileSdk in ${path}`); |
| 51 | +throw new Error(`Missing compileSdk in ${relativePath}`); |
44 | 52 | } |
45 | 53 | return Number(match[1]); |
46 | 54 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。