Skip to content

Commit

Permalink
Merge pull request #1978 from o1-labs/brian/npmDepsCi
Browse files Browse the repository at this point in the history
Have ci update the npmDepsHash for you
  • Loading branch information
Geometer1729 authored Jan 22, 2025
2 parents 002dd6d + 4485cab commit fd0c148
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ concurrency:
cancel-in-progress: true

jobs:
check-npm-deps:
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
./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: 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
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]
Expand Down
28 changes: 17 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,12 @@
./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-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs=";
# 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" ];
dontNpmBuild = true;
Expand Down Expand Up @@ -218,6 +213,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;
Expand Down Expand Up @@ -286,6 +282,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}/bin/prefetch-npm-deps ./package-lock.json > npmDepsHash
'';
}}/bin/update-npm-deps";
};
update-bindings = {
type = "app";
program = "${pkgs.writeShellApplication
Expand Down
1 change: 1 addition & 0 deletions npmDepsHash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs=

0 comments on commit fd0c148

Please sign in to comment.