Add nightly CI check against latest substrate. (#335)

* Add nightly check and use specific version (currently the same) in PR checks

* wrong var name, whoops

* Create GH issue if nightly run fails

* need tokio feature for RpcClient; match dependency in root Cargo.toml.

* Ensure substrate command is properly cleaned up in the event of a panic, to prevent blocking

* increase retry limit again

* fmt

* Tweak text for nightly-run-failed issue template

* Run nightly-CI every 5mins for testing

* I clearly dont use cron enough

* Put back cron timings to 8am daily

* break a test

* revert nightly workflow again (doesnt run off master) and testing rust workflow

* more testing..

* undo testing things; seems to work

* tidy up; substrate url at top of both CI files
This commit is contained in:
James Wilson
2021-11-30 15:01:25 +00:00
committed by GitHub
parent 4b9ee133ac
commit 4ca50ef844
5 changed files with 104 additions and 10 deletions
+1 -1
View File
@@ -10,5 +10,5 @@ codec = { package = "parity-scale-codec", version = "2", default-features = fals
[build-dependencies]
subxt = { path = ".." }
async-std = { version = "1.9.0", features = ["attributes"] }
sp-core = { package = "sp-core", git = "https://github.com/paritytech/substrate/", branch = "master" }
async-std = { version = "1.9.0", features = ["attributes", "tokio1"] }
+33 -4
View File
@@ -18,6 +18,10 @@ use std::{
env,
fs,
net::TcpListener,
ops::{
Deref,
DerefMut,
},
path::Path,
process::Command,
sync::atomic::{
@@ -32,6 +36,10 @@ static SUBSTRATE_BIN_ENV_VAR: &str = "SUBSTRATE_NODE_PATH";
#[async_std::main]
async fn main() {
run().await;
}
async fn run() {
// Select substrate binary to run based on env var.
let substrate_bin =
env::var(SUBSTRATE_BIN_ENV_VAR).unwrap_or_else(|_| "substrate".to_owned());
@@ -45,7 +53,7 @@ async fn main() {
.arg(format!("--rpc-port={}", port))
.spawn();
let mut cmd = match cmd {
Ok(cmd) => cmd,
Ok(cmd) => KillOnDrop(cmd),
Err(e) => {
panic!("Cannot spawn substrate command '{}': {}", substrate_bin, e)
}
@@ -55,7 +63,6 @@ async fn main() {
let metadata_bytes: sp_core::Bytes = {
const MAX_RETRIES: usize = 20;
let mut retries = 0;
let mut wait_secs = 1;
loop {
if retries >= MAX_RETRIES {
panic!("Cannot connect to substrate node after {} retries", retries);
@@ -72,9 +79,8 @@ async fn main() {
break res
}
_ => {
thread::sleep(time::Duration::from_secs(wait_secs));
thread::sleep(time::Duration::from_secs(1));
retries += 1;
wait_secs += 1;
}
};
}
@@ -142,3 +148,26 @@ fn next_open_port() -> Option<u16> {
}
}
}
/// If the substrate process isn't explicilty killed on drop,
/// it seems that panics that occur while the command is running
/// will leave it running and block the build step from ever finishing.
/// Wrapping it in this prevents this from happening.
struct KillOnDrop(std::process::Child);
impl Deref for KillOnDrop {
type Target = std::process::Child;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for KillOnDrop {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl Drop for KillOnDrop {
fn drop(&mut self) {
let _ = self.0.kill();
}
}