From 09bb2740a7333b83364ea185af1802456e7952c4 Mon Sep 17 00:00:00 2001 From: mini Date: Tue, 2 Jun 2026 02:22:55 +0900 Subject: [PATCH] fix(portable): replace author-machine path + add portable-path CI gate The disabled benchmark test hard-coded the upstream author's machine path (/Users/mitchellh/Documents/void/bug.osc.txt). Derive it from NSHomeDirectory() so the fixture path is portable across machines. Add .github/workflows/portable-path-gate.yml: a pure-bash PR gate that fails when an ADDED source line (*.zig/*.c/*.h/*.swift/*.sh/*.py, excluding vendor/deps/pkg and comment lines) introduces a /Users// or /home// machine-absolute path. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/portable-path-gate.yml | 29 ++++++++++++++++++++++++ macos/Tests/BenchmarkTests.swift | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/portable-path-gate.yml diff --git a/.github/workflows/portable-path-gate.yml b/.github/workflows/portable-path-gate.yml new file mode 100644 index 000000000..85eb6f4cf --- /dev/null +++ b/.github/workflows/portable-path-gate.yml @@ -0,0 +1,29 @@ +name: portable-path-gate +on: + pull_request: { branches: ['**'] } + workflow_dispatch: +permissions: { contents: read } +jobs: + no-foreign-path: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + - shell: bash + run: | + set -euo pipefail + base="origin/${{ github.base_ref }}" + git fetch --quiet origin "${{ github.base_ref }}" + hits="$(git diff -U0 "$base...HEAD" -- '*.zig' '*.c' '*.h' '*.swift' '*.sh' '*.py' \ + ':(exclude)vendor/**' ':(exclude)deps/**' ':(exclude)pkg/**' \ + | grep -E '^\+[^+]' | sed -E 's/^\+//' \ + | grep -E '/(Users|home)/[A-Za-z][A-Za-z0-9._-]+/' \ + | grep -vE '^[[:space:]]*(//|#|\*)' || true)" + if [ -n "$hits" ]; then + echo "🚫 FAIL — added source line(s) introduce a machine-absolute author path:" + echo "$hits" + echo "Use \$HOME / NSHomeDirectory() / env-derived paths, or a generic placeholder." + exit 1 + fi + echo "✅ PASS — no foreign machine-absolute paths in added source lines." diff --git a/macos/Tests/BenchmarkTests.swift b/macos/Tests/BenchmarkTests.swift index 4a4d50390..899764617 100644 --- a/macos/Tests/BenchmarkTests.swift +++ b/macos/Tests/BenchmarkTests.swift @@ -5,6 +5,7 @@ // Created by Mitchell Hashimoto on 7/9/25. // +import Foundation import Testing import VoidKit @@ -27,6 +28,6 @@ struct BenchmarkTests { @Test func example() async throws { void_benchmark_cli( "terminal-stream", - "--data=/Users/mitchellh/Documents/void/bug.osc.txt") + "--data=\(NSHomeDirectory())/Documents/void/bug.osc.txt") } }