-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjustfile
130 lines (106 loc) · 5.04 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# NOTE: This justfile relies heavily on nushell, make sure to install it: https://www.nushell.sh
set shell := ["nu", "-c"]
podman := `(which podman) ++ (which docker) | (first).path` # use podman otherwise docker
ver := `open chain-spec-generator/Cargo.toml | get package.version`
image := "ghcr.io/virto-network/virto"
chain := "kreivo"
runtime := "target/release/wbuild/kreivo-runtime/kreivo_runtime.compact.compressed.wasm"
rol := "collator"
relay := "kusama"
alias b := build-local
alias c := check
alias t := test
_task-selector:
#!/usr/bin/env nu
let selected_task = (
just --summary -u | split row ' ' | to text | fzf --header 'Available Virto recipes' --header-first --layout reverse --preview 'just --show {}' |
if ($in | is-empty) { 'about' } else { $in }
)
just $selected_task
@about:
open chain-spec-generator/Cargo.toml | get package | table -c
@version:
echo {{ ver }}
@list-crates:
open Cargo.toml | get workspace.members | each { open ($in + /Cargo.toml) | get package.name } | str join "\n"
@_check_deps:
rustup component add clippy
check: _check_deps
cargo clippy --all-targets -- --deny warnings
cargo +nightly fmt --all -- --check
@test crate="" *rest="":
cargo test (if not ("{{crate}}" | is-empty) { "-p" } else {""}) {{crate}} {{ rest }}
build-local features="":
cargo build --release --features '{{features}}'
benchmarks:
# TODO: build benchmarks for every pallet that's currently within the runtime as
# a dependency
mkdir .benchmarking-logs
frame-omni-bencher v1 benchmark pallet --list=pallets --runtime {{runtime}} \
| from csv \
| each {|record| just benchmark $record.pallet}
benchmark pallet="" extrinsic="*":
frame-omni-bencher v1 benchmark pallet \
--runtime {{runtime}} \
--pallet '{{pallet}}' --extrinsic '{{extrinsic}}' \
--steps 50 \
--repeat 20 \
--output ./runtime/kreivo/src/weights/ | \
save --force .benchmarking-logs/{{pallet}}.out.txt \
--stderr .benchmarking-logs/{{pallet}}.log.txt
if ((open .benchmarking-logs/{{pallet}}.out.txt | str length) == 0) { rm .benchmarking-logs/{{pallet}}.out.txt }
release-artifacts:
@mkdir release; rm -f release/*
cp {{ runtime }} release/
cp *.container release
release-tag:
git tag {{ ver }}
bump mode="minor":
#!/usr/bin/env nu
let ver = '{{ ver }}' | inc --{{ mode }}
open -r runtime/kreivo/Cargo.toml | str replace -m '^version = "(.+)"$' $'version = "($ver)"' | save -f runtime/kreivo/Cargo.toml
open -r chain-spec-generator/Cargo.toml | str replace -m '^version = "(.+)"$' $'version = "($ver)"' | save -f chain-spec-generator/Cargo.toml
# bump spec version
const SRC = 'runtime/kreivo/src/lib.rs'
let src = open $SRC
let spec_ver = ($src | grep spec_version | parse -r '\s*spec_version: (?<ver>\w+),' | first | get ver | into int)
$src | str replace -m '(\s*spec_version:) (\w+)' $'$1 ($spec_ver | $in + 1)' | save -f $SRC
# assume minor and major versions channge tx version
let bump_tx = '{{ mode }}' == 'minor' or '{{ mode }}' == 'major'
if $bump_tx {
let src = open $SRC
let tx_ver = ($src | grep transaction_version | parse -r '\s*transaction_version: (?<ver>\w+),' | first | get ver | into int)
$src | str replace -m '(\s*transaction_version:) (\w+)' $'$1 ($tx_ver | $in + 1)' | save -f $SRC
}
_zufix := os() + if os() == "linux" { "-x64" } else { "" }
zombienet network="": build-local
#!/usr/bin/env nu
# Run zombienet with a profile from the `zombienet/` folder chosen interactively
mut net = "{{ network }}"
if "{{ network }}" == "" {
let net_list = (ls zombienet | get name | path basename | str replace .toml '')
$net = ($net_list | to text | fzf --preview 'open {}.toml' | if ($in | is-empty) { $net_list | first } else { $in })
}
bin/zombienet-{{ _zufix }} -p native spawn $"zombienet/($net).toml"
get-zombienet-dependencies: (_get-latest "zombienet" "zombienet-"+_zufix) (_get-latest "cumulus" "polkadot-parachain") compile-polkadot-for-zombienet
compile-polkadot-for-zombienet:
#!/usr/bin/env nu
mkdir bin
# Compile polkadot with fast-runtime feature
let polkadot = (open Cargo.toml | get workspace.dependencies.sp-core)
let dir = (mktemp -d polkadot-sdk.XXX)
git clone --branch $polkadot.branch --depth 1 $polkadot.git $dir
echo $"(ansi defb)Compiling Polkadot(ansi reset) \(($polkadot.git):($polkadot.branch)\)"
cargo build --manifest-path ($dir | path join Cargo.toml) --locked --profile testnet --features fast-runtime --bin polkadot --bin polkadot-prepare-worker --bin polkadot-execute-worker
mv -f ($dir | path join target/testnet/polkadot) bin/
mv -f ($dir | path join target/testnet/polkadot-prepare-worker) bin/
mv -f ($dir | path join target/testnet/polkadot-execute-worker) bin/
_get-latest repo bin:
#!/usr/bin/env nu
mkdir bin
http get https://api.github.com/repos/paritytech/{{ repo }}/releases
# cumulus has two kinds of releases, we exclude runtimes
| where "tag_name" !~ "parachains" | first | get assets_url | http get $in
| where name =~ {{ bin }} | first | get browser_download_url
| http get $in --raw | save bin/{{ bin }} --progress --force
chmod u+x bin/{{ bin }}