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

Travis - Faster CI checks #464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7068344
cargo: run tests and clippy in release mode
mnaamani May 23, 2020
a09808c
travis and hooks, cargo test and clippy for target
mnaamani May 23, 2020
2bf96c1
travis: cache cargo again
mnaamani May 24, 2020
64d3c88
travis: additional optimizations
mnaamani May 24, 2020
e0ccff7
travis: test recompiling runtime with cargo cache enabled
mnaamani May 24, 2020
25835ba
travis: fail if cargo test and clippy fail
mnaamani May 24, 2020
ca7c856
scripts: no need to explicitly pull a docker image
mnaamani May 24, 2020
53a706a
travis: disable cache again to test build time
mnaamani May 24, 2020
0b01fb1
travis: experiment with caching with just one travis job
mnaamani May 25, 2020
e272365
travis: re-enable cargo cache
mnaamani May 25, 2020
a2ab792
build.rs - make sure to trigger WASM build after dummy from clippy
mnaamani May 25, 2020
0fcdf28
travis: clippy before test
mnaamani May 25, 2020
f797393
travis: use nightly for clippy to avoid messing with env variables
mnaamani May 25, 2020
6fcd61a
travis: install clippy for nightly toolchain
mnaamani May 25, 2020
421ff7b
travis, build scripts use nightly
mnaamani May 26, 2020
80749a7
travis: cache enabled
mnaamani May 26, 2020
ed157e4
travi: typo fix
mnaamani May 26, 2020
9fcd2aa
travis: rustfmt not available in nightly?
mnaamani May 26, 2020
66a8fea
travis: rust stable by default and add nightly
mnaamani May 26, 2020
677ea26
runtime wasm builder: try newer version to ensure always building for…
mnaamani May 26, 2020
a6d7e11
travis: load cache, but dump it - just testing!
mnaamani May 27, 2020
c41b5ee
travis: skipping clippy
mnaamani May 27, 2020
1831865
travis: -Z minimal-versions flag for cargo build
mnaamani May 27, 2020
e48ba1f
travis: rust nightly lock to version 2020-05-22 build fails in newer …
mnaamani May 27, 2020
75d497b
travis: typo
mnaamani May 27, 2020
d68d86d
travis: correct nightly for all steps
mnaamani May 27, 2020
f382ca3
travis: rust nightly 2020-05-23
mnaamani May 27, 2020
fddbc22
travis: too many clippy errors with nightly!
mnaamani May 27, 2020
069c68f
travis: return cp task removed accidentally
mnaamani May 27, 2020
a288ad7
travis: try to skip wasm build when running tests
mnaamani May 27, 2020
3a7d252
travis: fix path to target folder
mnaamani May 27, 2020
a700e27
travis: re-enable caching now that build is working
mnaamani May 27, 2020
0ad8eb2
build scripts: restore to using stable for test and clippy
mnaamani May 27, 2020
245740e
git-hooks: keep cargo test and clippy in debug mode
mnaamani May 28, 2020
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
92 changes: 35 additions & 57 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,54 @@
language: rust

# Caching of the runtime .wasm blob poses a problem.
# See: https://github.com/Joystream/joystream/issues/466
# Always starting with a clean slate is probably better, it allows us to ensure
# the WASM runtime is always rebuilt. It also allows us to detect when certain upstream dependencies
# sometimes break the build. When cache is enabled do not use the produced WASM build.
# This also means the binary should not be used to produce the final chainspec file (because the same
# one is embedded in the binary)
cache: cargo

rust:
- 1.43.0
- stable

matrix:
include:
- os: linux
env: TARGET=x86_64-unknown-linux-gnu
- os: linux
env: TARGET=arm-unknown-linux-gnueabihf
services: docker
- os: osx
env: TARGET=x86_64-apple-darwin
- os: linux
env: TARGET=wasm-blob
services: docker
# Removed all other plaftorm builds sice the repo is growing in terms of activitly
# and CI checks are taking long to start due to concurrent number of jobs
# one job should be sufficient for doing all manners of checks and unit nets. Will defer
# building all platform binanires and wasm blob to a different system.

before_install:
install:
- rustup install nightly-2020-05-23
- rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-23
# travis installs rust using rustup with the "minimal" profile so these tools are not installed by default
- rustup component add rustfmt
- cargo fmt --all -- --check
# choosing to add clippy for the nightly toolchain only
# becuase we want to run it with nighly to avoid having to set BUILD_DUMMY_WASM_BINARY=0
# setting that variable requires changing it in a later run of cargo bulid to ensure runtime/build.rs
# actually builds the runtime .. the behaviour is a bit odd so choosing to avoid messing with it.
- rustup component add clippy
- BUILD_DUMMY_WASM_BINARY=1 cargo clippy -- -D warnings
- rustup default stable
- rustup update nightly
- rustup target add wasm32-unknown-unknown --toolchain nightly
- cargo test --verbose --all

install:
- |
if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]
then
docker pull joystream/rust-raspberry
fi
before_script:
- cargo fmt --all -- --check

script:
- |
if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]
then
docker run -u root \
--volume ${TRAVIS_BUILD_DIR}:/home/cross/project \
joystream/rust-raspberry \
build --release
sudo chmod a+r ${TRAVIS_BUILD_DIR}/target/${TARGET}/release/joystream-node
elif [ "$TARGET" = "wasm-blob" ]
then
docker build --tag joystream/node \
--file ./devops/dockerfiles/node-and-runtime/Dockerfile \
.
docker create --name temp-container-joystream-node joystream/node
docker cp temp-container-joystream-node:/joystream/runtime.compact.wasm joystream_runtime.wasm
docker rm temp-container-joystream-node
else
cargo build --release --target=${TARGET}
fi
# we set release as build type for all steps to benefit from already compiled packages in prior steps
# skipping clippy ...
- BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --target=${TARGET} -- -D warnings
- BUILD_DUMMY_WASM_BINARY=1 cargo test --release --verbose --all --target=${TARGET}
- BUILD_DUMMY_WASM_BINARY=0 WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release --target=${TARGET} -p joystream-node
- ls -l ./target/${TARGET}/release/wbuild/joystream-node-runtime/

