From dcd1441d7f7b09a763bd3a0699899cf0d9cbd923 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Tue, 21 Jan 2025 13:53:14 -0500 Subject: [PATCH 01/12] add github action to handle npmDepsHash --- .github/workflows/build-bindings.yml | 22 ++++++++++++++++++++++ flake.nix | 23 ++++++++++++----------- npmDepsHash | 1 + 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 npmDepsHash diff --git a/.github/workflows/build-bindings.yml b/.github/workflows/build-bindings.yml index b4cd18b16..2b160f577 100644 --- a/.github/workflows/build-bindings.yml +++ b/.github/workflows/build-bindings.yml @@ -12,6 +12,28 @@ concurrency: cancel-in-progress: true jobs: + check-npm-deps: + name: check-npm-deps + runs-on: [sdk-self-hosted-linux-amd64-build-system] + steps: + - name: Try to build + run: | + set -Eeu + ./pin.sh + nix build o1js#npm-deps + update-npm-deps: + needs: check-npm-deps + if: ${{ failure() }} + runs-on: [sdk-self-hosted-linux-amd64-build-system] + steps: + - name: update-hash + run: nix run o1js#update-npm-deps + - uses: parkerbxyz/suggest-changes@v1 + with: + comment: 'please update the npm-deps-hash' + event: 'REQUEST_CHANGES' + + nix-build: name: build-bindings-ubuntu runs-on: [sdk-self-hosted-linux-amd64-build-system] diff --git a/flake.nix b/flake.nix index 74f10868a..c154f5882 100644 --- a/flake.nix +++ b/flake.nix @@ -158,17 +158,7 @@ ./package-lock.json ]; }); - # If you see 'ERROR: npmDepsHash is out of date' in ci - # set this to blank run ``nix build o1js#o1js-bindings` - # If you don't want to install nix you can also set it to "" and run ci to get the new hash - # You should get an output like this: - - # error: hash mismatch in fixed-output derivation '/nix/store/a03cg2az0b2cvjsp1wnr89clf31i79c1-o1js-npm-deps.drv': - # specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - # got: sha256-8EPvXpOgn0nvm/pFKN3h6EMjabOeBqfy5optIfe8E8Q= - # replace npmDepsHash bellow with the new hash - - npmDepsHash = "sha256-QLnSfX6JwYQXyHGNSxXdzqbhkbFl67sDrmlW/F6D/pw="; + npmDepsHash = builtins.readFile ./npmDepsHash; # The prepack script runs the build script, which we'd rather do in the build phase. npmPackFlags = [ "--ignore-scripts" ]; dontNpmBuild = true; @@ -218,6 +208,7 @@ # TODO build from ./ocaml root, not ./. (after fixing a bug in dune-nix) packages = { inherit dune-description; + npm-deps = o1js-npm-deps; o1js-bindings = pkgs.stdenv.mkDerivation { name = "o1js_bindings"; src = with pkgs.lib.fileset; @@ -286,6 +277,16 @@ ocaml-js = prj.pkgs.__ocaml-js__; }; apps = { + update-npm-deps = { + type = "app"; + program = "${pkgs.writeShellApplication + { name = "update-npm-deps"; + text = + '' + ${pkgs.prefetch-npm-deps} ./package-lock.json + ''; + }}/bin/update-npm-deps"; + }; update-bindings = { type = "app"; program = "${pkgs.writeShellApplication diff --git a/npmDepsHash b/npmDepsHash new file mode 100644 index 000000000..b5bbca2e5 --- /dev/null +++ b/npmDepsHash @@ -0,0 +1 @@ +sha256-QLnSfX6JwYQXyHGNSxXdzqbhkbFl67sDrmlW/F6D/pz= From 3d8e72a35a37a124339d7286a8b9425a40da262a Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Tue, 21 Jan 2025 16:15:34 -0500 Subject: [PATCH 02/12] set up nix for npm-deps update --- .github/workflows/build-bindings.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build-bindings.yml b/.github/workflows/build-bindings.yml index 2b160f577..da160f410 100644 --- a/.github/workflows/build-bindings.yml +++ b/.github/workflows/build-bindings.yml @@ -16,6 +16,13 @@ jobs: name: check-npm-deps runs-on: [sdk-self-hosted-linux-amd64-build-system] steps: + - name: Set up Nix + run: echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV + - name: Disable smudging + run: echo "GIT_LFS_SKIP_SMUDGE=1" >> $GITHUB_ENV + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Try to build run: | set -Eeu From 2ddcb457a23ee6f9e16dcf475730db17d907b648 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Tue, 21 Jan 2025 16:54:34 -0500 Subject: [PATCH 03/12] break npmDepsHash to trigger ci --- npmDepsHash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npmDepsHash b/npmDepsHash index b5bbca2e5..78a30de1c 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-QLnSfX6JwYQXyHGNSxXdzqbhkbFl67sDrmlW/F6D/pz= +sha256-QLnSfX6JwYQXyHGNSxXdzqbhkbFl67sDrmlW/F6D/pk= From e24ff72c0577917ae98045b63a5e8e23cf6e1dd1 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 09:06:00 -0500 Subject: [PATCH 04/12] add nix to path for update-npm-deps --- .github/workflows/build-bindings.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-bindings.yml b/.github/workflows/build-bindings.yml index da160f410..8fc4c44db 100644 --- a/.github/workflows/build-bindings.yml +++ b/.github/workflows/build-bindings.yml @@ -33,6 +33,8 @@ jobs: if: ${{ failure() }} runs-on: [sdk-self-hosted-linux-amd64-build-system] steps: + - name: Set up Nix + run: echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV - name: update-hash run: nix run o1js#update-npm-deps - uses: parkerbxyz/suggest-changes@v1 From 02463fdd9f22ab289aab6f55b70b249cc98bb0f0 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 09:18:14 -0500 Subject: [PATCH 05/12] fix script --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 7ebd7adcf..74c9326df 100644 --- a/flake.nix +++ b/flake.nix @@ -285,7 +285,7 @@ { name = "update-npm-deps"; text = '' - ${pkgs.prefetch-npm-deps} ./package-lock.json + ${pkgs.prefetch-npm-deps}/bin/prefetch-npm-deps ./package-lock.json > npmDepsHash ''; }}/bin/update-npm-deps"; }; From db0c4e0da5627ee33c431f370f82cec91b80b3c6 Mon Sep 17 00:00:00 2001 From: Brian Kuhns <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 09:22:13 -0500 Subject: [PATCH 06/12] Update npmDepsHash Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- npmDepsHash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npmDepsHash b/npmDepsHash index 78a30de1c..0c2d4afb3 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-QLnSfX6JwYQXyHGNSxXdzqbhkbFl67sDrmlW/F6D/pk= +sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs= From db85371c8cecaee0352d0ac637c94271f5da16d1 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 10:01:43 -0500 Subject: [PATCH 07/12] try having the bot only comment --- .github/workflows/build-bindings.yml | 2 +- flake.nix | 7 +++++-- npmDepsHash | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-bindings.yml b/.github/workflows/build-bindings.yml index 8fc4c44db..f6159926b 100644 --- a/.github/workflows/build-bindings.yml +++ b/.github/workflows/build-bindings.yml @@ -40,7 +40,7 @@ jobs: - uses: parkerbxyz/suggest-changes@v1 with: comment: 'please update the npm-deps-hash' - event: 'REQUEST_CHANGES' + event: 'COMMENT' nix-build: diff --git a/flake.nix b/flake.nix index 74c9326df..5a47e4c49 100644 --- a/flake.nix +++ b/flake.nix @@ -158,8 +158,11 @@ ./package-lock.json ]; }); - # to update this with nix run `nix run o1js#update-npm-deps` - # ci should also suggest the change automaticly + # If you get ERROR: npmDepsHash is out of date + # you can update the hash with `nix run o1js#update-npm-deps`. + # Failing that you can remove the hash from ./npmDepsHash and try again + # which should get an error message with the correct hash + # You can also just push and CI should suggest a fix which updates the hash npmDepsHash = builtins.readFile ./npmDepsHash; # The prepack script runs the build script, which we'd rather do in the build phase. npmPackFlags = [ "--ignore-scripts" ]; diff --git a/npmDepsHash b/npmDepsHash index 0c2d4afb3..f81e48560 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs= +sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpubadHash= From 0a8506c15254b4c065b841f690a4b7667c154f51 Mon Sep 17 00:00:00 2001 From: Brian Kuhns <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 10:06:37 -0500 Subject: [PATCH 08/12] Update npmDepsHash Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- npmDepsHash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npmDepsHash b/npmDepsHash index f81e48560..0c2d4afb3 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpubadHash= +sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs= From 5daa24ef032b11912659965ac7e1d7831c9ec9d3 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 10:08:41 -0500 Subject: [PATCH 09/12] break hash again to make sure review doesn't come back This reverts commit 0a8506c15254b4c065b841f690a4b7667c154f51. --- npmDepsHash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npmDepsHash b/npmDepsHash index 0c2d4afb3..f81e48560 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs= +sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpubadHash= From 27e66507ffb6871c5105770e036a2d5f909604f7 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 10:14:30 -0500 Subject: [PATCH 10/12] fix event name --- .github/workflows/build-bindings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-bindings.yml b/.github/workflows/build-bindings.yml index f6159926b..b1c3f50d1 100644 --- a/.github/workflows/build-bindings.yml +++ b/.github/workflows/build-bindings.yml @@ -40,7 +40,7 @@ jobs: - uses: parkerbxyz/suggest-changes@v1 with: comment: 'please update the npm-deps-hash' - event: 'COMMENT' + event: 'comment' nix-build: From eb15aa3df3929a58a08f7c2c9a3b8eed67ca5785 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 10:32:31 -0500 Subject: [PATCH 11/12] revert back to just request changes --- .github/workflows/build-bindings.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-bindings.yml b/.github/workflows/build-bindings.yml index b1c3f50d1..b43703ec5 100644 --- a/.github/workflows/build-bindings.yml +++ b/.github/workflows/build-bindings.yml @@ -40,8 +40,7 @@ jobs: - uses: parkerbxyz/suggest-changes@v1 with: comment: 'please update the npm-deps-hash' - event: 'comment' - + event: 'REQUEST_CHANGES' nix-build: name: build-bindings-ubuntu From 4485cab8fd7ced75dd6641f261481f71cc625ee9 Mon Sep 17 00:00:00 2001 From: Brian Kuhns <16kuhnb@gmail.com> Date: Wed, 22 Jan 2025 10:51:50 -0500 Subject: [PATCH 12/12] Update npmDepsHash Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- npmDepsHash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npmDepsHash b/npmDepsHash index f81e48560..0c2d4afb3 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpubadHash= +sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs=