Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(hash): switch from wasm-pack to using wasm-bindgen directly #999

Merged
merged 35 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5962d72
build(hash): switch from wasm-pack to use wasm-bindgen directly
jeremyBanks Jul 2, 2021
cb3d9fb
chore(hash): rebuild wasm
jeremyBanks Jul 2, 2021
9f3dd47
Use official Deno setup action, lock rust-toolchain version.
jeremyBanks Jul 5, 2021
e30da02
Merge remote-tracking branch 'origin/main' into wasm-bindgen
jeremyBanks Jul 5, 2021
2102801
attempt to improve reproducibility
jeremyBanks Jul 5, 2021
98d3890
Rebuild WASM for Hash in normal CI process.
jeremyBanks Jul 5, 2021
81242cc
dump WASM as WAT in CI to help identify non-determinism
jeremyBanks Jul 5, 2021
95bf640
chore(hash): rebuild wasm
jeremyBanks Jul 5, 2021
ba813e1
dump WASM as WAT in CI to help identify non-determinism
jeremyBanks Jul 5, 2021
a03ac02
attempting to fix non-determinism
jeremyBanks Jul 6, 2021
b399f15
ci change -- not touching hash/
jeremyBanks Jul 6, 2021
354e96a
fake change to test ci
jeremyBanks Jul 6, 2021
131ebdb
remove WAT test stuff
jeremyBanks Jul 6, 2021
da05fda
dummy change
jeremyBanks Jul 6, 2021
4384b6f
Merge remote-tracking branch 'origin/main' into wasm-bindgen-wip
jeremyBanks Jul 6, 2021
b057bc2
jeremyBanks Jul 6, 2021
dc64ff4
revert changes
jeremyBanks Jul 6, 2021
4cdb233
chore(hash): rebuild wasm
jeremyBanks Jul 6, 2021
ae6d486
m
jeremyBanks Jul 6, 2021
251d465
Merge remote-tracking branch 'jeremyBanks/wasm-bindgen' into wasm-bin…
jeremyBanks Jul 6, 2021
9649f40
Merge remote-tracking branch 'jeremyBanks/wasm-bindgen-wip' into wasm…
jeremyBanks Jul 6, 2021
1630b88
m
jeremyBanks Jul 6, 2021
944499c
a bit more CI log detail
jeremyBanks Jul 6, 2021
d378edd
jeremyBanks Jul 6, 2021
663eae4
cleanup cargo toml
wperron Jul 6, 2021
fa11999
update README
wperron Jul 6, 2021
bae5ded
typo fix
jeremyBanks Jul 6, 2021
26f959a
CI
jeremyBanks Jul 6, 2021
a1976db
CI
jeremyBanks Jul 6, 2021
7358679
cargo fmt
jeremyBanks Jul 6, 2021
5dc42dc
jeremyBanks Jul 6, 2021
5d78b50
sneaky hacker changing the binary
jeremyBanks Jul 6, 2021
0646e39
Revert "sneaky hacker changing the binary"
jeremyBanks Jul 6, 2021
462af7a
revert cargo fmt
jeremyBanks Jul 6, 2021
2c933be
rebuild
jeremyBanks Jul 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "rebuild wasm"

on:
workflow_dispatch:
jeremyBanks marked this conversation as resolved.
Show resolved Hide resolved

jobs:
rebuild-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: |-
curl -fsSL https://deno.land/x/install/install.sh | sh
wperron marked this conversation as resolved.
Show resolved Hide resolved
echo "$HOME/.deno/bin" >> $GITHUB_PATH

rustup target add wasm32-unknown-unknown

# This must match the version in hash/_wasm/Cargo.lock:
cargo install -f wasm-bindgen-cli --version 0.2.74

- name: rebuild generated files
id: build
run: |-
./hash/_wasm/build.ts

declare had_changes="$(
[[ -n "$(git status --porcelain)" ]] && echo true || echo false
)"
echo "::set-output name=had-changes::${had_changes}"

- name: commit and push generated files
if: success() && steps.build.outputs.had-changes == 'true'
run: |
declare br="
"
declare branch="$(echo ${GITHUB_REF#refs/heads/})"
declare date="$(git log -1 --pretty=format:'%ad')"
declare short_hash="$(git rev-parse --short=8 HEAD)"
declare short_subject="$(git log -1 --pretty=format:'%s')"
declare short_subject="$(git log -1 --pretty=format:'%s')"
if [[ ${#short_subject} -gt 50 ]]; then
short_subject="${short_subject:0:49}…"
fi
declare author_name="$(git log -1 --pretty=format:'%an')"
declare author_email="$(git log -1 --pretty=format:'%ae')"
declare current_action_url="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}"

export GIT_AUTHOR_DATE="${date}"
export GIT_AUTHOR_NAME="${author_name}"
export GIT_AUTHOR_EMAIL="${author_email}"

export GIT_COMMITTER_DATE="${date}"
export GIT_COMMITTER_NAME="github-actions"
export GIT_COMMITTER_EMAIL="41898282+github-actions[bot]@users.noreply.github.com"
jeremyBanks marked this conversation as resolved.
Show resolved Hide resolved

git remote rm origin
git remote add origin "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git checkout "${branch}"

git add .
git commit -m "chore(hash): rebuild wasm${br}${br}${current_action_url}"
git push --set-upstream origin "${branch}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ deno.d.ts
package.json
package-lock.json
.vscode/settings.json
**/cov/
**/cov/
/hash/_wasm/target
/hash/_wasm/out
95 changes: 55 additions & 40 deletions hash/_wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions hash/_wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

## Prerequisite

`wasm-pack` is required.
`wasm-bindgen` is required.

```sh
cargo install wasm-pack
cargo build --target wasm32-unknown-unknown
rustup target add wasm32-wasi

# This must match the version in hash/_wasm/Cargo.lock:
cargo install -f wasm-bindgen-cli --version 0.2.74
```

## Build

```sh
deno run --allow-read --allow-write --allow-run ./build.ts
deno run --allow-all build.ts
```

`wasm.js` will be generated.
Loading