Skip to content

Commit a43060e

Browse files
committed
ci: make platform verification portable
1 parent 693997f commit a43060e

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
test "$("$binary" --version)" = "sno $version"
9292
help="$($binary --help)"
9393
for command in account station starport; do
94-
rg -q "^[[:space:]]+$command" <<<"$help"
94+
grep -Eq "^[[:space:]]+$command([[:space:]]|$)" <<<"$help"
9595
done
9696
profile="$(mktemp -d)"
9797
test "$(SNO_PROFILE_DIR="$profile" "$binary" station telemetry consent get --json)" = '{"consent":"metadata-only"}'
@@ -154,7 +154,7 @@ jobs:
154154
test "$(docker run --rm --pull=always -v "$binary:/sno:ro" "$image" /sno --version)" = "sno $version"
155155
help="$(docker run --rm -v "$binary:/sno:ro" "$image" /sno --help)"
156156
for command in account station starport; do
157-
rg -q "^[[:space:]]+$command" <<<"$help"
157+
grep -Eq "^[[:space:]]+$command([[:space:]]|$)" <<<"$help"
158158
done
159159
output="$(docker run --rm -v "$binary:/sno:ro" -v "$profile:/profile" -e SNO_PROFILE_DIR=/profile "$image" /sno station telemetry consent get --json)"
160160
test "$output" = '{"consent":"metadata-only"}'

policy/test-substitutes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"vi\\.mock\\s*\\(",
2525
"mockery\\.patch",
2626
"monkeypatch\\.",
27-
"(?<![A-Za-z0-9_])patch\\s*\\(",
27+
"(^|[^A-Za-z0-9_])patch\\s*\\(",
2828
"(struct|class)\\s+(Fake|Mock)(FileSystem|Filesystem|Database|Db|Process|Command|Service)",
2929
"(Fake|Mock)(FileSystem|Filesystem|Database|Db|Process|Command|Service)\\s*[({]",
3030
"InMemory(FileSystem|Filesystem|Database|Db|Process)"

scripts/check-test-substitutes.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ source_pattern="$(jq -r '.banned_source_patterns | join("|")' "$policy")"
3737
server_pattern="$(jq -r '.service_server_patterns | join("|")' "$policy")"
3838

3939
mapfile -t manifests < <(printf '%s\n' "${files[@]}" | rg '/(Cargo\.toml|package\.json|pyproject\.toml)$' || true)
40-
if [[ "${#manifests[@]}" -gt 0 ]] && rg -n -i --pcre2 "(^|[^A-Za-z0-9_-])($dependency_pattern)([^A-Za-z0-9_-]|$)" "${manifests[@]}"; then
40+
if [[ "${#manifests[@]}" -gt 0 ]] && rg -n -i "(^|[^A-Za-z0-9_-])($dependency_pattern)([^A-Za-z0-9_-]|$)" "${manifests[@]}"; then
4141
fail "forbidden mocking dependency detected"
4242
fi
4343

44-
if rg -n --pcre2 "$source_pattern" "${files[@]}"; then
44+
if rg -n "$source_pattern" "${files[@]}"; then
4545
fail "forbidden internal mock or monkey-patch detected"
4646
fi
4747

@@ -52,7 +52,7 @@ while IFS= read -r server_file; do
5252
printf '%s\n' "$relative" >&2
5353
fail "undeclared service replacement detected"
5454
}
55-
done < <(rg -l --pcre2 "$server_pattern" "${files[@]}" || true)
55+
done < <(rg -l "$server_pattern" "${files[@]}" || true)
5656

5757
while IFS= read -r allowed_path; do
5858
[[ -n "$allowed_path" ]] || continue

scripts/test-test-substitute-policy.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ printf '[package]\nname = "seed"\nversion = "0.0.0"\n' >"$tmp_dir/colocated/Carg
3131
printf '#[cfg(test)] mod tests { mock!(InternalService {}); }\n' >"$tmp_dir/colocated/src/lib.rs"
3232
expect_failure colocated
3333

34+
mkdir -p "$tmp_dir/patch/tests"
35+
printf '[package]\nname = "seed"\nversion = "0.0.0"\n' >"$tmp_dir/patch/Cargo.toml"
36+
printf 'patch("module.internal");\n' >"$tmp_dir/patch/tests/internal.py"
37+
expect_failure patch
38+
3439
for kind in filesystem database process; do
3540
mkdir -p "$tmp_dir/fake-$kind/src"
3641
printf '[package]\nname = "seed"\nversion = "0.0.0"\n' >"$tmp_dir/fake-$kind/Cargo.toml"
@@ -58,4 +63,4 @@ printf 'let listener = TcpListener::bind("127.0.0.1:0");\n' >"$tmp_dir/allowed/t
5863
"$checker" "$tmp_dir/allowed" "$policy" >/dev/null
5964

6065
"$checker" "$repo_root" "$policy" >/dev/null
61-
printf 'test-substitute policy self-test passed: 8 forbidden mutations rejected, allowlist and repository accepted\n'
66+
printf 'test-substitute policy self-test passed: 9 forbidden mutations rejected, allowlist and repository accepted\n'

tests/support/sno_service_server.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ impl SnoServiceServer {
5757
Err(error) => panic!("accept request: {error}"),
5858
}
5959
};
60+
stream
61+
.set_nonblocking(false)
62+
.expect("set request stream blocking");
6063
stream
6164
.set_read_timeout(Some(Duration::from_secs(2)))
6265
.expect("set request timeout");

0 commit comments

Comments
 (0)