Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/release-prebuilt-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ jobs:
include:
- package_name: hunkdiff-linux-arm64
runner: ubuntu-24.04-arm
target_triple: bun-linux-arm64-musl
- package_name: hunkdiff-linux-x64
runner: ubuntu-latest
target_triple: bun-linux-x64-musl
- package_name: hunkdiff-windows-x64
runner: windows-latest
- package_name: hunkdiff-darwin-x64
Expand All @@ -55,6 +57,8 @@ jobs:
run: bun install --frozen-lockfile

- name: Build host artifact
env:
HUNK_TARGET_TRIPLE: ${{ matrix.target_triple }}
run: |
bun run build:bin
bun run ./scripts/build-prebuilt-artifact.ts --expect-package "${{ matrix.package_name }}"
Comment on lines 59 to 64
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 HUNK_TARGET_TRIPLE always injected for every matrix entry

The env: HUNK_TARGET_TRIPLE: ${{ matrix.target_triple }} block is attached unconditionally, so macOS runners receive HUNK_TARGET_TRIPLE="" (GitHub Actions resolves undefined matrix properties to empty string). The build script's [[ -n "${HUNK_TARGET_TRIPLE:-}" ]] guard makes this safe today, but any future consumer of that env var that doesn't apply the same guard will silently inherit an empty target. Consider making the env injection conditional with an if: matrix.target_triple != '' step-level condition, or move the env var into the matrix entries that need it.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/release-prebuilt-npm.yml
Line: 57-62

Comment:
**`HUNK_TARGET_TRIPLE` always injected for every matrix entry**

The `env: HUNK_TARGET_TRIPLE: ${{ matrix.target_triple }}` block is attached unconditionally, so macOS runners receive `HUNK_TARGET_TRIPLE=""` (GitHub Actions resolves undefined matrix properties to empty string). The build script's `[[ -n "${HUNK_TARGET_TRIPLE:-}" ]]` guard makes this safe today, but any future consumer of that env var that doesn't apply the same guard will silently inherit an empty target. Consider making the env injection conditional with an `if: matrix.target_triple != ''` step-level condition, or move the env var into the matrix entries that need it.

How can I resolve this? If you propose a fix, please make it concise.

Expand Down
9 changes: 8 additions & 1 deletion scripts/build-bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ const legacyOutfile = path.join(distDir, process.platform === "win32" ? "otdiff.
mkdirSync(distDir, { recursive: true });
rmSync(legacyOutfile, { force: true });

const buildArgs = ["bun", "build", "--compile"];
const targetTriple = process.env.HUNK_TARGET_TRIPLE;
if (targetTriple) {
buildArgs.push("--target", targetTriple);
}
buildArgs.push(path.join(repoRoot, "src", "main.tsx"), "--outfile", outfile);

const proc = Bun.spawnSync(
["bun", "build", "--compile", path.join(repoRoot, "src", "main.tsx"), "--outfile", outfile],
buildArgs,
{
cwd: repoRoot,
stdin: "inherit",
Expand Down
Loading