diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d45d517 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Keep LF everywhere, including on Windows checkouts: prettier --check expects +# LF, and GitHub's Windows runners otherwise check files out with CRLF. +* text=auto eol=lf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c50ec8..fe7397c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,8 @@ name: CI -# Runs on the org-level self-hosted runners, the same pair conflower-player uses: -# [self-hosted, macOS] -> Brooklyn-Studio -# [self-hosted, Windows] -> PROTO1-P8 -# Packaging is deliberately not done here; see release.yml. +# Runs on GitHub-hosted runners, never on our own machines: the repository is +# public, and a pull request from a fork runs its own code in this workflow. +# See docs/RUNNERS.md. Packaging is deliberately not done here; see release.yml. on: push: @@ -11,28 +10,29 @@ on: pull_request: workflow_dispatch: +permissions: + contents: read + concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: macos: - runs-on: [self-hosted, macOS] + runs-on: macos-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 with: node-version: '24' - # Self-hosted runners keep their working directory, and the generated - # folders are gitignored so checkout leaves them behind. - - run: npm run clean + cache: npm - run: npm ci - run: npm run lint - run: npm run format:check - run: npm run check - run: npm run build - run: npm run build:seed - # Opens a real window, so the runner needs a logged-in desktop session. + # Opens a real window; GitHub's macOS runners have a desktop session. # Gating here: this is the job that proves the packaged shell still works. - run: npm run smoke # The embeddable web build is a shipped artifact, so it gets the same @@ -41,25 +41,20 @@ jobs: - run: npm run smoke:embed windows: - runs-on: [self-hosted, Windows] + runs-on: windows-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 with: node-version: '24' - - run: npm run clean + cache: npm - run: npm ci - run: npm run lint - run: npm run format:check - run: npm run check - run: npm run build - run: npm run build:seed - # Gating: PROTO1-P8 runs in a logged-in session. If the runner is ever - # re-registered as a Windows service it will lose its interactive desktop - # and this needs continue-on-error. - run: npm run smoke # The embed artifact is platform independent, so running it on both runners - # is redundant in principle. It runs here anyway: it is the only place it - # gets exercised while Brooklyn-Studio is offline, and redundant coverage is - # cheaper than none. + # is redundant in principle; it is cheap, so it runs on both. - run: npm run smoke:embed diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f25593..e66f131 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,10 +5,8 @@ # from anywhere else is not possible. The two jobs are independent and each # publishes its own assets, so one platform failing does not block the other. # -# Runners are the org-level pair, the same ones conflower-player uses: -# [self-hosted, macOS] -> Brooklyn-Studio -# [self-hosted, Windows] -> PROTO1-P8 -# The org runner group must grant this repository access. +# Runs on GitHub-hosted runners, never on our own machines (docs/RUNNERS.md). +# Only people with write access can trigger it: a tag push or a manual run. # # To ship: # npm version 0.2.0 --no-git-tag-version @@ -34,14 +32,14 @@ env: # The tag being released, whether this was a tag push or a manual re-run. TAG: ${{ github.event.inputs.ref || github.ref_name }} -# One release at a time: both jobs reuse a working directory on their machine. +# One release at a time, so two runs never race to publish the same tag. concurrency: group: release cancel-in-progress: false jobs: macos: - runs-on: [self-hosted, macOS] + runs-on: macos-latest steps: - uses: actions/checkout@v5 with: @@ -64,12 +62,6 @@ jobs: fi echo "runner arch: $arch" - # A self-hosted runner keeps its working directory between runs, and the - # generated folders are gitignored, so checkout leaves them in place. Stale - # artifacts from an older version would otherwise be swept up by the - # release upload below. - - run: npm run clean - - run: npm ci # electron-builder names every artifact from the package.json version, so a @@ -131,7 +123,7 @@ jobs: if-no-files-found: error windows: - runs-on: [self-hosted, Windows] + runs-on: windows-latest steps: - uses: actions/checkout@v5 with: @@ -141,7 +133,6 @@ jobs: with: node-version: '24' - - run: npm run clean - run: npm ci - name: Tag must match package.json @@ -157,8 +148,7 @@ jobs: - run: npm run check - run: npm run prepackage - # A Windows runner registered as a service has no interactive desktop, and - # the smoke test cannot open a window without one. + # Advisory, as on the mac job: ci.yml is where this gates. - name: Smoke test continue-on-error: true run: npm run smoke @@ -166,9 +156,8 @@ jobs: # See the mac job: build only, publish explicitly below. - run: npx electron-builder --win --publish never - # A javascript action rather than the gh cli: gh is not installed on this - # runner, and assuming a cli exists on a hand-provisioned machine is how the - # first release attempt failed. This needs nothing but the runner's own node. + # A javascript action rather than the gh cli, so it needs nothing but the + # runner's own node. - name: Publish release assets if: startsWith(env.TAG, 'v') uses: softprops/action-gh-release@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index bdde0f0..308786f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,11 @@ from one version to the next. ## [Unreleased] -Nothing yet. +### Fixed + +- On Windows, editing an interface did not reload it when the workspace path + contained a short (8.3) folder name, such as `C:\Users\RUNNER~1\...`. The + watcher now follows the folder's full path. ## [0.1.1] - 2026-08-26 diff --git a/docs/DISTRIBUTION.md b/docs/DISTRIBUTION.md index 6c39b4d..7ed1aac 100644 --- a/docs/DISTRIBUTION.md +++ b/docs/DISTRIBUTION.md @@ -43,9 +43,8 @@ map, theirs is merged and their mapping wins, since a document may only have one Both run `npm run prepackage` first, which builds the host bundle, the standalone SDK, the type declarations, and the workspace seed. -`.github/workflows/release.yml` builds and publishes both platforms on the -org-level self-hosted runners. See `RUNNERS.md` for which machines those are and -the one permission that has to be granted. +`.github/workflows/release.yml` builds and publishes both platforms on +GitHub-hosted runners. See `RUNNERS.md` for why never our own machines. ### One gotcha with npm 11 install scripts @@ -78,9 +77,8 @@ JavaScript MIME type, the injected import map actually resolving `@planchette/sd path traversal out of the workspace being refused, the file watcher reloading the app, and pucks surviving that reload. -It opens a window, so it needs an interactive desktop session. In CI it gates the -macOS job and is advisory on Windows, since self-hosted Windows runners often run -as a service with no desktop. +It opens a window, so it needs an interactive desktop session. GitHub's hosted +runners have one; in CI it gates both jobs, and in a release it is advisory. ## Icons @@ -129,7 +127,8 @@ Nothing here needs rework. - **macOS**: get an Apple Developer ID, remove `mac.identity: null` from `electron-builder.yml`, and set `APPLE_ID`, `APPLE_APP_SPECIFIC_PASSWORD`, and - `APPLE_TEAM_ID` on the runner so electron-builder notarizes. The ad-hoc hook + `APPLE_TEAM_ID` as repository secrets passed to the release job's environment, so + electron-builder notarizes. The ad-hoc hook becomes a no-op you can delete. - **Windows**: add a `win.certificateFile` or use a signing service, and drop the SmartScreen instructions. diff --git a/docs/RUNNERS.md b/docs/RUNNERS.md index a42b029..be54953 100644 --- a/docs/RUNNERS.md +++ b/docs/RUNNERS.md @@ -1,205 +1,28 @@ # CI runners -Both workflows run on the **org-level** self-hosted runners, the same machines -conflower-player builds on. Nothing needs registering. +Both workflows run on **GitHub-hosted runners** (`macos-latest`, `windows-latest`), +never on the studio's self-hosted machines. -| Job | Label set | Machine | -| --- | --------- | ------- | -| macOS build and release | `[self-hosted, macOS]` | `hqmbp26-crouse`, or `Brooklyn-Studio` and `jeffbook-mac` when they are up | -| Windows build and release | `[self-hosted, Windows]` | `PROTO1-P8` | +## Why not our own machines -Both live in the org runner group `default`. There are no repo-scoped runners on -this repository, and none are wanted: repo-scoped runners cannot be shared, which -is how conflower-player ended up with a separate pair. +The repository is public. Anyone can fork it and open a pull request, and +`ci.yml` runs on pull requests, so the code in that pull request runs on whatever +machine picks up the job. On a GitHub-hosted runner that is a fresh virtual +machine, thrown away afterwards. On one of our machines it would be a stranger's +code on a studio computer, with whatever that computer can reach. GitHub's own +guidance is never to use self-hosted runners with a public repository. -## Verified +`release.yml` only runs on a tag push or a manual run, both of which need write +access, but it uses hosted runners too: one setup, nothing to maintain. -The first CI run proved most of this rather than assuming it: +## What this costs -- The Windows job is picked up by `PROTO1-P8` immediately, and `npm ci`, - `npm run check`, `npm run build` and `npm run build:seed` all pass. That - confirms the pinned `allowScripts` approval for Electron's binary download - works in CI, which was the main unknown. -- Repository access through the org runner group is therefore already granted. - Nothing needed adding. -- Both platforms now pass in full. `hqmbp26-crouse` was registered as an org - runner on 2026-08-21 and picks up macOS jobs immediately: checkout, `npm ci`, - typecheck, all three builds, the workspace seed, the 23-check desktop smoke test - and the 19-check embed test. -- Before that, the macOS job sat unassigned across four runs. Labels and group - access were fine the whole time, proven by Windows working from the same group. - `Brooklyn-Studio` was simply offline; its last job in any repo was 2026-08-12. +Nothing: GitHub-hosted runners are free for public repositories. A fresh machine +also means no stale build output to clean between runs, which is what +`scripts/clean.mjs` was originally for. -**Correction.** An earlier version of this file claimed the Windows smoke test -passed on the first run. It did not. `continue-on-error: true` reports a failed -step's conclusion as `success`, and that was read as a pass. The smoke test had -been failing on Windows from the first run with `spawn EINVAL`, because Node 20.12 -and later refuse to spawn a `.cmd` file without `shell: true` and the script -launched Electron through `npx.cmd`. It now resolves the Electron binary directly. +## If signing ever needs a certificate -With that fixed, the Windows smoke test **does** pass on `PROTO1-P8`: all 23 -checks, Electron window and all. This time the pass is real rather than masked, -because the step is gating and the run immediately before it reported `failure`, -which a `continue-on-error` step cannot do. So that machine has an interactive -desktop. - -## The one thing that has to be true - -The org runner group must **grant this repository access**. Org runner groups are -allow-lists; a new repo gets nothing by default, and jobs simply queue forever -with no error. - -GitHub → organisation **Potion** → Settings → Actions → Runner groups → -`default` → Repository access → add `planchette`. - -Symptom if this is missed: a run sits at "Waiting for a runner to pick up this -job" indefinitely. It is not a label problem, and re-running will not help. - -Access **is** currently granted, so the same symptom now means the machine for -that platform is offline. To tell the two apart, look at whether the other -platform's job started: if one runs and the other queues, it is a machine, not a -permission. - -## Adding a Mac runner - -`hqmbp26-crouse` was added this way on 2026-08-21, org level, so it is available -to other Potion projects as well as this one. Repo level is the tighter choice for -a personal machine, since an org runner can be used by any repository its group -allows; org level is the right call if you do want to share it. - -**Registering and running are two separate steps**, and it is easy to do the first -and think you are finished. `config.sh` writes the settings and exits, at which -point GitHub lists the runner but it is offline and jobs queue with no error. The -`svc.sh` lines below are what actually make it pick up work. A quick way to tell -them apart: if `~/actions-runner/_diag/Runner_*.log` has no `Listening for Jobs` -line, the runner has never run. - -Everything else is already in place on a machine set up for this repo: Node, -git, `zip`, and the Xcode command line tools for `codesign`. The `allowScripts` -approval for Electron's binary download is committed in `package.json`, so -`npm ci` needs no intervention. - -```sh -mkdir -p ~/actions-runner && cd ~/actions-runner -curl -O -L https://github.com/actions/runner/releases/download/v2.336.0/actions-runner-osx-arm64-2.336.0.tar.gz -tar xzf actions-runner-osx-arm64-2.336.0.tar.gz - -# Fetched inline so the registration token never lands in a shell history or a -# transcript. It expires in an hour and only permits adding a runner. -TOKEN=$(gh api -X POST repos/Potion/planchette/actions/runners/registration-token --jq .token) -./config.sh --url https://github.com/Potion/planchette --token "$TOKEN" --unattended --replace - -# Registration is done at this point, and the runner is still offline. This is -# the part that matters: -./svc.sh install -./svc.sh start -``` - -Confirm it is actually listening, not merely registered: - - launchctl list | grep actions.runner - -No custom labels are needed. GitHub applies `self-hosted`, `macOS` and `ARM64` -automatically, and the workflows ask for `[self-hosted, macOS]`. - -Check it took: - - gh api repos/Potion/planchette/actions/runners --jq '.runners[] | "\(.name) \(.status) \(.labels|map(.name)|join(","))"' - -### Three things about a laptop that a desktop would not have - -**`svc.sh` installs a LaunchAgent, not a LaunchDaemon.** That is what makes the -smoke tests work, because a LaunchAgent runs inside your logged-in session and so -has a desktop to open a window on. It also means the runner is offline whenever -you are logged out. - -**Sleep takes the runner offline mid-job.** For a long release build, hold it -awake: - - caffeinate -dimsu -w $(pgrep -f Runner.Listener | head -1) - -**Three Macs will answer `[self-hosted, macOS]`** once this one is registered: -this machine, `jeffbook-mac`, and `Brooklyn-Studio` when it returns. Jobs land on -whichever is free, so a release can build on any of them. All are Apple Silicon, -so the artifacts are identical; the only cost is unpredictability about which -machine did the work. If that matters, add a `planchette` label to the one you -want and change `runs-on` to `[self-hosted, macOS, planchette]`. - -## What each machine needs installed - -Both already build other projects, so most of this is present. - -**macOS** (`Brooklyn-Studio`) -- Node 24. `actions/setup-node` installs it into the runner tool cache on first - use, so nothing needs doing by hand. -- **Xcode command line tools**, for `codesign`. `scripts/adhoc-sign.cjs` ad-hoc - signs the bundle, and without a valid signature an arm64 build will not launch - at all: macOS calls it "damaged", which reads like a corrupt download and sends - people chasing the wrong problem. -- A **logged-in desktop session** if you want `npm run smoke` to pass, since it - opens a real window. It is `continue-on-error` in the release workflow on - purpose, so a headless session cannot block shipping. - -**Windows** (`PROTO1-P8`) -- Node 24, same as above. -- `npm run smoke` opens a real Electron window and passes here, so this runner - has a logged-in desktop session. It is gating in `ci.yml` so a failure is - visible rather than masked. If the runner is ever re-registered as a Windows - service it loses that desktop, and the step will need `continue-on-error`. - -Neither machine needs Wine, a Developer ID, or any signing setup. Electron's -~100MB binary download is cached per machine (`~/Library/Caches/electron`, -`%LOCALAPPDATA%\electron\Cache`) so it is paid once, not per run. - -## Why every job starts with `npm run clean` - -Self-hosted runners keep their working directory between runs, and `dist/`, -`release/`, `dist-types/`, and `workspace-seed/` are all gitignored, so -`actions/checkout` leaves them alone. Without the clean step, artifacts from an -older version survive and get swept into the next release's upload glob. This is -not hypothetical: a local build left `Touch Table Sim-0.1.0.dmg` files behind -after the rename, and a `release/*.dmg` glob would have shipped them. - -## Shipping a release - -``` -npm version 0.2.0 --no-git-tag-version -git commit -am "Release v0.2.0" -git tag v0.2.0 -git push --follow-tags -``` - -The tag triggers `release.yml`. Both platforms build in parallel and each -publishes its own assets to one GitHub Release, using create-or-upload so -whichever finishes first creates it. The release is a **draft**: download both -artifacts and run them before publishing by hand. Drop `--draft` from the two -`gh release create` calls if you would rather it went out directly. `scripts/check-version.mjs` refuses to build -if the tag and `package.json` disagree, because electron-builder names artifacts -from `package.json` and a mismatch produces a `v0.2.0` release full of `0.1.0` -files. - -Release notes come from `docs/release-notes.md`, which is mostly the Gatekeeper -and SmartScreen instructions recipients need. Swap `--notes-file` for -`--generate-notes` if you would rather have the commit list. - -## Pinning to a specific machine - -`jeffbook-mac` also answers `[self-hosted, macOS]`, so a mac job can land there -instead of on `Brooklyn-Studio`. Both are Apple Silicon, so the artifacts are -identical either way; the only cost is a build running on a laptop that might -sleep. If that becomes annoying, add a custom label such as `planchette` to -`Brooklyn-Studio` in the org runner settings and change the job to -`[self-hosted, macOS, planchette]`. - -## Signed builds, if you ever want them - -conflower-player already has Developer ID and notarization credentials as repo -secrets (`MACOS_CERT_P12`, `MACOS_CERT_PASSWORD`, `MACOS_KEYCHAIN_PASSWORD`, -`NOTARY_APPLE_ID`, `NOTARY_TEAM_ID`, `NOTARY_PASSWORD`). Copying those to this -repo, or promoting them to org secrets, would let electron-builder sign and -notarize properly, and the whole "right-click then Open" instruction disappears. - -That is a deliberate non-goal today, not an oversight. It would mean removing -`mac.identity: null` from `electron-builder.yml` and teaching -`scripts/adhoc-sign.cjs` to stand down when a real identity is present, since -ad-hoc signing afterwards would overwrite the good signature. +Real signing (see `DISTRIBUTION.md`) needs secrets. Store them as repository +secrets and pass them to the release job only. Secrets are never given to +workflows started from a fork's pull request. diff --git a/electron/main.js b/electron/main.js index 6e3b567..11186f9 100644 --- a/electron/main.js +++ b/electron/main.js @@ -427,6 +427,11 @@ let watcher = null * Tell the renderer when workspace files change, so it can reload just the app * iframe. Built-in fs.watch is enough here: recursive mode is supported on both * macOS and Windows, which keeps the packaged app free of runtime dependencies. + * + * Watch the canonical path, not the one we were given. On Windows a path with an + * 8.3 short-name component (C:\Users\RUNNER~1\..., which is what os.tmpdir() + * returns for long user names) breaks recursive fs.watch: the change never + * reaches us as an edit inside the app's folder, so nothing reloads. */ function watchWorkspace() { watcher?.close() @@ -435,7 +440,13 @@ function watchWorkspace() { let lastApp = null try { - watcher = fs.watch(workspace, { recursive: true }, (_event, filename) => { + let target = workspace + try { + target = fs.realpathSync.native(workspace) + } catch { + // Missing folder: let fs.watch below report it. + } + watcher = fs.watch(target, { recursive: true }, (_event, filename) => { if (filename) { const first = String(filename).split(path.sep)[0] lastApp = first || null diff --git a/scripts/clean.mjs b/scripts/clean.mjs index d76a61d..20ec04e 100644 --- a/scripts/clean.mjs +++ b/scripts/clean.mjs @@ -1,10 +1,9 @@ /** * Remove every generated directory. * - * Exists mainly for self-hosted runners: they keep their working directory - * between runs, and release/ is gitignored, so `actions/checkout` will not clear - * it. Stale artifacts from an older version would then be picked up by an upload - * glob and shipped alongside the new ones. Node rather than `rm -rf` so the same + * Exists mainly for local builds: release/ and the other generated folders are + * gitignored, so they survive between builds, and stale artifacts from an older + * version would be picked up alongside the new ones. Node rather than `rm -rf` so the same * command works on Windows. */ import { rm } from 'node:fs/promises' diff --git a/scripts/smoke-desktop.mjs b/scripts/smoke-desktop.mjs index 2844df1..b25f0c3 100644 --- a/scripts/smoke-desktop.mjs +++ b/scripts/smoke-desktop.mjs @@ -371,6 +371,8 @@ try { await evaluate("document.getElementById('appframe').contentWindow.__smokeStamp = 1; return 1") const stampBefore = await evaluate("return document.getElementById('appframe').contentWindow.__smokeStamp ?? null") await fs.appendFile(path.join(workspace, 'dial-demo', 'main.js'), '\n// smoke edit\n') + // A temp dir with an 8.3 short name (Windows runners: C:\Users\RUNNER~1\...) + // is the case that once broke this; see watchWorkspace in electron/main.js. const reloaded = await evaluate(` for (let i = 0; i < 60; i++) { if (document.getElementById('appframe').contentWindow.__smokeStamp === undefined) return true;