mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 07:10:18 +00:00
air-beautify-wasm in the tree (#336)
1. Update wasm-bindgen in the wasm-air-beautify to make it buildable with rest of tree. 2. Rename `wasm-air-beautify` to `air-beautify-wasm`, to make it consistent with other packages. 3. Implement github workflows to build and deploy the `air-beautify-wasm` package.
This commit is contained in:
parent
22d39f5b23
commit
ea934ab9a9
86
.github/workflows/publish_air_beautify_wasm.yaml
vendored
Normal file
86
.github/workflows/publish_air_beautify_wasm.yaml
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
# run locally like this:
|
||||
# act -b -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j publish-air-beautify-wasm -s "NPM_TOKEN=uuid-uuid-uuid-uuid"
|
||||
|
||||
name: "publish-air-beautify-wasm"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
|
||||
jobs:
|
||||
npm-publish:
|
||||
name: "Publish air-beautify-wasm to NPM"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
|
||||
- run: cargo update --aggressive
|
||||
|
||||
- name: Install jq & sponge
|
||||
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq moreutils
|
||||
|
||||
- name: Install toml-cli
|
||||
run: cargo install toml-cli
|
||||
|
||||
- name: Get versions from local and npm, and take the highest one
|
||||
working-directory: tools/wasm/air-beautify-wasm
|
||||
run: |
|
||||
set -x
|
||||
|
||||
# install semver and add it to PATH
|
||||
yarn global add semver
|
||||
PATH="$(yarn global bin):$PATH"
|
||||
|
||||
# JQ version regex pattern
|
||||
PAT="\\\\d+.\\\\d+.\\\\d+"
|
||||
|
||||
CARGO_TOML="Cargo.toml"
|
||||
|
||||
# get package name and version from Cargo.toml
|
||||
PKG_NAME="$(toml get "$CARGO_TOML" package.name | tr -d \")"
|
||||
LOCAL_VERSION="$(toml get "$CARGO_TOML" package.version | tr -d \")"
|
||||
|
||||
# get & increment version from NPM
|
||||
JS_VERSIONS=$(yarn info --silent "$PKG_NAME" versions | tr \' \" | jq -r ".[] | select(test(\"$PAT\"))" || true)
|
||||
JS_VERSION="$(semver -p $JS_VERSIONS | tail -n1)"
|
||||
NEXT_JS_VERSION="$(semver --increment patch "$JS_VERSION" || true)"
|
||||
|
||||
# take the highest version
|
||||
MAX_VERSION="$(semver "$NEXT_JS_VERSION" "$LOCAL_VERSION" | tail -n1)"
|
||||
|
||||
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
|
||||
echo "JS_PKG_NAME=$JS_PKG_NAME" | tee -a $GITHUB_ENV
|
||||
|
||||
- name: Setup wasm-pack
|
||||
uses: jetli/wasm-pack-action@v0.3.0
|
||||
with:
|
||||
version: 'latest'
|
||||
|
||||
- name: Set interpreter version to ${{ env.FINAL_VERSION }} before the build
|
||||
working-directory: tools/wasm/air-beautify-wasm
|
||||
run: |
|
||||
toml set Cargo.toml package.version "${{ env.FINAL_VERSION }}" | sponge Cargo.toml
|
||||
|
||||
- name: Build air_interpreter_server.wasm for node
|
||||
working-directory: tools/wasm/air-beautify-wasm
|
||||
run: |
|
||||
rm -rf pkg
|
||||
wasm-pack build --release
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "14"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Publish to npm registry
|
||||
working-directory: tools/wasm/air-beautify-wasm/pkg
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: npm publish --access public
|
98
.github/workflows/snapshot.yml
vendored
98
.github/workflows/snapshot.yml
vendored
@ -9,6 +9,9 @@ on:
|
||||
air-interpreter-wasm-version:
|
||||
description: "air-interpreter-wasm version"
|
||||
value: ${{ jobs.publish-interpreter.outputs.version }}
|
||||
air-beautify-wasm-version:
|
||||
description: "air-beautify-wasm version"
|
||||
value: ${{ jobs.publish-beautify.outputs.version }}
|
||||
|
||||
env:
|
||||
FORCE_COLOR: true
|
||||
@ -237,3 +240,98 @@ jobs:
|
||||
```shell
|
||||
cargo add air-interpreter-wasm@${{ env.VERSION }} --registry fluence
|
||||
```
|
||||
|
||||
publish-air-beautify:
|
||||
name: "Publish air-beautify-wasm snapshot"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
version: "${{ steps.build.outputs.version }}"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout aquavm
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Import secrets
|
||||
uses: hashicorp/vault-action@v2.4.2
|
||||
with:
|
||||
url: https://vault.fluence.dev
|
||||
path: jwt/github
|
||||
role: ci
|
||||
method: jwt
|
||||
jwtGithubAudience: "https://github.com/fluencelabs"
|
||||
jwtTtl: 300
|
||||
exportToken: false
|
||||
secrets: |
|
||||
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
|
||||
|
||||
- name: Setup wasm-pack
|
||||
uses: jetli/wasm-pack-action@v0.3.0
|
||||
with:
|
||||
version: 'latest'
|
||||
|
||||
- name: Setup node with self-hosted npm registry
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
registry-url: "https://npm.fluence.dev"
|
||||
|
||||
- name: Build air-beautify-wasm
|
||||
run: |
|
||||
rm -rf pack
|
||||
wasm-pack build --release
|
||||
working-directory: tools/wasm/air-beautify-wasm
|
||||
|
||||
- name: Generate package version
|
||||
id: version
|
||||
run: |
|
||||
SHA=${{ github.event.pull_request.head.sha }}
|
||||
echo "::set-output name=sha::${SHA::7}"
|
||||
echo "::set-output name=branch::${GITHUB_HEAD_REF//[^a-zA-Z0-9-]/-}"
|
||||
|
||||
- name: Set package version
|
||||
id: build
|
||||
env:
|
||||
BRANCH: ${{ steps.version.outputs.branch }}
|
||||
SHA: ${{ steps.version.outputs.sha }}
|
||||
RUN: ${{ github.run_number }}
|
||||
ATTEMPT: ${{ github.run_attempt }}
|
||||
working-directory: tools/wasm/air-beautify-wasm/pkg
|
||||
run: |
|
||||
echo "::set-output name=version::$(\
|
||||
npm version prerelease \
|
||||
--no-git-tag-version \
|
||||
--preid ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }})"
|
||||
|
||||
- name: Publish to self-hosted npm repo
|
||||
working-directory: tools/wasm/air-beautify-wasm/pkg
|
||||
run: npm publish --tag snapshot --registry https://npm.fluence.dev
|
||||
|
||||
- name: Find comment in PR
|
||||
uses: peter-evans/find-comment@v1
|
||||
id: comment
|
||||
with:
|
||||
issue-number: "${{ github.event.pull_request.number }}"
|
||||
comment-author: github-actions[bot]
|
||||
body-includes: "## air-beautify-wasm version is"
|
||||
|
||||
- name: Update comment in PR
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
env:
|
||||
AIR_BEAUTIFY_VERSION: ${{ steps.build.outputs.version }}
|
||||
with:
|
||||
comment-id: "${{ steps.comment.outputs.comment-id }}"
|
||||
issue-number: "${{ github.event.pull_request.number }}"
|
||||
edit-mode: replace
|
||||
body: |
|
||||
## air-beautify-wasm version is [${{ env.AIR_BEAUTIFY_VERSION }}](https://npm.fluence.dev/-/web/detail/@fluencelabs/air_beautify/v/${{ env.AIR_BEAUTIFY_VERSION }})
|
||||
To install it run:
|
||||
```shell
|
||||
npm login --registry https://npm.fluence.dev
|
||||
npm i @fluencelabs/air-beautify-wasm@${{ env.AIR_BEAUTIFY_VERSION }} --registry=https://npm.fluence.dev
|
||||
```
|
||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -67,6 +67,14 @@ dependencies = [
|
||||
"clap 4.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "air-beautify-wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"air-beautifier",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "air-execution-info-collector"
|
||||
version = "0.1.0"
|
||||
@ -2808,6 +2816,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
|
@ -20,13 +20,13 @@ members = [
|
||||
"crates/testing-framework",
|
||||
"tools/cli/air-beautify",
|
||||
"tools/cli/air-trace",
|
||||
"tools/wasm/air-beautify-wasm",
|
||||
]
|
||||
|
||||
exclude = [
|
||||
"air/tests/test_module/integration/security_tetraplets/auth_module",
|
||||
"air/tests/test_module/integration/security_tetraplets/log_storage",
|
||||
"crates/interpreter-wasm",
|
||||
"tools/wasm/wasm-air-beautify",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "wasm-air-beautify"
|
||||
name = "air-beautify-wasm"
|
||||
version = "0.1.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2021"
|
||||
@ -13,9 +13,5 @@ crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
# 0.2.79: a function can return Result<..., JsError>.
|
||||
wasm-bindgen = { version = "=0.2.80", features = ["serde-serialize"] }
|
||||
wasm-bindgen = { version = "=0.2.82", features = ["serde-serialize"] }
|
||||
air-beautifier = { version = "0.1.0", path = "../../../crates/beautifier" }
|
||||
|
||||
[profile.release]
|
||||
# Tell `rustc` to optimize for small code size.
|
||||
opt-level = "s"
|
Loading…
Reference in New Issue
Block a user