ci: Add marine e2e (#230)

This commit is contained in:
Anatolios Laskaris 2022-11-21 13:17:18 +02:00 committed by GitHub
parent 10db33a0b3
commit 70638f1f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 167 additions and 129 deletions

2
.cargo/config.toml Normal file
View File

@ -0,0 +1,2 @@
[registries]
fluence = { index = "git://crates.fluence.dev/index" }

117
.github/workflows/e2e.yml vendored Normal file
View File

@ -0,0 +1,117 @@
name: "e2e"
on:
pull_request:
paths-ignore:
- "!**.md"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
FORCE_COLOR: true
jobs:
snapshot:
name: "marine"
uses: ./.github/workflows/snapshot.yml
aquavm:
needs:
- snapshot
uses: fluencelabs/aquavm/.github/workflows/snapshot.yml@master
with:
cargo-dependencies: |
[
{
"package": "marine-runtime",
"manifest": "avm/server/Cargo.toml",
"version": "=${{ needs.snapshot.outputs.cargo-version }}",
"registry": "fluence"
},
{
"package": "fluence-app-service",
"manifest": "air/Cargo.toml",
"version": "=${{ needs.snapshot.outputs.cargo-version }}",
"registry": "fluence"
}
]
rust-peer:
needs:
- snapshot
- aquavm
uses: fluencelabs/rust-peer/.github/workflows/snapshot.yml@master
with:
cargo-dependencies: |
[
{
"package": "fluence-app-service",
"version": "=${{ needs.snapshot.outputs.cargo-version }}",
"registry": "fluence"
},
{
"package": "avm-server",
"version": "=${{ needs.aquavm.outputs.cargo-version }}",
"registry": "fluence"
},
{
"package": "air-interpreter-wasm",
"version": "=${{ needs.aquavm.outputs.cargo-version }}",
"registry": "fluence"
}
]
fluence-js-tests:
name: "fluence-js"
needs:
- aquavm
- rust-peer
uses: fluencelabs/fluence-js/.github/workflows/tests.yml@master
with:
avm-version: "${{ needs.aquavm.outputs.avm-version }}"
rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}"
fluence-js-snapshot:
name: "fluence-js"
needs:
- aquavm
uses: fluencelabs/fluence-js/.github/workflows/snapshot.yml@master
with:
avm-version: "${{ needs.aquavm.outputs.avm-version }}"
aqua-snapshot:
name: "aqua"
needs:
- fluence-js-snapshot
uses: fluencelabs/aqua/.github/workflows/snapshot.yml@main
with:
fluence-js-version: "${{ needs.fluence-js-snapshot.outputs.fluence-js-version }}"
aqua-playground:
needs:
- fluence-js-snapshot
- aqua-snapshot
- rust-peer
uses: fluencelabs/aqua-playground/.github/workflows/tests.yml@master
with:
fluence-js-version: "${{ needs.fluence-js-snapshot.outputs.fluence-js-version }}"
aqua-version: "${{ needs.aqua-snapshot.outputs.aqua-version }}"
rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}"
registry:
needs:
- aqua-snapshot
- rust-peer
uses: fluencelabs/registry/.github/workflows/tests.yml@main
with:
aqua-version: "${{ needs.aqua-snapshot.outputs.aqua-version }}"
rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}"

View File

