diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 6d730630d..141b3b4ff 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -55,7 +55,7 @@ jobs: strategy: matrix: rust-branch: - - nightly-2023-01-18 + - nightly-2023-03-01 rust-target: - x86_64-unknown-linux-gnu @@ -95,25 +95,22 @@ jobs: toolchain: ${{ matrix.rust-branch }} profile: minimal - - name: Utilize Rust shared cached - uses: Swatinem/rust-cache@v2.2.1 + - name: Set up cargo cache + uses: actions/cache@v3 + continue-on-error: false with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.rust-target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ matrix.rust-target }}-cargo- ## TODO: maybe use `if` conditions in tests to target `--package ` - name: Run tests # timeout-minutes: 30 run: | - cargo test --tests - - - name: Run benchmarks - # timeout-minutes: 30 - run: | - pushd node && - cargo build --features=runtime-benchmarks --release - - - name: Build executable - # timeout-minutes: 30 - run: | - cargo build --release + cargo test --tests --features=runtime-benchmarks diff --git a/.github/workflows/publish-tag.yml b/.github/workflows/publish-tag.yml index 53d7a4760..59bb561f3 100644 --- a/.github/workflows/publish-tag.yml +++ b/.github/workflows/publish-tag.yml @@ -1,4 +1,4 @@ -name: Rust build, benchmarks, and tests +name: Build wasm, chainspec and publish release concurrency: group: ci-${{ github.ref }} @@ -11,6 +11,11 @@ on: push: tags: - 'v[0-9]+.[0-9]+.[0-9]+' + ## + # Alternatives triggers + branches: + - "BIT-353-create-deterministic-wasm-builds-on-github-tag" + workflow_dispatch: ## # Environment variables shared for all targets @@ -27,63 +32,99 @@ env: # Test and build and publish jobs: check: - name: Tests and publishes targeting ${{ matrix.rust-target }} for OS ${{ matrix.os }} + name: Testing, building and publishing for ${{ matrix.rust-target }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} ## # Define multiple targets for builds and tests strategy: matrix: - rust-branch: - - stable + chain: + - node-subtensor + + rust-toolchain: + - nightly-2023-03-01 rust-target: - - x86_64-unknown-linux-gnu - - x86_64-apple-darwin + - wasm32-unknown-unknown os: - - ubuntu-latest - - macos-latest - - include: - - os: ubuntu-latest - - os: macos-latest + - self-hosted ## # Environment variables specific to each target env: - RUSTV: ${{ matrix.rust-branch }} RUST_BIN_DIR: target/${{ matrix.rust-target }}/release + RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} TARGET: ${{ matrix.rust-target }} ## steps: - - name: Check-out repository under $GITHUB_WORKSPACE + - name: Check-out repository under ${{ github.workspace }} uses: actions/checkout@v2 - - name: Install dependencies + - name: 🔧 Install dependencies run: | - sudo apt update && - sudo apt install -y git clang curl libssl-dev llvm libudev-dev protobuf-compiler + ./scripts/install-deps.sh - - name: Install Rust ${{ matrix.rust-branch }} - uses: actions-rs/toolchain@v1.0.6 + - name: 🔧 Install Rust + uses: actions-rs/toolchain@v1 with: - toolchain: ${{ matrix.rust-branch }} + toolchain: ${{ matrix.rust-toolchain }} + target: ${{ matrix.rust-target }} + override: true profile: minimal - - name: Utilize Rust shared cached - uses: Swatinem/rust-cache@v2.2.1 + #- name: ⚡ Cache + # uses: actions/cache@v3 + # continue-on-error: false + # with: + # path: | + # ~/.cargo/bin/ + # ~/.cargo/registry/index/ + # ~/.cargo/registry/cache/ + # ~/.cargo/git/db/ + # target/ + # key: ${{ matrix.rust-target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: ⚡ Cache dependencies + uses: Swatinem/rust-cache@v2.6.2 + + - name: ⚡ Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + + #- name: 🔎 Test + # run: | + # cargo test --tests --profile ci-test + + #- name: 🚀 Build executable + # run: | + # cargo build --profile ci-release + + - name: Srtool build + id: srtool_build + uses: chevdor/srtool-actions@v0.8.0 + env: + RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} + TARGET: ${{ matrix.rust-target }} + #BUILD_OPTS: "" with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} - - - name: Run tests + chain: ${{ matrix.chain }} + image: paritytech/srtool + tag: 1.69.0 + runtime_dir: runtime + package: node-subtensor-runtime + profile: ci-release + + - name: Srtool summary run: | - cargo test --tests + echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.chain }}-srtool-digest.json + cat ${{ matrix.chain }}-srtool-digest.json + echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" - - name: Build executable + - name: Create chainspec run: | - cargo build --release + target/${{ matrix.rust-target }}/release/node-subtensor build-spec --disable-default-bootnode --raw --chain finney > release_chainspec.json ## TODO: double-check `artifacts` path(s) be correct # :warning: values for the following must always match; @@ -98,5 +139,4 @@ jobs: makeLatest: true tag: ${{ github.ref }}-${{ matrix.rust-target }} name: Release ${{ github.ref }} for ${{ matrix.rust-target }} - artifacts: 'raw_spec.json,raw_spec_finney.json,target/${{ matrix.rust-target }}/release/node-subtensor' - + artifacts: 'release_chainspec.json,target/${{ matrix.rust-target }}/release/node-subtensor,${{ steps.srtool_build.outputs.wasm_compressed }}' diff --git a/Cargo.toml b/Cargo.toml index 410d184a9..8e7d8d08e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,15 @@ members = [ "runtime", ] -[profile.release] -panic = "unwind" +[profile.ci-dev] +inherits = "dev" +incremental = true + +[profile.ci-test] +inherits = "ci-dev" -[profile.test] +[profile.ci-release] +inherits = "release" +panic = "unwind" opt-level = 3 +codegen-units = 8 diff --git a/pallets/subtensor/tests/batch_tx.rs b/pallets/subtensor/tests/integration/batch_tx.rs similarity index 100% rename from pallets/subtensor/tests/batch_tx.rs rename to pallets/subtensor/tests/integration/batch_tx.rs diff --git a/pallets/subtensor/tests/block_step.rs b/pallets/subtensor/tests/integration/block_step.rs similarity index 100% rename from pallets/subtensor/tests/block_step.rs rename to pallets/subtensor/tests/integration/block_step.rs diff --git a/pallets/subtensor/tests/difficulty.rs b/pallets/subtensor/tests/integration/difficulty.rs similarity index 100% rename from pallets/subtensor/tests/difficulty.rs rename to pallets/subtensor/tests/integration/difficulty.rs diff --git a/pallets/subtensor/tests/epoch.rs b/pallets/subtensor/tests/integration/epoch.rs similarity index 100% rename from pallets/subtensor/tests/epoch.rs rename to pallets/subtensor/tests/integration/epoch.rs diff --git a/pallets/subtensor/tests/mock.rs b/pallets/subtensor/tests/integration/mock.rs similarity index 100% rename from pallets/subtensor/tests/mock.rs rename to pallets/subtensor/tests/integration/mock.rs diff --git a/pallets/subtensor/tests/networks.rs b/pallets/subtensor/tests/integration/networks.rs similarity index 100% rename from pallets/subtensor/tests/networks.rs rename to pallets/subtensor/tests/integration/networks.rs diff --git a/pallets/subtensor/tests/neuron_info.rs b/pallets/subtensor/tests/integration/neuron_info.rs similarity index 100% rename from pallets/subtensor/tests/neuron_info.rs rename to pallets/subtensor/tests/integration/neuron_info.rs diff --git a/pallets/subtensor/tests/registration.rs b/pallets/subtensor/tests/integration/registration.rs similarity index 100% rename from pallets/subtensor/tests/registration.rs rename to pallets/subtensor/tests/integration/registration.rs diff --git a/pallets/subtensor/tests/senate.rs b/pallets/subtensor/tests/integration/senate.rs similarity index 100% rename from pallets/subtensor/tests/senate.rs rename to pallets/subtensor/tests/integration/senate.rs diff --git a/pallets/subtensor/tests/serving.rs b/pallets/subtensor/tests/integration/serving.rs similarity index 100% rename from pallets/subtensor/tests/serving.rs rename to pallets/subtensor/tests/integration/serving.rs diff --git a/pallets/subtensor/tests/staking.rs b/pallets/subtensor/tests/integration/staking.rs similarity index 100% rename from pallets/subtensor/tests/staking.rs rename to pallets/subtensor/tests/integration/staking.rs diff --git a/pallets/subtensor/tests/sudo.rs b/pallets/subtensor/tests/integration/sudo.rs similarity index 100% rename from pallets/subtensor/tests/sudo.rs rename to pallets/subtensor/tests/integration/sudo.rs diff --git a/pallets/subtensor/tests/uids.rs b/pallets/subtensor/tests/integration/uids.rs similarity index 100% rename from pallets/subtensor/tests/uids.rs rename to pallets/subtensor/tests/integration/uids.rs diff --git a/pallets/subtensor/tests/weights.rs b/pallets/subtensor/tests/integration/weights.rs similarity index 100% rename from pallets/subtensor/tests/weights.rs rename to pallets/subtensor/tests/integration/weights.rs diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh new file mode 100755 index 000000000..2aba1c374 --- /dev/null +++ b/scripts/install-deps.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function install_macosx_darwin_22_deps() +{ + brew upgrade && + yes | brew install git cmake openssl protobuf +} + +function install_deps() +{ + if [[ "$OSTYPE" == "linux-gnu" ]]; then + sudo apt upgrade -y && \ + sudo apt install -y git build-essential make clang libssl-dev llvm libudev-dev protobuf-compiler + elif [[ "$OSTYPE" == 'darwin22.0' ]]; then + install_macosx_darwin_22_deps + elif [[ "$OSTYPE" == 'darwin22' ]]; then + install_macosx_darwin_22_deps + elif [[ "$OSTYPE" == "darwin" ]]; then + echo "NOT IMPLEMENTED: $OSTYPE" + exit 1 + elif [[ "$OSTYPE" == "darwin20" ]]; then + echo "NOT IMPLEMENTED: $OSTYPE" + exit 1 + else + echo "NOT IMPLEMENTED: $OSTYPE" + exit 1 + fi +} + +install_deps \ No newline at end of file