Use rust-toolchain to setup rust (#318)

This commit is contained in:
Anatoly Laskaris 2022-09-09 16:34:19 +03:00 committed by GitHub
parent a77fb3395c
commit 7a146501a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 168 deletions

View File

@ -8,40 +8,25 @@ on:
jobs:
pre-release:
name: "Tagged Release"
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-wasi
profile: minimal
override: true
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install marine
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: install
args: marine
- run: cargo install marine
### Update & build
- uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: update
- run: cargo update
- name: marine build --release
working-directory: ./air-interpreter
shell: bash
run: marine build --release --features marine
### Create release
- uses: marvinpinto/action-automatic-releases@latest
- name: Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"

View File

@ -7,46 +7,38 @@ concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
air:
name: "Run aquavm tests"
runs-on: builder
env:
RUST_TEST_THREADS: 1
CARGO_HOME: "${{ github.workspace }}/cargo"
env:
RUST_BACKTRACE: 1
RUST_TEST_THREADS: 1
CARGO_TERM_COLOR: always
jobs:
aquavm:
name: "Run tests"
runs-on: builder
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-06-29
target: wasm32-wasi
components: rustfmt, clippy
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: "Cache rust"
uses: Swatinem/rust-cache@v1
- run: cargo install marine
- name: "Download marine"
run: .github/download_marine.sh
- name: "Build Wasm binary for interpreter"
- name: Build Wasm binary for interpreter
run: marine build --features marine
working-directory: air-interpreter
- name: "Build Wasm binary for tests"
- name: Build Wasm binary for tests
run: ./build_test_binaries.sh
working-directory: air/tests/test_module
- name: "cargo fmt"
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: "cargo check"
- name: Run cargo check
run: cargo check
- name: "cargo test"
- name: Run cargo test
run: |
cargo test --release
# Check that it does compile
@ -56,5 +48,5 @@ jobs:
RUSTFLAGS="-Z sanitizer=$san" cargo test --features test_with_native_code --target x86_64-unknown-linux-gnu
done
- name: "cargo clippy"
- name: Run cargo clippy
run: cargo clippy -v

View File

@ -9,39 +9,17 @@ jobs:
cargo-publish:
name: "Publish crates"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v2
### Prepare cargo & toolchains
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-03-20
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
toolchain: nightly-2022-03-20
command: update
args: --aggressive
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install cargo-workspaces
run: cargo install cargo-workspaces || true
run: cargo install cargo-workspaces
### === Rust package release ===
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}

View File

