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

Create deterministic wasm builds and publish release on tag #150

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9992135
BIT-353: Use srtool-actions to build deterministic wasm and upload to…
Jun 7, 2023
1d33885
BIT-353: Fix github.workspace var and remove macos targets in publish…
Jun 7, 2023
581b151
BIT-353: Remove duplicate cache utilization in workflow
Jun 7, 2023
1f565d3
BIT-353: Clarify release creation workflow name
Jun 7, 2023
9e06f27
BIT-353: Fix package name in srtools and hardcode chainspec chain arg
Jun 7, 2023
875962d
BIT-353: Switch rustup toolchain from stable to nightly
Jun 7, 2023
1f03619
BIT-353: Use toolchain file in publish-tag workflow
Jun 7, 2023
fb3e3ca
BIT-353: Remove --tests flag from testing step and use release
Jun 7, 2023
14ac229
BIT-353: Fix misconfiguration of actions-rs/toolchain for toolchain file
Jun 7, 2023
482da72
BIT-353: Clarify job name for publishing
Jun 7, 2023
345f8df
BIT-353: Fix actions-rs/toolchain configuration
Jun 7, 2023
48ae1c7
BIT-353: Use --tests in testing as some tests in --release dont panic
Jun 7, 2023
338183d
BIT-353: Add wasm32 target to toolchain
Jun 7, 2023
e382438
BIT-353: Remove useless steps in check-rust
Jun 8, 2023
35aaf04
BIT-353: Add toolchain override for working dir
Jun 8, 2023
d2104ad
BIT-353: Remove linux target from workflow
Jun 9, 2023
e7fc009
BIT-353: Update toolchain version and fix rust cache
Jun 9, 2023
2227106
BIT-353: Enforce target and toolchain in srtool build, fix cache
Jun 9, 2023
6b7cd63
BIT-353: Use correct env vars for toolchain and build target
Jun 9, 2023
d8ffd54
BIT-353: Readd TARGET env var
Jun 9, 2023
d19b89c
BIT-353: Remove CARGO_BUILD_TARGET env var
Jun 9, 2023
e8aa9df
BIT-353: Use +nightly flag in cargo commands, set TARGET env var
Jun 9, 2023
668e423
BIT-353: Use self-hosted runner for build generation
Jun 13, 2023
e4de453
BIT-353: Use brew in dep install as self-hosted runner is macOS
Jun 13, 2023
2332021
BIT-353: Update brew install deps
Jun 13, 2023
0762582
BIT-353: BIT-353 adding workflow_dispatch for publish tag github acti…
eduardogr Aug 21, 2023
38a6099
BIT-353: BIT-353 trigger publish tag workflow for development branch …
eduardogr Aug 21, 2023
90a2323
BIT-353: BIT-353 trigger publish tag workflow for development branch …
eduardogr Aug 21, 2023
ecb1f6e
BIT-353: BIT-353 github-action; publish-tag; use ubuntu-latest
eduardogr Aug 21, 2023
092683d
BIT-353: BIT-353 github-action; publish-tag; use ubuntu-latest
eduardogr Aug 21, 2023
8b5f13c
BIT-353: BIT-353 github-action; publish-tag; use ubuntu-latest
eduardogr Aug 21, 2023
d1e2ada
BIT-353: BIT-353 github-action; publish-tag; use ubuntu-latest
eduardogr Aug 21, 2023
3de6c83
BIT-353: BIT-353 github-action; publish-tag; Use self hosted and exeu…
eduardogr Aug 21, 2023
269367b
BIT-353: BIT-353 fixing scrips ./scrips/install-deps.sh
eduardogr Aug 21, 2023
fc7f7df
BIT-353: BIT-353 fixing scrips ./scrips/install-deps.sh
eduardogr Aug 21, 2023
e7bd7ee
BIT-353: BIT-353 fixing scrips ./scrips/install-deps.sh
eduardogr Aug 21, 2023
e6050d9
BIT-353: BIT-353 fixing scrips caching for publish-tag.yml workflow
eduardogr Aug 21, 2023
7f814ae
BIT-353: BIT-353 fixing publish-tag.yaml caching
eduardogr Aug 21, 2023
8b7e03c
BIT-353: BIT-353 improving publish-tag.yml caching
eduardogr Aug 21, 2023
8d236a8
BIT-353: BIT-353 improving publish-tag.yml caching
eduardogr Aug 21, 2023
c338951
BIT-353: BIT-353 adding profile ephemeral build and use opt-level 2 f…
eduardogr Aug 22, 2023
3506da6
BIT-353: BIT-353 adding profile ephemeral build and use opt-level 2 f…
eduardogr Aug 22, 2023
258bfc3
BIT-353: BIT-353 adding profile ephemeral build and use opt-level 2 f…
eduardogr Aug 22, 2023
a463b9f
BIT-353: BIT-353 upgrade srtool-actions to 0.8.0
eduardogr Aug 24, 2023
e8771d6
BIT-353: fixing publish-tag.yml workflow
eduardogr Sep 6, 2023
ba43012
BIT-353: BIT-353 debugging github action
eduardogr Sep 8, 2023
8612085
BIT-353: BIT-353 +nightly is not a build opt for cargo build. That wa…
eduardogr Sep 22, 2023
6980542
BIT-353: BIT-353 trying to fix gh action 'publish-tag' removing optio…
eduardogr Sep 22, 2023
29bcf6c
BIT-353: BIT-353 trying to fix gh action 'publish-tag'
eduardogr Sep 25, 2023
4ec67b0
BIT-353: BIT-353 removing extra 'cargo build'
eduardogr Sep 25, 2023
e2d26ab
BIT-353: BIT-353 removing extra step for debugging 'whoami'
eduardogr Sep 25, 2023
866ca73
BIT-353: BIT-353 trying to fix gh action 'publish-tag' removing optio…
eduardogr Sep 25, 2023
7816f51
BIT-353: BIT-353 UNDO -> trying to fix gh action 'publish-tag' by ren…
eduardogr Sep 25, 2023
c426423
BIT-353: BIT-353 trying to fix gh action 'publish-tag' adding package…
eduardogr Sep 25, 2023
e28a193
BIT-353: BIT-353 trying to fix gh action 'publish-tag' adding package…
eduardogr Sep 25, 2023
f9d70c1
BIT-353: BIT-353 change cargo profiles a bit
eduardogr Oct 6, 2023
f26a648
BIT-353: BIT-353 change cargo profiles a bit
eduardogr Oct 6, 2023
7803f64
BIT-353: BIT-353 change cargo profiles a bit
eduardogr Oct 6, 2023
9eb2da7
BIT-353: BIT-353 change cargo profiles a bit
eduardogr Oct 6, 2023
a2db97c
BIT-353: BIT-353 adding all test form pallets/subtensor/test/*.rs int…
eduardogr Oct 6, 2023
00ee1f2
BIT-353: BIT-353 change cargo profiles a bit
eduardogr Oct 6, 2023
aa6d135
BIT-353: BIT-353 adding custom image to run srtool
eduardogr Oct 12, 2023
9db71e6
BIT-353: BIT-353 adding custom image to run srtool
eduardogr Oct 12, 2023
50e5214
BIT-353: BIT-353 adding custom image to run srtool
eduardogr Oct 12, 2023
174f8cc
BIT-353: BIT-353 adding custom image to run srtool
eduardogr Oct 12, 2023
16f01f3
BIT-353: BIT-353 adding custom image to run srtool
eduardogr Oct 19, 2023
5029a45
BIT-353: BIT-353 adding custom image to run srtool
eduardogr Oct 19, 2023
a13c0ed
BIT-353: BIT-353 adding custom image to run srtool
eduardogr Oct 23, 2023
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
29 changes: 13 additions & 16 deletions .github/workflows/check-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
strategy:
matrix:
rust-branch:
- nightly-2023-01-18
- nightly-2023-03-01

rust-target:
- x86_64-unknown-linux-gnu
Expand Down Expand Up @@ -95,25 +95,22 @@ jobs:
toolchain: ${{ matrix.rust-branch }}
profile: minimal

- name: Utilize Rust shared cached
uses: Swatinem/[email protected]
- 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>`
- 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

100 changes: 70 additions & 30 deletions .github/workflows/publish-tag.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust build, benchmarks, and tests
name: Build wasm, chainspec and publish release

concurrency:
group: ci-${{ github.ref }}
Expand All @@ -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
Expand All @@ -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/[email protected]
#- 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/[email protected]

- name: ⚡ Run sccache-cache
uses: mozilla-actions/[email protected]

#- 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/[email protected]
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;
Expand All @@ -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 }}'
13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 30 additions & 0 deletions scripts/install-deps.sh
Original file line number Diff line number Diff line change
@@ -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
Loading