@ -1,127 +0,0 @@
# run locally like this:
# act -b -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j publish-npm-branch -s "NPM_TOKEN=uuid-uuid-uuid-uuid"
name: "publish-npm-branch"
on:
push:
branches-ignore:
- master
jobs:
npm-publish-dev:
name: "Publish marine-js package to NPM"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
### Extract branch name
- name: Extract branch name
if: github.event_name != 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
id: extract_branch
- name: Extract branch name
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
### Calculate FINAL_VERSION
- name: Install jq & sponge
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq moreutils
- name: Install cargo-show & toml-cli
run: cargo install cargo-show toml-cli || true
- name: Get versions from npm & crates.io, and take the highest one
run: |
set -x
# install semver and add it to PATH
yarn global add semver
PATH="$(yarn global bin):$PATH"
MARINE_JS_CARGO_TOML="marine-js/Cargo.toml"
CARGO_TOML="marine-js/Cargo.toml"
PACKAGE_JSON="marine-js/npm-package/package.json"
# sanitize branch name so it can be used as a semver suffix (replace [^0-9a-zA-Z-] with hyphen)
SANITIZED_BRANCH="$(echo -n "${{ env.BRANCH_NAME }}" | tr -C '[:alnum:]-' -)"
# JQ Version regex pattern
PAT="\\\\d+.\\\\d+.\\\\d+-$SANITIZED_BRANCH.\\\\d+"
# get package name from Cargo.toml
PKG_NAME="$(toml get "$CARGO_TOML" package.name | tr -d \")"
# get package name from package.json
JS_PKG_NAME="$(cat "$PACKAGE_JSON" | jq -r .name)"
### NPM
# take all versions from npm and replace single quotes with double quotes
NPM_VERSIONS=$(yarn info --silent "$JS_PKG_NAME" versions 2>/dev/null | tr \' \")
# take only versions that contain branch name
NPM_VERSIONS_FILTERED=$(echo $NPM_VERSIONS | jq -r ".[] | select(test(\"$PAT\"))")
# flatten into a single line
NPM_VERSIONS_FLATTENED=$(echo $NPM_VERSIONS_FILTERED | awk '{print}' ORS=' ')
# sort versions according to semver, take highest (last)
LAST_NPM_VERSION="$(semver -p $(echo $NPM_VERSIONS_FLATTENED) | tail -n1 || true)"
# increment prerelease part of the version
PRERELEASE_NPM_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${LAST_NPM_VERSION}" || true)"
### CRATES.IO
CRATE_VERSIONS=$(cargo show --json "$PKG_NAME")
CRATE_VERSIONS_FILTERED=$(echo $CRATE_VERSIONS | jq -r ".versions[] | .num | select(test(\"$PAT\"))")
CRATE_VERSIONS_FLATTENED=$(echo $CRATE_VERSIONS_FILTERED | awk '{print}' ORS=' ')
LAST_CRATE_VERSION="$(semver -p $(echo $CRATE_VERSIONS_FLATTENED) | tail -n1 || true)"
PRERELEASE_CRATE_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${LAST_CRATE_VERSION}" || true)"
### LOCAL
### (NOTE: the following code assumes that local versions do not contain prerelease suffix; existing suffix will be ignored)
# take local Rust version
LOCAL_RUST_VERSION="$(toml get "$CARGO_TOML" package.version | tr -d \")"
MARINE_JS_RUST_VERSION="$(toml get "$MARINE_JS_CARGO_TOML" package.version | tr -d \")"
MAX_RUST_VERSION="$(semver "$LOCAL_RUST_VERSION" "MARINE_JS_RUST_VERSION" | tail -n1)"
LOCAL_RUST_PRERELEASE_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${MAX_RUST_VERSION}-0")" # added '-0' here to avoid semver erroneously increment patch octet. Any suffix works, '-0' is chosen deliberately.
### SAVE FINAL VERSION TO ENV
# take the highest version
MAX_VERSION="$(semver "$LOCAL_RUST_PRERELEASE_VERSION" "$PRERELEASE_NPM_VERSION" "$PRERELEASE_CRATE_VERSION" | tail -n1)"
# save info to env
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
echo "JS_PKG_NAME=$JS_PKG_NAME" | tee -a $GITHUB_ENV
### === JavaScript package release ===
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
continue-on-error: true
- name: Build npm package
working-directory: marine-js
run: |
./build.sh
cd npm-package
npm i
npm run build
- name: Set version to FINAL_VERSION
run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version || true
working-directory: marine-js/npm-package
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"
- name: Publish to NPM registry
run: npm publish --access public --tag=beta
working-directory: marine-js/npm-package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

46
.github/workflows/snapshot.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: Publish snapshots
on:
workflow_call:
outputs:
cargo-version:
description: "cargo snapshot version"
value: ${{ jobs.cargo-snapshot.outputs.version }}
jobs:
cargo-snapshot:
name: "Publish cargo snapshots"
runs-on: builder
outputs:
version: "${{ steps.snapshot.outputs.version }}"
permissions:
contents: read
id-token: write
steps:
- name: Checkout Marine
uses: actions/checkout@v3
with:
repository: fluencelabs/marine
- 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/cargo-registry/users/ci token | CARGO_REGISTRIES_FLUENCE_TOKEN
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Publish cargo snapshots
id: snapshot
uses: fluencelabs/github-actions/cargo-publish-snapshot@main

View File

@ -17,7 +17,7 @@ marine-it-parser = { path = "../crates/it-parser", version = "0.11.0" }
marine-it-generator = { path = "../crates/it-generator", version = "0.9.4" }
marine-module-interface = { path = "../crates/module-interface", version = "0.6.0" }
marine-utils = { path = "../crates/utils", version = "0.4.0" }
marine-min-it-version = { path = "../crates/min-it-version", version = "0.2.0" }
marine-min-it-version = { path = "../crates/min-it-version", version = "0.2.0" }
wasmer-runtime = { package = "wasmer-runtime-fl", version = "=0.17.1" }
# dynamicfunc-fat-closures allows using state inside DynamicFunc

View File

@ -13,7 +13,7 @@ crate-type = ["cdylib"]
marine-it-interfaces = { path = "../crates/it-interfaces", version = "0.7.3" }
marine-module-interface = { path = "../crates/module-interface", version = "0.6.0" }
marine-utils = { path = "../crates/utils", version = "0.4.0" }
marine-min-it-version = { path = "../crates/min-it-version", version = "0.2.0" }
marine-min-it-version = { path = "../crates/min-it-version", version = "0.2.0" }
it-json-serde = { path = "../crates/it-json-serde", version = "0.3.4" }
marine-rs-sdk = "0.7.1"