Skip to content

Conversation

@julerex
Copy link

@julerex julerex commented Jan 30, 2026

…d quiet log bootstrap in tests

  • compile_and_run: use Scripts/package_app.sh (capital S) to match repo
  • package_app: add resolve_binary_path() fallback to .build/$CONF/ when SwiftPM builds for host only; use it for install_binary and PREFERRED_BUILD_DIR
  • CodexBarLog: detect XCTest/Swift Testing and auto-bootstrap with minimal config to avoid log spam in CI

…d quiet log bootstrap in tests

- compile_and_run: use Scripts/package_app.sh (capital S) to match repo
- package_app: add resolve_binary_path() fallback to .build/$CONF/ when SwiftPM builds for host only; use it for install_binary and PREFERRED_BUILD_DIR
- CodexBarLog: detect XCTest/Swift Testing and auto-bootstrap with minimal config to avoid log spam in CI
@julerex julerex changed the title Fix Scripts path casing, package_app for host-only SwiftPM builds, an… fix: Scripts path casing, host-only SwiftPM builds, quiet test logs Jan 30, 2026
@julerex
Copy link
Author

julerex commented Jan 30, 2026

Input from Github Copilot GPT5-mini:

I loaded the repository-code-search ability and inspected the PR description plus the relevant scripts (notably Scripts/package_app.sh and Scripts/compile_and_run.sh) to see what the changes do and how they interact with the rest of the repo. I also ran quick code searches for script path usages and packaging logic to confirm where the fixes are required. The search results may be incomplete — you can view more results in the GitHub UI here: https://github.com/steipete/CodexBar/search?q=package_app.sh&type=code

High-level read: the PR fixes a path-casing bug (Scripts vs scripts), adds a fallback to resolve_binary_path/.build/$CONF for SwiftPM host-only builds (so package_app can find SwiftPM-built products), and quiets/spawns a minimal CodexBarLog bootstrap in XCTest/Swift test environments to reduce CI log noise. Those changes look sensible; below are focused suggestions and checks to make the behavior more robust and reduce future regressions.

Suggested action items (prioritized, actionable)

  1. Enforce path-casing consistency and add a regression check
  • Problem: case mismatch (Scripts vs scripts) can be invisible on macOS (case-insensitive) but break on case-sensitive filesystems.
  • Action:
    • Grep for inconsistent references and fix them all:
      • git grep -n '/scripts/' || true
      • git grep -n 'Scripts/' || true
    • Add a CI check (fast job) that fails if any lower-case "/scripts/" references exist (or better: fail if any references do not match the canonical directory name). Example quick check to add to CI:
      • if git grep -n '/scripts/' >/dev/null; then echo "Found '/scripts/' references; use 'Scripts/'" >&2; exit 1; fi
    • Alternatively add a small unit (lint) step that validates that all script invocations match the repo path exactly.
  • Rationale: prevents accidental regressions where dev machines don't catch casing bugs.
  1. Make resolve_binary_path / PREFERRED_BUILD_DIR discovery more robust
  • Problem: SwiftPM and Xcode produce slightly different .build layouts; relying on a single heuristic can fail in edge cases.
  • Suggestions:
    • Prefer using swift build --show-bin-path (or swift build -c "$CONF" --show-bin-path) when available to get the actual bin path for the build configuration. Example:
      • PREFERRED_BUILD_DIR="$(swift build -c "${CONF}" --show-bin-path 2>/dev/null || dirname "$(build_product_path "CodexBar" "${ARCH_LIST[0]}")")"
    • Keep the current .build/$CONF fallback, but treat it as a fallback only.
    • Ensure resolve_binary_path handles Debug vs Release naming and per-arch directories (e.g., .build/arm64-apple-macosx/release vs .build/release).
  • Rationale: more reliable in CI and for Xcode-built artifacts.
  1. Validate the install_binary / verify_binary_arches logic for single-arch host-only builds
  • Things to check:
    • When host-only (single arch), ensure build_product_path returns the right path and verify_binary_arches does not falsely assert a mismatch.
    • Edge cases: Github Actions macOS runners on arm64 vs x86_64; confirm ARCH_LIST detection and lipo use is correct (lipo is used only when multiple arches).
  • Action: add a CI job that performs:
    • swift build -c debug
    • run Scripts/package_app.sh in a dry-run mode (or with echo/tracing) to assert it finds binaries and bundles SwiftPM resource bundles correctly.
  1. SwiftPM resource bundle detection (SWIFTPM_BUNDLES)
  • Problem: script glob uses PREFERRED_BUILD_DIR to find *.bundle — if PREFERRED_BUILD_DIR is wrong, packaging will fail.
  • Suggestion: after determining PREFERRED_BUILD_DIR, print a diagnostic message when it’s a fallback (so CI logs show what path was used). Consider also checking both candidate locations:
    • candidate1="$(swift build --show-bin-path 2>/dev/null)"
    • candidate2=".build/$CONF"
    • candidate3="$(dirname "$(build_product_path ... )")"
  • Action: add a small log line: "Using PREFERRED_BUILD_DIR=..." so it's easy to debug packaging failures.
  1. CodexBarLog test-time detection: ensure detection covers all test runners/environments
  • Things to confirm:
    • Which signals are used to detect XCTest / Swift testing? (Common env vars include XCT, XCODE_RUNNING_FOR_TESTING, or XCTestConfigurationFilePath.)
    • Ensure detection covers both XCTest run via Xcode and swift test (and the new Swift testing infra).
  • Action:
    • Add unit tests that run under swift test asserting the logger does minimal bootstrapping (no network or heavy IO).
    • Add a CI run that runs swift test and ensures logging is quiet (or at least no noisy bootstrap logs are emitted).
  • Rationale: avoid surprising behavior where tests rely on logs or the log bootstrap causes failures.
  1. Add shellcheck / bash -n / linters for scripts
  • Add a lightweight script lint job (shellcheck where possible or bash -n) to CI to catch syntax issues early.
  • For packaging scripts that must run on macOS only, consider a small macOS CI job to run the scripts with a DRY_RUN=1 mode (if you add that), or run them in a non-destructive mode that asserts they locate binaries and bundles.
  1. Update docs & dev instructions
  • The docs mention ./Scripts/package_app.sh and ./Scripts/compile_and_run.sh in several places; ensure docs reflect the correct casing and any new behavior (resolve_binary_path fallback).
  • Add a short note in docs/packaging.md that the packaging script now correctly locates host-only SwiftPM builds and how to override PREFERRED_BUILD_DIR if needed.
  1. CI to exercise packaging on both arch hosts (optional but recommended)
  • If you frequently build universal or on different architectures, add a GitHub Actions matrix that runs package_app.sh on both macOS-latest runners (arm64 and x86_64) or at least simulate the different outputs.
  • This will catch arch-specific path issues early.
  1. Minor PR hygiene and tests
  • Include an explicit entry in the PR body listing commands you ran locally (particularly swift test and Scripts/compile_and_run.sh) and the expected CI changes.
  • If CodexBarLog change impacts tests, add or update tests that confirm logging suppression in CI; that will make reviewer confidence higher.

If you want, I can:

  • Run a repo-wide search for inconsistent '/scripts/' references and list the occurrences (I can produce a patch or PR to fix them).
  • Draft a small CI job snippet to add to .github/workflows that enforces script path casing and runs shellcheck / bash -n for Scripts/.
  • Propose a small change to package_app.sh to prefer swift build --show-bin-path with a safe fallback (I can draft the exact shell snippet).

Which of those would you like me to do next?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant