-
Notifications
You must be signed in to change notification settings - Fork 8
docs: work from the Linux workstation, run macOS lanes on the Mac over SSH #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #!/usr/bin/env bash | ||
| # Runs a command in a macOS build checkout over SSH, at a commit already on | ||
| # origin. For working from a Linux machine: the desktop shell (Tauri, the | ||
| # server payload, `src-tauri` cargo tests) only builds on macOS. | ||
| # | ||
| # scripts/macos-remote.sh [--ref <git ref>] -- '<command>' | ||
| # | ||
| # GAJAE_MAC_HOST ssh destination of the Mac (required) | ||
| # GAJAE_MAC_CHECKOUT build checkout on the Mac, relative to its home or | ||
| # absolute (default: workspace/gajae-code-app/.gjc-worktrees/mac-build) | ||
| # | ||
| # The ref (default HEAD) is resolved here and must already be on an origin | ||
| # branch. The checkout is disposable: it is force-checked-out to that commit | ||
| # and cleaned of untracked files (ignored build outputs are kept, so builds | ||
| # stay incremental), and `npm ci` runs again whenever package-lock.json | ||
| # differs from its last install. | ||
| # The command runs in a zsh login shell from the checkout root, e.g. | ||
| # scripts/macos-remote.sh -- 'npm run server:payload:macos && cargo test --locked --manifest-path src-tauri/Cargo.toml' | ||
| set -euo pipefail | ||
|
|
||
| ref=HEAD | ||
| while [ $# -gt 0 ]; do | ||
| case "$1" in | ||
| --ref) ref="$2"; shift 2 ;; | ||
| --) shift; break ;; | ||
| *) echo "usage: $0 [--ref <git ref>] -- '<command>'" >&2; exit 64 ;; | ||
| esac | ||
| done | ||
| command="$*" | ||
| if [ -z "$command" ]; then echo "usage: $0 [--ref <git ref>] -- '<command>'" >&2; exit 64; fi | ||
| host="${GAJAE_MAC_HOST:?set GAJAE_MAC_HOST to the ssh destination of the Mac}" | ||
| checkout="${GAJAE_MAC_CHECKOUT:-workspace/gajae-code-app/.gjc-worktrees/mac-build}" | ||
| sha="$(git rev-parse --verify "$ref^{commit}")" | ||
|
|
||
| remote_script=$(cat <<'REMOTE' | ||
| set -e | ||
| cd "$HOME" | ||
| cd "$GAJAE_CHECKOUT" | ||
| git fetch --quiet --prune origin | ||
| # Reachable from a remote-tracking branch, not merely present in the Mac's | ||
| # object store, which also holds the Mac's own unpushed work. | ||
| if [ -z "$(git branch -r --contains "$GAJAE_SHA" 2>/dev/null)" ]; then | ||
| print -u2 "macos-remote: $GAJAE_SHA is not on origin; push it first." | ||
| exit 65 | ||
| fi | ||
| git checkout --quiet --force --detach "$GAJAE_SHA" | ||
| # Untracked leftovers go; ignored build outputs (node_modules, cargo target, | ||
| # the server payload) stay so builds remain incremental. | ||
| git clean -fdq | ||
| lock="$(shasum -a 256 package-lock.json | cut -d' ' -f1)" | ||
| if [ "$(cat node_modules/.macos-remote-lock 2>/dev/null)" != "$lock" ]; then | ||
| npm ci --no-audit --no-fund | ||
| print -r -- "$lock" > node_modules/.macos-remote-lock | ||
| fi | ||
| print -r -- "macos-remote: $(git log --oneline -1) on $(hostname -s)" | ||
| eval "$GAJAE_COMMAND" | ||
| REMOTE | ||
| ) | ||
|
|
||
| ssh -o BatchMode=yes "$host" /bin/zsh -l -s <<EOF | ||
| GAJAE_CHECKOUT=$(printf %q "$checkout") | ||
| GAJAE_SHA=$sha | ||
| GAJAE_COMMAND=$(printf %q "$command") | ||
| $remote_script | ||
| EOF | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.