Skip to content

Commit fd0c148

Browse files
authored
Merge pull request #1978 from o1-labs/brian/npmDepsCi
Have ci update the npmDepsHash for you
2 parents 002dd6d + 4485cab commit fd0c148

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

.github/workflows/build-bindings.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15+
check-npm-deps:
16+
name: check-npm-deps
17+
runs-on: [sdk-self-hosted-linux-amd64-build-system]
18+
steps:
19+
- name: Set up Nix
20+
run: echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV
21+
- name: Disable smudging
22+
run: echo "GIT_LFS_SKIP_SMUDGE=1" >> $GITHUB_ENV
23+
- uses: actions/checkout@v4
24+
with:
25+
submodules: recursive
26+
- name: Try to build
27+
run: |
28+
set -Eeu
29+
./pin.sh
30+
nix build o1js#npm-deps
31+
update-npm-deps:
32+
needs: check-npm-deps
33+
if: ${{ failure() }}
34+
runs-on: [sdk-self-hosted-linux-amd64-build-system]
35+
steps:
36+
- name: Set up Nix
37+
run: echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV
38+
- name: update-hash
39+
run: nix run o1js#update-npm-deps
40+
- uses: parkerbxyz/suggest-changes@v1
41+
with:
42+
comment: 'please update the npm-deps-hash'
43+
event: 'REQUEST_CHANGES'
44+
1545
nix-build:
1646
name: build-bindings-ubuntu
1747
runs-on: [sdk-self-hosted-linux-amd64-build-system]

flake.nix

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,12 @@
158158
./package-lock.json
159159
];
160160
});
161-
# If you see 'ERROR: npmDepsHash is out of date' in ci
162-
# set this to blank run ``nix build o1js#o1js-bindings`
163-
# If you don't want to install nix you can also set it to "" and run ci to get the new hash
164-
# You should get an output like this:
165-
166-
# error: hash mismatch in fixed-output derivation '/nix/store/a03cg2az0b2cvjsp1wnr89clf31i79c1-o1js-npm-deps.drv':
167-
# specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
168-
# got: sha256-8EPvXpOgn0nvm/pFKN3h6EMjabOeBqfy5optIfe8E8Q=
169-
# replace npmDepsHash bellow with the new hash
170-
171-
npmDepsHash = "sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs=";
161+
# If you get ERROR: npmDepsHash is out of date
162+
# you can update the hash with `nix run o1js#update-npm-deps`.
163+
# Failing that you can remove the hash from ./npmDepsHash and try again
164+
# which should get an error message with the correct hash
165+
# You can also just push and CI should suggest a fix which updates the hash
166+
npmDepsHash = builtins.readFile ./npmDepsHash;
172167
# The prepack script runs the build script, which we'd rather do in the build phase.
173168
npmPackFlags = [ "--ignore-scripts" ];
174169
dontNpmBuild = true;
@@ -218,6 +213,7 @@
218213
# TODO build from ./ocaml root, not ./. (after fixing a bug in dune-nix)
219214
packages = {
220215
inherit dune-description;
216+
npm-deps = o1js-npm-deps;
221217
o1js-bindings = pkgs.stdenv.mkDerivation {
222218
name = "o1js_bindings";
223219
src = with pkgs.lib.fileset;
@@ -286,6 +282,16 @@
286282
ocaml-js = prj.pkgs.__ocaml-js__;
287283
};
288284
apps = {
285+
update-npm-deps = {
286+
type = "app";
287+
program = "${pkgs.writeShellApplication
288+
{ name = "update-npm-deps";
289+
text =
290+
''
291+
${pkgs.prefetch-npm-deps}/bin/prefetch-npm-deps ./package-lock.json > npmDepsHash
292+
'';
293+
}}/bin/update-npm-deps";
294+
};
289295
update-bindings = {
290296
type = "app";
291297
program = "${pkgs.writeShellApplication

npmDepsHash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs=

0 commit comments

Comments
 (0)