mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 19:21:03 +00:00
Initial rebrand from paritytech/subxt to pezkuwichain/pezkuwi-subxt
- Renamed all subxt crates to pezkuwi-subxt - Updated internal references - Configured for Pezkuwi ecosystem
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/target
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "artifacts"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
documentation.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Internal tool to regenerate artifacts"
|
||||
|
||||
[dependencies]
|
||||
substrate-runner = { workspace = true }
|
||||
@@ -0,0 +1,82 @@
|
||||
use std::{
|
||||
fs::File,
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
use substrate_runner::SubstrateNode;
|
||||
|
||||
/// A Script to generate artifacts that are used in the integration tests.
|
||||
///
|
||||
/// Run with `cargo run --bin artifacts` from the root of the repository.
|
||||
fn main() {
|
||||
let mut node_builder = SubstrateNode::builder();
|
||||
node_builder.polkadot();
|
||||
|
||||
// Spawn the node and retrieve a ws URL to it:
|
||||
let proc = node_builder
|
||||
.spawn()
|
||||
.map_err(|e| e.to_string())
|
||||
.expect("Could not spawn node");
|
||||
let node_url = format!("ws://127.0.0.1:{}", proc.ws_port());
|
||||
|
||||
// Get the full metadata from the spawned substrate node
|
||||
run_cmd(
|
||||
&format!("cargo run --bin subxt metadata --version 15 --url {node_url}"),
|
||||
Some("artifacts/polkadot_metadata_full.scale"),
|
||||
);
|
||||
|
||||
// Use it to generate polkadot.rs
|
||||
run_cmd(
|
||||
"cargo run --bin subxt codegen --file artifacts/polkadot_metadata_full.scale",
|
||||
Some("testing/integration-tests/src/full_client/codegen/polkadot.rs"),
|
||||
);
|
||||
run_cmd(
|
||||
"rustfmt testing/integration-tests/src/full_client/codegen/polkadot.rs",
|
||||
None,
|
||||
);
|
||||
|
||||
// Generate a metadata file that only contains a few pallets that we need for our examples.
|
||||
run_cmd(
|
||||
"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets Balances,Staking,System,Multisig,Timestamp,ParaInherent",
|
||||
Some("artifacts/polkadot_metadata_small.scale"),
|
||||
);
|
||||
|
||||
// Generate a metadata file that contains no pallets
|
||||
run_cmd(
|
||||
"cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets \"\"",
|
||||
Some("artifacts/polkadot_metadata_tiny.scale"),
|
||||
);
|
||||
|
||||
// Generate a metadata file that only contains some custom metadata
|
||||
run_cmd(
|
||||
"cargo run --bin generate-custom-metadata",
|
||||
Some("artifacts/metadata_with_custom_values.scale"),
|
||||
);
|
||||
|
||||
// Generate the polkadot chain spec.
|
||||
run_cmd(
|
||||
"cargo run --features chain-spec-pruning --bin subxt chain-spec --url wss://rpc.polkadot.io:443 --output-file artifacts/demo_chain_specs/polkadot.json --state-root-hash --remove-substitutes",
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
fn run_cmd(cmd: &str, out_path: Option<&str>) {
|
||||
println!("Running Command: {cmd}");
|
||||
// Note: simple space splitting, no fancy parsing of e.g. quotes surrounding whitespace.
|
||||
let mut parts = cmd.split(' ');
|
||||
let program = parts.next().expect("no program in command string");
|
||||
let mut command = Command::new(program);
|
||||
for e in parts {
|
||||
command.arg(e);
|
||||
}
|
||||
|
||||
if let Some(out_path) = out_path {
|
||||
let file = File::create(out_path).unwrap();
|
||||
command.stdout(Stdio::from(file));
|
||||
}
|
||||
|
||||
let status = command.spawn().unwrap().wait().unwrap();
|
||||
if !status.success() {
|
||||
panic!("Command `{cmd}` failed with status: {status}")
|
||||
}
|
||||
}
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This script obtains the changelog to be introduced in the new release.
|
||||
|
||||
set -eu
|
||||
|
||||
REMOTE_LINK="https://github.com/paritytech/subxt/pull/"
|
||||
|
||||
function usage() {
|
||||
cat <<HELP_USAGE
|
||||
This script obtains the changelog between the latest release tag and origin/master.
|
||||
|
||||
Usage: $0 [-h]
|
||||
|
||||
-h Print help message.
|
||||
HELP_USAGE
|
||||
}
|
||||
|
||||
function log_error() {
|
||||
echo "Error:" "$@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function log_info() {
|
||||
echo -e "[+]" "$@"
|
||||
}
|
||||
|
||||
while getopts "h?" opt; do
|
||||
case "$opt" in
|
||||
h|\?)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
GIT_BIN=$(which git) || log_error 'git is not installed. Please follow https://github.com/git-guides/install-git for instructions'
|
||||
|
||||
# Generate the changelog between the provided tag and origin/master.
|
||||
function generate_changelog() {
|
||||
local tag="$1"
|
||||
|
||||
prs=$($GIT_BIN --no-pager log --pretty=format:"%s" "$tag"..origin/master) || log_error 'Failed to obtain commit list'
|
||||
|
||||
log_info "Changelog\n"
|
||||
while IFS= read -r line; do
|
||||
# Obtain the pr number from each line. The regex should match, as provided by the previous grep.
|
||||
if [[ $line =~ "(#"([0-9]+)")"$ ]]; then
|
||||
pr_number="${BASH_REMATCH[1]}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
# Generate a valid PR link.
|
||||
pr_link="$REMOTE_LINK$pr_number"
|
||||
# Generate the link as markdown.
|
||||
pr_md_link=" ([#$pr_number]($pr_link))"
|
||||
# Print every word from the commit title, except the last word.
|
||||
# The last word is the PR id that is already included by the pr-link.
|
||||
# The changelog line is `- commit-title pr-link`.
|
||||
echo "$line" | awk -v link="$pr_md_link" '{ printf "- "; for(i=1;i<=NF-1;i++) { printf $i" "} print link}'
|
||||
done <<< "$prs"
|
||||
}
|
||||
|
||||
# Get latest release tag.
|
||||
tag=$($GIT_BIN describe --tag --match "v[0-9]*" --abbrev=0 origin/master) || log_error 'Failed to obtain the latest release tag'
|
||||
log_info "Latest release tag: $tag"
|
||||
|
||||
generate_changelog "$tag"
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This script is copied from `https://github.com/paritytech/jsonrpsee` with some minor tweaks.
|
||||
# Add `--dry-run` and/or `--allow-dirty` to your command line to test things before publication.
|
||||
|
||||
set -eu
|
||||
|
||||
# Find publishable crates by running something like this below and figure out the topological order:
|
||||
# $ find . -iname 'Cargo.toml' | xargs grep "publish\ *=\ *true" | grep "^.*\.toml" -o
|
||||
ORDER=(metadata codegen macro subxt cli)
|
||||
|
||||
function read_toml () {
|
||||
NAME=""
|
||||
VERSION=""
|
||||
# Extract and parse the "name = ..." line that belongs to the [package] section
|
||||
NAME=$(grep -e "\[package\]" -e 'name*=*' ./Cargo.toml | grep -A1 "\[package\]" | tail -n 1 | sed -e 's/.*"\(.*\)"/\1/')
|
||||
VERSION=$(grep "^version" ./Cargo.toml | sed -e 's/.*"\(.*\)"/\1/')
|
||||
}
|
||||
function remote_version () {
|
||||
REMOTE_VERSION=""
|
||||
REMOTE_VERSION=$(cargo search "$NAME" | grep "^$NAME =" | sed -e 's/.*"\(.*\)".*/\1/')
|
||||
}
|
||||
|
||||
# First display the plan
|
||||
for CRATE_DIR in ${ORDER[@]}; do
|
||||
cd $CRATE_DIR > /dev/null
|
||||
read_toml
|
||||
echo "$NAME@$VERSION"
|
||||
cd - > /dev/null
|
||||
done
|
||||
|
||||
read -p ">>>> Really publish?. Press [enter] to continue. "
|
||||
|
||||
set -x
|
||||
|
||||
cargo clean
|
||||
|
||||
set +x
|
||||
|
||||
# Then actually perform publishing.
|
||||
for CRATE_DIR in ${ORDER[@]}; do
|
||||
cd $CRATE_DIR > /dev/null
|
||||
read_toml
|
||||
remote_version
|
||||
# Seems the latest version matches, skip by default.
|
||||
if [ "$REMOTE_VERSION" = "$VERSION" ] || [[ "$REMOTE_VERSION" > "$VERSION" ]]; then
|
||||
RET=""
|
||||
echo "Seems like $NAME@$REMOTE_VERSION is already published. Continuing in 5s. "
|
||||
read -t 5 -p ">>>> Type [r][enter] to retry, or [enter] to continue... " RET || true
|
||||
if [ "$RET" != "r" ]; then
|
||||
echo "Skipping $NAME@$VERSION"
|
||||
cd - > /dev/null
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# Attempt to publish (allow retries)
|
||||
while : ; do
|
||||
# give the user an opportunity to abort or skip before publishing
|
||||
echo "🚀 Publishing $NAME@$VERSION..."
|
||||
sleep 3
|
||||
|
||||
set +e && set -x
|
||||
cargo publish $@
|
||||
RES=$?
|
||||
set +x && set -e
|
||||
# Check if it succeeded
|
||||
if [ "$RES" != "0" ]; then
|
||||
CHOICE=""
|
||||
echo "##### Publishing $NAME failed"
|
||||
read -p ">>>>> Type [s][enter] to skip, or [enter] to retry.. " CHOICE
|
||||
if [ "$CHOICE" = "s" ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Wait again to make sure that the new version is published and available.
|
||||
echo "Waiting for $NAME@$VERSION to become available at the registry..."
|
||||
while : ; do
|
||||
sleep 3
|
||||
remote_version
|
||||
if [ "$REMOTE_VERSION" = "$VERSION" ]; then
|
||||
echo "🥳 $NAME@$VERSION published successfully."
|
||||
sleep 3
|
||||
break
|
||||
else
|
||||
echo "#### Got $NAME@$REMOTE_VERSION but expected $NAME@$VERSION. Retrying..."
|
||||
fi
|
||||
done
|
||||
cd - > /dev/null
|
||||
done
|
||||
|
||||
echo "Tagging subxt@$VERSION"
|
||||
set -x
|
||||
git tag -s -a v$VERSION -m "Version $VERSION"
|
||||
sleep 3
|
||||
git push --tags
|
||||
Reference in New Issue
Block a user