@ -12,48 +12,21 @@ jobs:
npm-publish:
name: "Publish AIR to NPM & crates.io"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v2
### Prepare cargo & toolchains
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-v2-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain with wasm32-unknown-unknown
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-03-20
target: wasm32-unknown-unknown
profile: minimal
override: true
- name: Install wasm32-wasi
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-03-20
target: wasm32-wasi
profile: minimal
- uses: actions-rs/cargo@v1
with:
toolchain: nightly-2022-03-20
command: update
args: --aggressive
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo update --aggressive
### 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
run: cargo install cargo-show toml-cli
- name: Get versions from npm & crates.io, and take the highest one
run: |
@ -97,13 +70,11 @@ jobs:
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
echo "JS_PKG_NAME=$JS_PKG_NAME" | tee -a $GITHUB_ENV
### === Rust package release ===
- name: Install marine
run: cargo install marine || true
run: cargo install marine
- name: Set interpreter version to ${{ env.FINAL_VERSION }} before the build
run: |
PATH="~/.cargo/bin:$PATH"
(
cd air-interpreter
toml set Cargo.toml package.version "${{ env.FINAL_VERSION }}" | sponge Cargo.toml
@ -121,9 +92,7 @@ jobs:
run: cp target/wasm32-wasi/release/air_interpreter_server.wasm crates/interpreter-wasm/air_interpreter_server.wasm
- name: Set project version to ${{ env.FINAL_VERSION }}
run: |
PATH="~/.cargo/bin:$PATH"
toml set Cargo.toml package.version "${{ env.FINAL_VERSION }}" | sponge Cargo.toml
run: toml set Cargo.toml package.version "${{ env.FINAL_VERSION }}" | sponge Cargo.toml
working-directory: crates/interpreter-wasm
- name: Login to crates.io
@ -133,7 +102,6 @@ jobs:
run: cargo publish --allow-dirty
working-directory: crates/interpreter-wasm
### Create a pre-release
- name: Create Release
id: create_release
uses: actions/create-release@v1
@ -148,7 +116,6 @@ jobs:
draft: false
prerelease: false
### === JavaScript package release ===
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
continue-on-error: true
@ -160,18 +127,18 @@ jobs:
npm i
npm run build
### Set version
- name: Set version to ${{ env.FINAL_VERSION }}
run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version
working-directory: avm/client
### Publish to NPM registry
- uses: actions/setup-node@v1
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "14"
registry-url: "https://registry.npmjs.org"
- run: npm publish --access public
working-directory: avm/client
- name: Publish to npm registry
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
working-directory: avm/client

View File

@ -6,18 +6,14 @@ name: "publish-interpreter-branch"
on:
push:
branches-ignore:
- master
- "master"
jobs:
npm-publish-dev:
name: "Publish AIR interpreter .wasm to NPM & crates.io"
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
@ -30,39 +26,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
### Prepare cargo & toolchains
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ runner.os }}-cargo-v2-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain with wasm32-unknown-unknown
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-03-20
target: wasm32-unknown-unknown
profile: minimal
override: true
- name: Install wasm32-wasi
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-03-20
target: wasm32-wasi
profile: minimal
- uses: actions-rs/cargo@v1
with:
toolchain: nightly-2022-03-20
command: update
args: --aggressive
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo update --aggressive
### 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
run: cargo install cargo-show toml-cli
- name: Get versions from npm & crates.io, and take the highest one
run: |
@ -121,13 +94,11 @@ jobs:
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
echo "JS_PKG_NAME=$JS_PKG_NAME" | tee -a $GITHUB_ENV
### === Rust package release ===
- name: Install marine
run: cargo install marine || true
run: cargo install marine
- name: Set interpreter version to ${{ env.FINAL_VERSION }} before the build
run: |
PATH="~/.cargo/bin:$PATH"
(
cd air-interpreter
toml set Cargo.toml package.version "${{ env.FINAL_VERSION }}" | sponge Cargo.toml
@ -146,7 +117,6 @@ jobs:
- name: Set project name@version to ${{ env.PKG_NAME }}@${{ env.FINAL_VERSION }}
run: |
PATH="~/.cargo/bin:$PATH"
toml set Cargo.toml package.version "${{ env.FINAL_VERSION }}" | sponge Cargo.toml
NAME=$(toml get Cargo.toml package.name | jq -r .)
@ -160,7 +130,6 @@ jobs:
run: cargo publish --allow-dirty
working-directory: crates/interpreter-wasm
### === JavaScript package release ===
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
continue-on-error: true
@ -172,17 +141,18 @@ jobs:
npm i
npm run build
### Set version to FINAL_VERSION
- run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version || true
- name: Set version to ${{ env.FINAL_VERSION }}
run: yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version || true
working-directory: avm/client
### Publish to NPM registry
- uses: actions/setup-node@v1
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "14"
registry-url: "https://registry.npmjs.org"
- run: npm publish --access public --tag=beta
working-directory: avm/client
- name: Publish to npm registry
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --tag=beta
working-directory: avm/client

View File

@ -2,13 +2,13 @@ name: rustdoc
on:
push:
branches:
- master
- "master"
workflow_dispatch:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTFLAGS: ""
RUSTUP_MAX_RETRIES: 10
jobs:
@ -19,16 +19,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true
components: rustfmt, rust-src
- name: Build Documentation
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --all --no-deps
env:
RUSTDOCFLAGS: "--enable-index-page -Zunstable-options"
run: cargo +nightly doc --all --no-deps
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3.7.3

6
rust-toolchain.toml Normal file
View File

@ -0,0 +1,6 @@
[toolchain]
# AquaVM can be built with "stable", "nightly" required only to build Marine tests
channel = "nightly"
components = [ "rustfmt", "clippy" ]
targets = [ "x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "wasm32-wasi" ]
profile = "minimal"