makers startmkdir -p resources
./target/production/anagolay --base-path ./target/data --chain local --no-telemetry --rpc-methods Unsafe --rpc-cors all --unsafe-rpc-external
./target/production/anagolay build-spec --base-path ./target/data --disable-default-bootnode --chain local > ./resources/idiyanale/spec.json
./target/production/anagolay build-spec --chain=./resources/idiyanale/spec.json --raw --disable-default-bootnode > ./resources/idiyanale/genesis.jsonThe gitlab job test is configured to run with the .rules-run-if-source-code-is-changed rule which triggers it in one of two cases:
- if the commit message starts with
[sc build] - any changes in rust files are made in the
node,pallets,runtimedirectories
when you first time create the workspace you will need to do this:
# to get the envs
direnv allow
# stop the server which started without the env variables and it's using the local cache
sccache --stop-server
# to start the server and verify that it is using the aws as a storge
sccache --start-server; sccache --show-statsLinks https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#use-extends-to-reuse-configuration-sections, https://docs.gitlab.com/ee/ci/yaml/#extends , https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#use-extends-and-include-together With extend pay attention on the rules of merging.
SCCACHE_START_SERVER=1 SCCACHE_NO_DAEMON=1 RUST_LOG=sccache=trace SCCACHE_LOG=debug sccache
sccache --stop-server && SCCACHE_START_SERVER=1 SCCACHE_NO_DAEMON=1 RUST_LOG=sccache=trace SCCACHE_LOG=debug sccache
If you happen to see the profraw files they are used to instrument your code. Here is what you can do:
- check the RUSTFLAGS with
echo $RUSTFLAGS, this should not contain the-C instrument-coverage - completely unset the RUSTFLAGS with
unset RUSTFLAGS - remove all the
profrawfiles using thisfind . \( -name "*.profraw" \) -delete
To create the Anagolay node you need to have latest version of the base image anagolay/rust-ci which you can get it from DockerHub
Scanning for the vulnerabilities using builtin Docker scan:
docker scan --file Dockerfile --exclude-base anagolay/node:0.2.1-devAudit the code using the Cargo Audit:
# check the security
cargo auditgrcov produces the correct output in either HTML or GitLab compatible format.
Total process takes around 40 min on Gitpod - roughly 20 for instrumentation, 10 for tests, 10 for report generation:
Instrumentation
rustup component add llvm-tools-preview
cargo install grcov
export LLVM_PROFILE_FILE="anagolay-%p-%m.profraw"
export RUSTFLAGS="-Cinstrument-coverage"
export SKIP_WASM_BUILD=true
makers clean
makers build
makers testHTML report generation
This will generate a static website in a folder (./coverage), including badges:
grcov . -s . -t html --binary-path ./target/debug --llvm --branch --ignore-not-existing --ignore "/*" -o ./coverageCobertura report generation
This will generate an XML file (./coverage.xml) suitable by GitLab pipelines:
grcov . -s . -t cobertura --binary-path ./target/debug --llvm --branch --ignore-not-existing --ignore "/*" -o ./coverage.xmlCleanup
find . \( -name "anagolay*.profraw" \) -deleteTo test the full suite run makers test
To test documentation examples, run makers test --doc -- --show-output
To generate pallet weights run from the root of the project. Use the folder name for the pallet. This script will compile the node for you and run the benchmarks.
# TEMPLATE ./.devops/run-benchmarks.sh CHAIN PALLET $RUN_WITH_BUILD[true << default |false]
# PoE
./.devops/run-benchmarks.sh dev poe false # this will not build it it will only run it
# Workflows
./.devops/run-benchmarks.sh dev workflows # this will build it and run it
# Operations
./.devops/run-benchmarks.sh dev operations
# All pallets and all extrinsics with the release build
./.devops/run-all-benchmarks.sh dev
# All pallets and all extrinsics without the release build
./.devops/run-all-benchmarks.sh dev false
zombienet allows to quickly setup a test environment with a relay chain and two collators, running
the debug (or the release) build.
The network is started by start cargo target and requires to have the binaries of polkadot and zombienet in the path.
It will spawn native (non containerized) nodes and will be configured by the file zombienet/config.toml.
In order to have the required binaries you can run the following shell script on your local setup:
echo '#!/bin/sh
docker run -v /tmp:/tmp -u $(id -u):$(id -g) paritypr/polkadot-debug:master $@' > polkadot && sudo mv polkadot /usr/local/bin/polkadot
sudo chmod +x /usr/local/bin/polkadot
sudo sh -c "wget -c https://github.com/paritytech/zombienet/releases/download/v1.3.33/zombienet-linux-x64 -O /usr/local/bin/zombienet"
sudo chmod +x /usr/local/bin/zombienetCargo has integration with rustdoc to make it easier to generate docs. To generate pallets/crates documentation run from the root of the project. It'll generate all pallet's documentation.
makers docs-flow --no-depsdocs/api folder will contain the autogenerated docs in the root of the project.
VERY important website to check when upgrading the toolchain https://rust-lang.github.io/rustup-components-history/