22# community can change them without being scared of breaking things, or
33# needing to do the complicated (without nix) build setup.
44
5- name : Build o1js bindings
5+ name : Build bindings
66
77on :
88 pull_request :
9+ workflow_dispatch :
910
1011concurrency :
1112 group : ${{ github.workflow }}-${{ github.ref }}
1213 cancel-in-progress : true
1314
1415jobs :
1516 check-npm-deps :
16- name : check-npm-deps
17+ if : github.event_name == 'pull_request' # Runs only for PRs
18+ name : check npmDepsHash is correct
1719 runs-on : [sdk-self-hosted-linux-amd64-build-system]
1820 steps :
1921 - name : Set up Nix
@@ -23,24 +25,17 @@ jobs:
2325 - uses : actions/checkout@v4
2426 with :
2527 submodules : recursive
26- - name : Try to build
28+ - name : fix npmDepsHash
2729 run : |
2830 set -Eeu
2931 ./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
32+ nix run o1js#update-npm-deps
33+ # if the npmDepsHash is out of date auto commit the new one
34+ - uses : stefanzweifel/git-auto-commit-action@v5
4135 with :
42- comment : ' please update the npm-deps-hash'
43- event : ' REQUEST_CHANGES'
36+ commit_message : " auto update npmDepsHash"
37+ file_pattern : " npmDepsHash"
38+
4439
4540 nix-build :
4641 name : build-bindings-ubuntu
@@ -57,32 +52,42 @@ jobs:
5752 run : |
5853 set -Eeu
5954 ./pin.sh
60- nix run o1js#update -bindings --max-jobs 4
61- #fail if this changes any files
62- cd src/bindings
63- echo If this check fails you can download a patch from the patch-upload job
64- echo "https://github.com/o1-labs/o1js/blob/main/README-dev.md#bindings-check-in-ci"
65- git diff --exit-code
66- - name : add build to gc-root if on main
67- if : github.ref == 'refs/heads/main'
68- run : |
69- nix build o1js#o1js-bindings --out-link /home/app/actions-runner/nix-cache/main-bindings-gcroot
70- - name : Cleanup the Nix store
71- run : |
72- nix-store --gc --print-dead
73- nix-store --optimise
74- patch-upload :
55+ nix run o1js#generate -bindings --max-jobs 4
56+ - name : cache bindings
57+ uses : actions/cache@v4
58+ id : bindings-cache
59+ with :
60+ path : |
61+ src/bindings/compiled
62+ src/bindings/mina-transaction/gen
63+ key : bindings-${{ github.event.pull_request.head.sha || github.sha }}
64+
65+ # The upload job is seperate from the build job because
66+ # other workflows have to wait for the cache and the await action works with jobs not steps
67+ # so the split is nesecary to avoid waiting for the artifact upload too
68+ upload-bindings :
69+ name : upload bindings artifact
7570 needs : nix-build
76- if : ${{ failure() }}
7771 runs-on : [sdk-self-hosted-linux-amd64-build-system]
7872 steps :
79- - name : generate patch
73+ - name : Set up Nix
74+ run : echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV
75+ - name : Disable smudging
76+ run : echo "GIT_LFS_SKIP_SMUDGE=1" >> $GITHUB_ENV
77+ - uses : actions/checkout@v4
78+ with :
79+ submodules : recursive
80+ - name : generate tar
8081 run : |
81- cd src/bindings
82- git add .
83- git diff HEAD --textconv --text > ../../ bindings.patch
84- - name : Upload patch
82+ set -Eeu
83+ ./pin.sh
84+ nix build o1js#bindings-tar --out-link bindings.tar.gz
85+ - name : Upload bindings
8586 uses : actions/upload-artifact@v4
8687 with :
87- name : bindings.patch
88- path : bindings.patch
88+ name : bindings.tar.gz
89+ path : bindings.tar.gz
90+ - name : add build to gc-root if on main
91+ if : github.ref == 'refs/heads/main'
92+ run : |
93+ nix build o1js#o1js-bindings --out-link /home/app/actions-runner/nix-cache/main-bindings-gcroot
0 commit comments