relayrunner 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +111 -6
  2. package/dist/cli.js +1309 -100
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -1,8 +1,17 @@
1
1
  # RelayRunner CLI
2
2
 
3
3
  Connects a machine to the RelayRunner gateway so it can run your workspace's
4
- GitHub Actions jobs. See [#61](https://github.com/relayrunner/relayrunner/issues/61)
5
- for the plan.
4
+ GitHub Actions jobs. It's published to npm as
5
+ [`relayrunner`](https://www.npmjs.com/package/relayrunner) and needs Node.js 22
6
+ or newer on macOS or Linux (x64 or ARM64).
7
+
8
+ ```sh
9
+ npm install --global relayrunner # or use npx relayrunner
10
+ ```
11
+
12
+ Machines only take jobs from private repositories. To opt jobs in, see the
13
+ [root README](../../README.md#how-it-works) or
14
+ [docs/agent-install.md](../../docs/agent-install.md).
6
15
 
7
16
  ## `relayrunner connect`
8
17
 
@@ -12,23 +21,71 @@ npx relayrunner connect
12
21
 
13
22
  The first run signs you in: it shows a code and opens the dashboard, where you
14
23
  pick the workspace and name for this machine and approve. The machine token is
15
- saved to `~/.relayrunner/machine.json` (mode 0600); later runs reuse it.
24
+ saved to `~/.relayrunner/machine.json` (mode 0600); later runs reuse it. The
25
+ gateway sends a new token every time `connect` comes online and the old one
26
+ stops working, so a copy of `machine.json` from a backup or a synced dotfiles
27
+ folder can't sign in as the machine.
16
28
 
17
29
  While it runs, the machine is online: it keeps a WebSocket open to the gateway,
18
- runs the jobs it's sent (one at a time) and prints what happens. It reconnects
19
- on its own if the connection drops. Ctrl-C takes it offline; a job that's
20
- running stops with it.
30
+ runs the jobs it's sent (one at a time) and prints what happens, including the
31
+ repo each job is from. It reconnects on its own if the connection drops. Ctrl-C
32
+ takes it offline; a job that's running stops with it.
33
+
34
+ Before it starts a job, `connect` checks the job's runner config: it must hold
35
+ only the files GitHub's do, every server in it must be GitHub's, over https, and
36
+ the runner must be named for that job. Anything else is refused and reported as
37
+ a failed job, so a gateway that was tampered with can't point the runner at a
38
+ server of its own or write files outside the runner. It can't tell a job the
39
+ gateway routed here from a runner it minted on a GitHub repo of its own, so the
40
+ terminal shows which repo each job is from.
41
+
42
+ If another `connect` signs in as this machine while it's online, this one stops
43
+ and says so. When that happens from a different network, the person who
44
+ approved the machine also gets an email, since someone else may have its token.
21
45
 
22
46
  - `--server <url>` or `RELAYRUNNER_URL` points it at another gateway. Changing it signs in again.
47
+ It must be https, except for `localhost` while developing, since the token goes
48
+ out on every connect.
23
49
  - `--name <name>` changes the suggested machine name (default: the hostname).
50
+ - `--share only-me|anyone` sets who can run jobs on this machine without asking.
51
+ It works on a machine that's already signed in too.
24
52
  - If the machine is removed in the dashboard, `connect` deletes the saved token.
25
53
  A running `connect` exits and asks you to run it again; a new one signs in
26
54
  straight away.
27
55
 
56
+ A new machine runs only jobs you started (`only-me`). Right after signing in,
57
+ if the workspace has other members, `connect` asks "Who can run jobs on this
58
+ machine?": Only me, or Anyone in the workspace (teammates' and bots' jobs too).
59
+ It doesn't ask in a workspace of one, on later runs, or without a terminal to
60
+ answer. [`relayrunner share`](#relayrunner-share) changes it later.
61
+
62
+ Run inside a checkout of a private repo where no job uses RelayRunner yet,
63
+ `connect` first asks whether to set it up (default no). Yes runs the same picker
64
+ as [`relayrunner init`](#relayrunner-init). No is remembered for that repo in
65
+ `~/.relayrunner/declined-repos.json`, so it doesn't ask again; `init` still
66
+ works there. It never asks outside a repo, in a public repo, in a repo that's
67
+ already set up, or without a terminal to answer.
68
+
28
69
  Jobs run in `actions/runner`, which is downloaded into
29
70
  `~/.relayrunner/runner/<version>` on first connect and checked against its
30
71
  SHA-256. Set `RELAYRUNNER_HOME` to keep everything somewhere else.
31
72
 
73
+ ## `relayrunner login`
74
+
75
+ ```sh
76
+ npx relayrunner login
77
+ ```
78
+
79
+ Signs this machine in without putting it online: the same browser sign-in as the
80
+ first `connect`, then it saves the token and exits. It's for a coding agent
81
+ setting up RelayRunner (see [docs/agent-install.md](../../docs/agent-install.md)),
82
+ which can't keep `connect` running after its session ends. Run `connect`
83
+ afterwards to take jobs.
84
+
85
+ If the machine is already signed in to that gateway, it says so and exits. A
86
+ token that's no longer valid is replaced. `--server`, `--name` and `--share` work as they do
87
+ for `connect`.
88
+
32
89
  ## `relayrunner whoami`
33
90
 
34
91
  ```sh
@@ -45,6 +102,39 @@ its workspace, who enrolled it (name and email) and whether it's online now.
45
102
  - `--json` prints the same as JSON (never the token). `--server <url>` or
46
103
  `RELAYRUNNER_URL` only reports a sign-in for that gateway.
47
104
 
105
+ ## `relayrunner init`
106
+
107
+ ```sh
108
+ npx relayrunner init
109
+ ```
110
+
111
+ Run inside a checkout, it routes the repo's GitHub Actions jobs through
112
+ RelayRunner: each chosen job gets a `relay-<job>` job in front of it (the
113
+ reusable workflow in [relayrunner/actions](https://github.com/relayrunner/actions)),
114
+ and its `runs-on` becomes the relay's answer. The job's old label becomes the
115
+ fallback when no machine is free. It only edits `.github/workflows/`, keeps
116
+ comments and formatting, and never commits.
117
+
118
+ It sorts every job into one of three groups:
119
+
120
+ - **Ready**: a plain GitHub-hosted (`ubuntu-*`, `macos-*`) or Blacksmith
121
+ (`blacksmith-*`) label. A `macos-*` job only routes to macOS machines.
122
+ Warnings flag what to check first: services or containers (need Docker),
123
+ Linux package installs on a Mac, Blacksmith-only actions.
124
+ - **Already routed**: the job runs where a relay sends it.
125
+ - **Skipped, with the reason**: a matrix, a `runs-on` expression, list or
126
+ group, a reusable workflow, a deploy job (`environment`, `id-token: write`,
127
+ or secrets other than `GITHUB_TOKEN`), Windows, or an unknown label.
128
+
129
+ A public repo is refused: machines never take public repos' jobs. Visibility is
130
+ checked with an anonymous GitHub API call, so it doesn't matter which account
131
+ `gh` or git is signed in as.
132
+
133
+ - `--plan` lists the jobs and changes nothing; `--plan --json` prints them as JSON.
134
+ - `--apply <jobs>` routes jobs without prompting. Name them by id (`test`),
135
+ `file:id` (`ci.yml:test`) when an id is in several workflows, or `all` for
136
+ every ready job. Add `--json` for a JSON result.
137
+
48
138
  ## `relayrunner pause` and `relayrunner resume`
49
139
 
50
140
  ```sh
@@ -58,7 +148,22 @@ again. Anyone in the workspace can do the same from the machine's ⋯ menu on th
58
148
  Runners page, and a running `relayrunner connect` prints when that happens.
59
149
  Both exit 1 when not signed in or when the token is no longer valid.
60
150
 
151
+ ## `relayrunner share`
152
+
153
+ ```sh
154
+ npx relayrunner share # show the current setting
155
+ npx relayrunner share only-me # run only jobs you started
156
+ npx relayrunner share anyone # run any job in the workspace
157
+ ```
158
+
159
+ Who can run jobs on this machine. `only-me` takes only jobs you started on
160
+ GitHub; `anyone` takes any job in the workspace, including teammates' and bots'.
161
+ It's the same setting as the sharing icon on the machine's card on the Runners
162
+ page, and only the machine's owner can change it there. `relayrunner whoami`
163
+ shows it too. Exits 1 when not signed in or when the token is no longer valid.
164
+
61
165
  ## Building
62
166
 
63
167
  `pnpm --filter relayrunner build` bundles the CLI into `dist/cli.js` with
64
168
  tsdown, including the workspace's `@relayrunner/machine-protocol` package.
169
+ Releases go out through changesets; see [.changeset/README.md](../../.changeset/README.md).