Diffinery

homeflare/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

Merge pull request #22 from alankernel67/claude/skip-docker-e2e-on-forks

Run fork pull requests' CI on Diffinery's runners, not GitHub's
altugank authored · GitHub committed 2 parents 9948c4a6d0b149commit 1019f324b6eb356fc27f6a527d9a4e7f98401b08Browse files
11 files changed+40−22
Files (11)
modified.github/workflows/awesome-lists.yml+1−1View file
@@ -26,7 +26,7 @@
2626 suggest:
2727 name: Open the list pull requests
2828 if: ${{ github.server_url != 'https://github.com' && github.repository == 'codician/diffinery' }}
29- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
29+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
3030 environment: github-mirror
3131 timeout-minutes: 10
3232 steps:
modified.github/workflows/ci.yml+6−4View file
@@ -4,8 +4,10 @@
44 # workflow (e2e.yml), so deploys don't wait for it too.
55 #
66 # Every job of this repository's workflows runs on the label in the repository variable
7-# DIFFINERY_RUNS_ON, else ubuntu-latest (a hosted runner on Diffinery too). The GitHub copy
8-# sets `diffinery` to run on diffinery.com's GitHub runners; forks need nothing.
7+# DIFFINERY_RUNS_ON, else on `diffinery` (diffinery.com's GitHub runners) in
8+# codician-team/diffinery, else ubuntu-latest (a hosted runner on Diffinery too). GitHub passes
9+# no variables to pull requests from forks, so without that middle default they would run on
10+# GitHub's own runners. Other copies of the repository need nothing.
911
1012 on:
1113 push:
@@ -24,7 +26,7 @@
2426 # tests together took longer than either does alone.
2527 typecheck:
2628 name: Typecheck and bundle
27- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
29+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
2830 timeout-minutes: 20
2931 steps:
3032 - uses: actions/checkout@v4
@@ -44,7 +46,7 @@
4446
4547 test:
4648 name: Unit tests (${{ matrix.shard }}/2)
47- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
49+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
4850 timeout-minutes: 20
4951 # Two halves of every package's test files, side by side: CI is the first step of a deploy.
5052 strategy:
modified.github/workflows/d1-replication.yml+2−2View file
@@ -18,7 +18,7 @@
1818 jobs:
1919 check:
2020 name: Check sessions on a test database
21- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
21+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
2222 # The Cloudflare secrets are the production environment's.
2323 environment: production
2424 timeout-minutes: 20
@@ -81,7 +81,7 @@
8181 name: Turn on read replication in production
8282 needs: check
8383 if: ${{ inputs.enable_production }}
84- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
84+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
8585 environment:
8686 name: production
8787 url: https://${{ vars.DIFFINERY_DOMAIN || 'diffinery.com' }}
modified.github/workflows/deploy.yml+5−4View file
@@ -10,8 +10,9 @@
1010 # DIFFINERY_GITHUB_APP_ID, DIFFINERY_GITHUB_APP_SLUG, DIFFINERY_GITHUB_APP_CLIENT_ID,
1111 # DIFFINERY_GITHUB_APP_URL the GitHub App of GitHub runners (docs/self-hosting/configuration.md)
1212 # DIFFINERY_RUNS_ON the runner label of every job in this repository's workflows (default
13-# ubuntu-latest). `diffinery` runs them on a Diffinery instance's GitHub runners;
14-# set it back to ubuntu-latest to deploy while those can't start.
13+# ubuntu-latest, and `diffinery` in codician-team/diffinery, whose fork pull
14+# requests get no variables). `diffinery` runs them on a Diffinery instance's
15+# GitHub runners; set it back to ubuntu-latest to deploy while those can't start.
1516 #
1617 # It deploys a main commit only once CI (typecheck, unit tests and the Worker bundle) has
1718 # passed on it, so it doesn't run those itself. End-to-end tests run alongside the deploy.
@@ -42,7 +43,7 @@
4243 # codician/diffinery, an older copy of this repository: GitHub deploys diffinery.com,
4344 # and that copy lacks the GitHub App's variables a deploy needs.
4445 if: ${{ !(github.server_url == 'https://diffinery.com' && github.repository == 'codician/diffinery') && (github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push')) }}
45- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
46+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
4647 timeout-minutes: 5
4748 outputs:
4849 deploy: ${{ steps.tip.outputs.deploy }}
@@ -72,7 +73,7 @@
7273 name: Deploy to Cloudflare
7374 needs: gate
7475 if: ${{ needs.gate.outputs.deploy == 'true' }}
75- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
76+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
7677 timeout-minutes: 45
7778 environment:
7879 name: production
modified.github/workflows/e2e.yml+3−3View file
@@ -19,7 +19,7 @@
1919 # Only the last shard needs a browser (passkeys).
2020 e2e:
2121 name: End-to-end (${{ matrix.name }})
22- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
22+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
2323 timeout-minutes: 20
2424 strategy:
2525 fail-fast: false
@@ -88,11 +88,11 @@
8888
8989 # Docker as the hosted runner image runs it, with this change's docker wrapper, daemon config
9090 # and agent (its registry relay). It needs a Diffinery hosted runner, for the real dockerd: on
91- # Diffinery, or on GitHub with DIFFINERY_RUNS_ON=diffinery. On GitHub's own runners it fails.
91+ # Diffinery, or on GitHub on the `diffinery` label. On GitHub's own runners it fails.
9292 # A daemon an earlier step started is stopped first, so the first uses below start it afresh.
9393 runner-docker:
9494 name: End-to-end (runner Docker)
95- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
95+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
9696 timeout-minutes: 20
9797 steps:
9898 - uses: actions/checkout@v4
modified.github/workflows/github-community.yml+1−1View file
@@ -19,7 +19,7 @@
1919 setup:
2020 name: Labels, welcome discussion and roadmap issue
2121 if: ${{ github.server_url != 'https://github.com' && github.repository == 'codician/diffinery' }}
22- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
22+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
2323 environment: github-mirror
2424 timeout-minutes: 5
2525 steps:
modified.github/workflows/live-test.yml+1−1View file
@@ -31,7 +31,7 @@
3131 name: Containers, registry, sandboxes, webhooks, schedules, LFS and pull requests
3232 # Runs on the host that deploys production (see the gate in deploy.yml).
3333 if: ${{ github.event_name == 'workflow_dispatch' || (github.server_url == 'https://diffinery.com' && github.event.workflow_run.conclusion == 'success') }}
34- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
34+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
3535 timeout-minutes: 45
3636 environment: production
3737 env:
modifiedCONTRIBUTING.md+6−0View file
@@ -57,6 +57,12 @@
5757 end-to-end shards before they merge. Tests must not depend on the speed of the machine
5858 they run on.
5959
60+CI runs on Diffinery's own runners for GitHub (`runs-on: diffinery`), pull requests from
61+forks included: in this repository the workflows default to that label when the
62+repository variable `DIFFINERY_RUNS_ON`, which GitHub doesn't pass to forks, is missing.
63+The "End-to-end (runner Docker)" job needs those runners and fails on GitHub's own. A
64+maintainer may have to approve the workflows of your first pull request before they run.
65+
6066 ## Conventions
6167
6268 - **TypeScript everywhere**, in strict mode, sharing code through the workspace packages in
modifiedapps/diffinery/docs/actions/github-runners.md+9−1View file
@@ -70,8 +70,16 @@
7070 runs-on: ${{ vars.RUNS_ON || 'ubuntu-latest' }}
7171 ```
7272
73-Then set the variable to `diffinery` (`gh variable set RUNS_ON --body diffinery`). Setting it back to `ubuntu-latest` returns the jobs to GitHub-hosted runners, for example to keep a deploy working while Diffinery can't start runners. Forks without the variable keep running on GitHub. Diffinery's own repository does this with `DIFFINERY_RUNS_ON`.
73+Then set the variable to `diffinery` (`gh variable set RUNS_ON --body diffinery`). Setting it back to `ubuntu-latest` returns the jobs to GitHub-hosted runners, for example to keep a deploy working while Diffinery can't start runners. Forks without the variable keep running on GitHub.
7474
75+GitHub passes no repository variables to workflows of pull requests from forks, so those jobs run on `ubuntu-latest` too. To run them on Diffinery as well, default to `diffinery` in your own repository, and keep `ubuntu-latest` for copies of it:
76+
77+```yaml
78+ runs-on: ${{ vars.RUNS_ON || (github.repository == 'my-org/my-repo' && 'diffinery') || 'ubuntu-latest' }}
79+```
80+
81+Diffinery's own repository does this with `DIFFINERY_RUNS_ON`. Read [Security](#security) first: anyone who opens a pull request can then use your minutes.
82+
7583 ## The machine
7684
7785 The container runs the same image as Diffinery's own [hosted runners](/docs/actions/runners#hosted-runners): Ubuntu 24.04 on x64 with Git, Node.js 22, Python 3.12, Docker, the GitHub CLI and `/dev/kvm`. Differences from a GitHub-hosted runner:
modifiedapps/diffinery/docs/self-hosting/deploy.md+1−1View file
@@ -111,7 +111,7 @@
111111 | `MAIL_DOMAIN` | Variable, optional | The domain email is sent from, when it isn't `DIFFINERY_DOMAIN`. |
112112 | `ACCESS_TEAM_DOMAIN` | Variable, optional | Your Zero Trust team domain, for example `example.cloudflareaccess.com`. Needed only when the token can't read it. |
113113 | `DIFFINERY_GITHUB_APP_ID`, `DIFFINERY_GITHUB_APP_SLUG`, `DIFFINERY_GITHUB_APP_CLIENT_ID`, `DIFFINERY_GITHUB_APP_URL` | Variables, optional | The GitHub App of [GitHub runners](/docs/self-hosting/configuration#github-runners). The workflow passes them to render-config as `GITHUB_APP_ID` and the rest. |
114-| `DIFFINERY_RUNS_ON` | Variable, optional | The `runs-on` label of every job in the repository's workflows. Without it, jobs run on `ubuntu-latest`. Set it to `diffinery` to run them on a Diffinery instance's [GitHub runners](/docs/actions/github-runners) once that instance's GitHub App is installed on the repository. Set it back to `ubuntu-latest` to deploy while those runners can't start, for example while the instance itself is down. |
114+| `DIFFINERY_RUNS_ON` | Variable, optional | The `runs-on` label of every job in the repository's workflows. Without it, jobs run on `ubuntu-latest` (in `codician-team/diffinery` itself, on `diffinery`, so pull requests from forks, which get no variables, run there too). Set it to `diffinery` to run them on a Diffinery instance's [GitHub runners](/docs/actions/github-runners) once that instance's GitHub App is installed on the repository. Set it back to `ubuntu-latest` to deploy while those runners can't start, for example while the instance itself is down. |
115115
116116 The Deploy job runs in an environment named `production`, so you can also store the secrets as environment secrets there and add required reviewers to that environment.
117117
modifiedapps/diffinery/test/unit/contact.test.ts+5−4View file
@@ -157,10 +157,11 @@
157157 await submitMessage(env, audit, input("[email protected]", { message: "Second message, about another." }), null, "203.0.113.9");
158158 expect(rows(DB)).toHaveLength(2);
159159 await confirmMessage(env, audit, tokenOf(queued[1]));
160- expect(rows(DB).map((r) => [r.message, r.state])).toEqual([
161- ["First message, about one thing.", "unconfirmed"],
162- ["Second message, about another.", "new"],
163- ]);
160+ // Both can have the same created_at millisecond, and then the random id orders them.
161+ expect(Object.fromEntries(rows(DB).map((r) => [r.message, r.state]))).toEqual({
162+ "First message, about one thing.": "unconfirmed",
163+ "Second message, about another.": "new",
164+ });
164165 });
165166
166167 it("limits one network, one address and the whole form per day, quietly past the last two", async () => {