before_deploy:
- |
if [ "$TARGET" = "wasm-blob" ]
then
export ASSET="joystream_runtime.wasm"
else
cp ./target/${TARGET}/release/joystream-node .
if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]
then
export FILENAME="joystream-node-armv7-linux-gnueabihf"
else
export FILENAME=`./joystream-node --version | sed -e "s/ /-/g"`
fi
tar -cf ${FILENAME}.tar ./joystream-node
gzip ${FILENAME}.tar
export ASSET=${FILENAME}.tar.gz
fi
- cp ./target/${TARGET}/release/joystream-node .
- FILENAME=`./joystream-node --version | sed -e "s/ /-/g"`
- tar -cf ${FILENAME}.tar ./joystream-node
- gzip ${FILENAME}.tar
- export ASSET=${FILENAME}.tar.gz

deploy:
- provider: releases
Expand Down
3 changes: 2 additions & 1 deletion devops/dockerfiles/node-and-runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ LABEL description="Compiles all workspace artifacts"
WORKDIR /joystream
COPY . /joystream

RUN cargo build --release
# Build joystream-node and its dependencies - runtime
RUN cargo build --release -p joystream-node

FROM debian:stretch
LABEL description="Joystream node"
Expand Down
10 changes: 5 additions & 5 deletions devops/git-hooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
set -e

export BUILD_DUMMY_WASM_BINARY=1
echo '+cargo test --release --all'
BUILD_DUMMY_WASM_BINARY=1 cargo test --all

echo '+cargo clippy --release --all -- -D warnings'
BUILD_DUMMY_WASM_BINARY=1 cargo clippy --all -- -D warnings

echo '+cargo test --all'
cargo test --all

echo '+cargo clippy --all -- -D warnings'
cargo clippy --all -- -D warnings
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"license": "GPL-3.0-only",
"scripts": {
"test": "yarn && yarn workspaces run test",
"test-migration": "yarn && yarn workspaces run test-migration"
"test-migration": "yarn && yarn workspaces run test-migration",
"cargo-checks": "devops/git-hooks/pre-commit && devops/git-hooks/pre-push",
"cargo-build": "scripts/cargo-build.sh"
},
"workspaces": [
"tests/network-tests"
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'

[build-dependencies.wasm-builder-runner]
package = 'substrate-wasm-builder-runner'
version = '1.0.4'
version = '1.0.5'

[dependencies.forum]
default_features = false
Expand Down
2 changes: 1 addition & 1 deletion runtime/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {
}

let file_name = "wasm_binary.rs";
let wasm_builder_source = WasmBuilderSource::Crates("1.0.8");
let wasm_builder_source = WasmBuilderSource::Crates("1.0.9");
// This instructs LLD to export __heap_base as a global variable, which is used by the
// external memory allocator.
let default_rust_flags = "-Clink-arg=--export=__heap_base";
Expand Down
27 changes: 3 additions & 24 deletions runtime/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::VERSION;
use rstd::prelude::*;
use sr_primitives::{print, traits::Zero};
// use sr_primitives::{print, traits::Zero};
use srml_support::{debug, decl_event, decl_module, decl_storage};

impl<T: Trait> Module<T> {
Expand All @@ -12,37 +12,16 @@ impl<T: Trait> Module<T> {
/// Important to note this method should be carefully maintained, because it runs on every runtime
/// upgrade.
fn runtime_upgraded() {
print("Running runtime upgraded handler");
debug::print!("Running runtime upgraded handler");

// Add initialization of modules introduced in new runtime release. Typically this
// would be any new storage values that need an initial value which would not
// have been initialized with config() or build() chainspec construction mechanism.
// Other tasks like resetting values, migrating values etc.

// Runtime Upgrade Code for going from Rome to Constantinople

// Create the Council mint. If it fails, we can't do anything about it here.
if let Err(err) = governance::council::Module::<T>::create_new_council_mint(
minting::BalanceOf::<T>::zero(),
) {
debug::warn!(
"Failed to create a mint for council during migration: {:?}",
err
);
}

// Initialise the proposal system various periods
proposals_codex::Module::<T>::set_default_config_values();
}
}

pub trait Trait:
system::Trait
+ governance::election::Trait
+ content_working_group::Trait
+ roles::actors::Trait
+ proposals_codex::Trait
{
pub trait Trait: system::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/cargo-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

cargo build --release
1 change: 0 additions & 1 deletion scripts/raspberry-cross-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

# joystream/rust-raspberry image was built from:
# https://github.com/mnaamani/rust-on-raspberry-docker/commit/8536508b743d55c8573043c4082c62da3b4fd3e2
docker pull joystream/rust-raspberry

docker run \
--volume ${PWD}/:/home/cross/project \
Expand Down
7 changes: 7 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ set -e
# - skips installing substrate and subkey
curl https://getsubstrate.io -sSf | bash -s -- --fast

source ~/.cargo/env

rustup component add rustfmt clippy

# TODO: Install additional tools...

# - b2sum
# - nodejs
# - npm
# - yarn
# .... ?