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

[DOPS-2942]: Update parachain build #205

Merged
merged 14 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@Library('jenkins-library') _

def pipeline = new org.rust.AppPipeline(steps: this,
envImageName: 'docker.soramitsu.co.jp/sora2/parachain-env:latest',
envImageName: 'docker.soramitsu.co.jp/sora2/env:env',
appImageName: 'docker.soramitsu.co.jp/sora2/parachain',
clippyLinter: false,
cargoClippyTag: ':parachain',
buildTestCmds: ['housekeeping/scripts/build.sh'],
buildTestCmds: 'housekeeping/scripts/build.sh',
cargoClippyCmds: ['housekeeping/scripts/clippy.sh'],
codeCoverage: false,
codeCoverageCommand: './housekeeping/scripts/coverage.sh',
pushTags: ['develop': 'dev'],
buildArtifacts: 'sora2-parachain-runtime_rococo.compact.compressed.wasm, sora2-parachain-runtime_kusama.compact.compressed.wasm, sora2-parachain-runtime_polkadot.compact.compressed.wasm',
sonarProjectKey: 'sora:sora2-parachain',
Expand Down
12 changes: 0 additions & 12 deletions Jenkinsfile-env

This file was deleted.

59 changes: 0 additions & 59 deletions Jenkinsfile-relay

This file was deleted.

30 changes: 0 additions & 30 deletions housekeeping/docker/develop/Dockerfile

This file was deleted.

50 changes: 0 additions & 50 deletions housekeeping/docker/relay/Dockerfile

This file was deleted.

94 changes: 63 additions & 31 deletions housekeeping/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,36 @@ binaryfile="target/release/parachain-collator"
binaryfilepath="housekeeping/parachain-collator"
errorfile="benchmarking_errors.txt"

rm -rf ~/.cargo/registry/

if [[ $buildTag != null ]] && [[ ${TAG_NAME} != null || ${TAG_NAME} != '' ]]; then
if [[ ${TAG_NAME} =~ 'benchmarking'* ]]; then
buildcmd="cargo build --release --locked --bin parachain-collator --features"
buildfeature="runtime-benchmarks,kusama"
elif [[ $buildTag = 'dev' || $buildTag = 'latest' ]] || [[ ${TAG_NAME} = 'stage-'* ]] || [[ ${TAG_NAME} = 'test-'* ]]; then
buildfeature="rococo"
elif [[ ${TAG_NAME} = 'kusama-'* ]]; then
buildfeature="kusama"
elif [[ ${TAG_NAME} = 'polkadot-'* ]]; then
buildfeature="polkadot"
fi
printf "🕙 Testing with feature $buildfeature will start now... \n"
$testcmd "$buildfeature"
printf "🕙 Building with feature $buildfeature will start now... \n"
$buidcmd "$buildfeature"
wasm_in="./target/release/wbuild/sora2-parachain-runtime/"
wasm_out=./sora2-parachain-runtime_$buildfeature.compact.compressed.wasm
wasm_file=$(ls "$wasm_in" | grep ".compact.compressed.wasm")
mv "$wasm_in$wasm_file" "$wasm_out"
if [ -f "$wasm_out" ]; then
test() {
if [[ $buildTag != null ]] && [[ ${TAG_NAME} != null || ${TAG_NAME} != '' ]]; then
if [[ ${TAG_NAME} =~ 'benchmarking'* ]]; then
buildfeature="runtime-benchmarks,kusama"
elif [[ -n $buildTag ]] || [[ ${TAG_NAME} = 'stage-'* ]] || [[ ${TAG_NAME} = 'test-'* ]]; then
buildfeature="rococo"
elif [[ ${TAG_NAME} = 'kusama-'* ]]; then
buildfeature="kusama"
elif [[ ${TAG_NAME} = 'polkadot-'* ]]; then
buildfeature="polkadot"
fi
printf " Testing for feature $buildfeature will start now... \n"
$testcmd "$buildfeature"
wasm_in="./target/release/wbuild/sora2-parachain-runtime/"
wasm_out=./sora2-parachain-runtime_$buildfeature.compact.compressed.wasm
wasm_file=$(ls "$wasm_in" | grep ".compact.compressed.wasm")
mv "$wasm_in$wasm_file" "$wasm_out"
if [ -f "$wasm_out" ]; then
printf "✅ "$wasm_out" found!\n"
else
else
printf "❌"$wasm_out" can't found!\n"
exit 1
fi
else
for network in ${networks[@]}
do
printf "⚡️ There is no tag here, only tests run. \n"
printf "🏃 Running tests for "$network"... \n"
fi
else
# No buildtags. Only coverage
export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="sora2-%p-%m.profraw"
for network in ${networks[@]}
do
printf "🕙 No buildtags. Running coverage tests for $network feature... \n"
$testcmd "$network" "$benchfeature"
wasm_in="./target/release/wbuild/sora2-parachain-runtime/"
wasm_out=./sora2-parachain-runtime_$network.compact.compressed.wasm
Expand All @@ -53,8 +51,36 @@ else
printf "❌"$wasm_out" can't found!\n"
exit 1
fi
done
fi
done
fi
}

build() {
if [[ $buildTag != null ]] && [[ ${TAG_NAME} != null || ${TAG_NAME} != '' ]]; then
if [[ ${TAG_NAME} =~ 'benchmarking'* ]]; then
buildcmd="cargo build --release --locked --bin parachain-collator --features"
buildfeature="runtime-benchmarks,kusama"
elif [[ -n $buildTag ]] || [[ ${TAG_NAME} = 'stage-'* ]] || [[ ${TAG_NAME} = 'test-'* ]]; then
buildfeature="rococo"
elif [[ ${TAG_NAME} = 'kusama-'* ]]; then
buildfeature="kusama"
elif [[ ${TAG_NAME} = 'polkadot-'* ]]; then
buildfeature="polkadot"
fi
printf "🕙 Building with feature $feature will start now... \n"
$buidcmd "$feature"
wasm_in="./target/release/wbuild/sora2-parachain-runtime/"
wasm_out=./sora2-parachain-runtime_$feature.compact.compressed.wasm
wasm_file=$(ls "$wasm_in" | grep ".compact.compressed.wasm")
mv "$wasm_in$wasm_file" "$wasm_out"
if [ -f "$wasm_out" ]; then
printf "✅ $wasm_out found!\n"
else
printf "❌ $wasm_out can't found!\n"
exit 1
fi
fi
}

if [ -f "$binaryfile" ]; then
cp "$binaryfile" "$binaryfilepath"
Expand All @@ -64,3 +90,9 @@ if [ -f "$errorfile" ]; then
printf "⚠️ build failed, please check the error below\n"
cat "$errorfile"
fi

if [ "$(type -t $1)" = "function" ]; then
"$1"
else
echo "Func '$1' is not exists in this workflow. Skipped."
fi
7 changes: 1 addition & 6 deletions housekeeping/scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/sh

export RUSTFLAGS="-Cinstrument-coverage"
export SKIP_WASM_BUILD=1
export LLVM_PROFILE_FILE="sora2-%p-%m.profraw"
grcov . --binary-path ./target/release -s . -t lcov --branch -o ./lcov_report --ignore-not-existing --ignore "/opt/cargo/**" "target/release" "node/src" --log-level="ERROR" --llvm-path='/usr/lib/llvm-14/bin'

rustup component add llvm-tools-preview

grcov . --binary-path ./target/debug -s . -t lcov --branch -o ./lcov_report --ignore-not-existing --ignore "/opt/cargo/**" "target/debug" "node/src"
find . -type f -name '*.profraw' -delete