Skip to content

Commit ce0d218

Browse files
committed
fix: review
1 parent 7ab5348 commit ce0d218

7 files changed

Lines changed: 66 additions & 78 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'checks'
1+
name: "checks"
22
on:
33
pull_request:
44
push:
@@ -18,15 +18,15 @@ jobs:
1818
permissions:
1919
contents: read
2020
steps:
21-
- uses: actions/checkout@v6
21+
- uses: actions/checkout@v7
2222
with:
2323
persist-credentials: false
2424

2525
- name: setup node
2626
uses: actions/setup-node@v6
2727
with:
2828
node-version: 24
29-
cache: 'yarn'
29+
cache: "yarn"
3030

3131
- name: Install dependencies
3232
run: yarn install --frozen-lockfile
@@ -41,34 +41,3 @@ jobs:
4141
env:
4242
GH_TOKEN: ${{ github.token }}
4343
run: yarn check:config
44-
45-
binaries:
46-
name: binaries
47-
strategy:
48-
fail-fast: false
49-
matrix:
50-
platform:
51-
- windows-2022
52-
- macos-15-intel
53-
- macos-latest
54-
- ubuntu-22.04
55-
- ubuntu-24.04-arm
56-
runs-on: ${{ matrix.platform }}
57-
permissions:
58-
contents: read
59-
steps:
60-
- uses: actions/checkout@v6
61-
with:
62-
persist-credentials: false
63-
64-
- name: setup node
65-
uses: actions/setup-node@v6
66-
with:
67-
node-version: 24
68-
cache: 'yarn'
69-
70-
- name: Install dependencies
71-
run: yarn install --frozen-lockfile
72-
73-
- name: Download binaries and verify checksums
74-
run: yarn fetch:binaries

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ Depending on which Holochain minor version you want to use you should use the co
1717
- Holochain 0.4.x: [main-0.4](https://github.com/holochain/kangaroo-electron/tree/main-0.4)
1818
- Holochain 0.3.x: [main-0.3](https://github.com/holochain/kangaroo-electron/tree/main-0.3)
1919

20+
If you change the `holochainVersion` field in `kangaroo.config.ts`, the npm dependencies that talk to the conductor (`@holochain/client` and `@holochain/hc-spin-rust-utils`) need to move to a matching version series as well. The `bins.compatibleDeps` field in `kangaroo.config.ts` records which npm dependency series goes with which Holochain series, and `yarn check:config` verifies that `package.json` agrees with it:
21+
22+
```ts
23+
compatibleDeps: {
24+
'0.7': {
25+
'@holochain/client': '0.21',
26+
'@holochain/hc-spin-rust-utils': '0.700',
27+
},
28+
},
29+
```
30+
31+
> [!NOTE]
32+
> Add an entry whenever you move to a new Holochain series. If there is no entry for the series you configured, `yarn check:config` prints a warning and skips the dependency verification instead of failing.
33+
2034
# Instructions
2135

2236
## Setup and Testing Locally

kangaroo.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ export default defineConfig({
1414
relayUrl: 'https://dev-test-bootstrap2.holochain.org/',
1515
bins: {
1616
holochainVersion: '0.7.0',
17+
compatibleDeps: {
18+
'0.7': {
19+
'@holochain/client': '0.21',
20+
'@holochain/hc-spin-rust-utils': '0.700',
21+
},
22+
},
1723
holochain: {
1824
sha256: {
1925
'x86_64-unknown-linux-gnu':

scripts/lib/test-server.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

scripts/update-binary-hashes.mjs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import path from 'node:path';
55

66
const require = createRequire(import.meta.url);
77
require('tsx/cjs');
8-
const { isTestServerUrl } = require('./lib/test-server.js');
98

109
const OWNER = 'holochain';
1110
const REPO = 'holochain';
1211

12+
// URL of the testing bootstrap/relay server this repository ships with.
13+
// Compared as an exact URL, matching the check in scripts/write-configs.js.
14+
const TEST_SERVER_URL = 'https://dev-test-bootstrap2-iroh.holochain.org/';
15+
1316
const CHECK_MODE = process.argv.includes('--check');
1417

1518
// The platform targets kangaroo builds for. Both sha256 maps in
@@ -22,16 +25,6 @@ const EXPECTED_TARGETS = [
2225
'aarch64-apple-darwin',
2326
];
2427

25-
// Known-compatible npm dependency series (major.minor) per Holochain
26-
// series. Extend this map when adopting a new Holochain series; the check
27-
// fails loudly when the configured Holochain version is not listed here.
28-
const DEP_COMPAT = {
29-
'0.7': {
30-
'@holochain/client': '0.21',
31-
'@holochain/hc-spin-rust-utils': '0.700',
32-
},
33-
};
34-
3528
const configPath = path.join(process.cwd(), 'kangaroo.config.ts');
3629
const kangarooConfig = require(configPath).default;
3730

@@ -143,18 +136,19 @@ function checkDependencyVersions(problems) {
143136
return;
144137
}
145138
const series = `${parsed.major}.${parsed.minor}`;
146-
const compat = DEP_COMPAT[series];
139+
const compat = kangarooConfig.bins.compatibleDeps?.[series];
147140
if (!compat) {
148-
problems.push(
149-
`no known compatible dependency versions for Holochain ${series}.x - extend DEP_COMPAT in scripts/update-binary-hashes.mjs`
141+
console.warn(
142+
`⚠️ kangaroo.config.ts has no 'bins.compatibleDeps' entry for Holochain ${series}.x - skipping the npm dependency check. Add one to have this check verify that your npm dependencies match your Holochain version.`
150143
);
151144
return;
152145
}
153146
const packageJson = JSON.parse(
154147
fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8')
155148
);
149+
const dependencies = packageJson.dependencies ?? {};
156150
for (const [depName, expectedSeries] of Object.entries(compat)) {
157-
const range = packageJson.dependencies[depName];
151+
const range = dependencies[depName];
158152
if (!range) {
159153
problems.push(`package.json has no dependency '${depName}'`);
160154
continue;
@@ -167,7 +161,7 @@ function checkDependencyVersions(problems) {
167161
const depSeries = `${minVersion.major}.${minVersion.minor}`;
168162
if (depSeries !== expectedSeries) {
169163
problems.push(
170-
`dependency '${depName}' is '${range}' (series ${depSeries}) but Holochain ${holochainVersion} needs series ${expectedSeries}`
164+
`dependency '${depName}' is '${range}' (series ${depSeries}) but 'bins.compatibleDeps' in kangaroo.config.ts declares series ${expectedSeries} for Holochain ${holochainVersion}`
171165
);
172166
}
173167
}
@@ -179,7 +173,7 @@ function warnAboutTestServers() {
179173
['relayUrl', kangarooConfig.relayUrl],
180174
];
181175
for (const [field, url] of servers) {
182-
if (isTestServerUrl(url)) {
176+
if (url === TEST_SERVER_URL) {
183177
console.warn(
184178
`⚠️ ${field} ('${url}') points at a test server. Test servers have no availability guarantees - do not ship a production release with this setting.`
185179
);

scripts/write-configs.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const jsYaml = require('js-yaml');
22
const fs = require('fs');
33
const path = require('path');
44
require('tsx/cjs');
5-
const { isTestServerUrl } = require('./lib/test-server');
65

76
const PLACEHOLDER_APP_ID = 'org.holochain.kangaroo-electron';
87
const PLACEHOLDER_PRODUCT_NAME = 'Holochain Kangaroo Electron';
@@ -15,15 +14,15 @@ if (!process.env.KANGAROO_DEV) {
1514
// of their own chosen appId/productName
1615
if (kangarooConfig.appId === PLACEHOLDER_APP_ID)
1716
throw new Error(
18-
"The appId field in 'kangaroo.config.ts' is still using the placeholder value. Change it to the appId of your app."
17+
"The appId field in 'kangaroo.config.ts' is still using the placeholder value. Change it to the appId of your app.",
1918
);
2019
if (kangarooConfig.productName === PLACEHOLDER_PRODUCT_NAME)
2120
throw new Error(
22-
"The productName field in 'kangaroo.config.ts' is still using the placeholder value. Change it to the productName of your app."
21+
"The productName field in 'kangaroo.config.ts' is still using the placeholder value. Change it to the productName of your app.",
2322
);
2423
}
2524

26-
if (isTestServerUrl(kangarooConfig.bootstrapUrl)) {
25+
if (kangarooConfig.bootstrapUrl === 'https://dev-test-bootstrap2-iroh.holochain.org/') {
2726
console.log(`
2827
2928
⚠️ WARNING ⚠️
@@ -41,7 +40,7 @@ among users of your app.
4140
`);
4241
}
4342

44-
if (isTestServerUrl(kangarooConfig.relayUrl)) {
43+
if (kangarooConfig.relayUrl === 'https://dev-test-bootstrap2-iroh.holochain.org/') {
4544
console.log(`
4645
4746
⚠️ WARNING ⚠️
@@ -65,13 +64,13 @@ fs.mkdirSync('resources', { recursive: true });
6564
fs.writeFileSync(
6665
path.join('resources', 'kangaroo.config.json'),
6766
JSON.stringify(kangarooConfig, undefined, 2),
68-
'utf-8'
67+
'utf-8',
6968
);
7069

7170
// Copy conductor config template to resources folder
7271
fs.copyFileSync(
7372
path.join(process.cwd(), 'templates', 'conductor-config.yaml'),
74-
path.join('resources', 'conductor-config.yaml')
73+
path.join('resources', 'conductor-config.yaml'),
7574
);
7675

7776
// Overwrite package.json values
@@ -83,7 +82,7 @@ packageJSON.version = kangarooConfig.version;
8382
fs.writeFileSync('package.json', JSON.stringify(packageJSON, undefined, 2), 'utf-8');
8483

8584
const eletronBuilderYml = jsYaml.load(
86-
fs.readFileSync(path.join(process.cwd(), 'templates', 'electron-builder-template.yml'))
85+
fs.readFileSync(path.join(process.cwd(), 'templates', 'electron-builder-template.yml')),
8786
);
8887

8988
eletronBuilderYml.appId = kangarooConfig.appId;

src/main/types.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,31 @@ export type KangarooConfig = {
116116
bins: {
117117
holochainVersion: string;
118118
holochainFeature?: "unstable";
119+
/**
120+
* npm dependency versions that are known to work with a given Holochain
121+
* series, used by `yarn check:config` to catch a `holochainVersion` bump
122+
* that forgot to bump the corresponding npm dependencies.
123+
*
124+
* The outer key is a Holochain series in `major.minor` notation, the inner
125+
* keys are npm package names and the inner values the `major.minor` series
126+
* of that package which is compatible with that Holochain series.
127+
*
128+
* Whenever you move to a new Holochain series, add an entry for it. If
129+
* there is no entry for the series of `holochainVersion`, the check is
130+
* skipped with a warning.
131+
*
132+
* Example:
133+
*
134+
* ```ts
135+
* compatibleDeps: {
136+
* '0.7': {
137+
* '@holochain/client': '0.21',
138+
* '@holochain/hc-spin-rust-utils': '0.700',
139+
* },
140+
* }
141+
* ```
142+
*/
143+
compatibleDeps?: Record<string, Record<string, string>>;
119144
holochain: Sha256Hashes;
120145
lair: Sha256Hashes;
121146
};

0 commit comments

Comments
 (0)