From 144305500cda4468551b6c282699267bec25ccbd Mon Sep 17 00:00:00 2001 From: Perry Randall Date: Tue, 16 Jul 2024 16:54:42 -0700 Subject: [PATCH] [forge] Framework upgrade test all proposals Add and test any proposal release yaml in the data dir of release builder Test Plan: Build / runs on PR with label --- .dockerignore | 2 +- crates/aptos-build-info/build.rs | 7 +++- docker/builder/forge.Dockerfile | 1 + testsuite/testcases/src/framework_upgrade.rs | 37 +++++++++++++++++--- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 34ec98bf8c62c..3a4bd7c40a38b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -20,7 +20,7 @@ !**/*.errmap !config/src/config/test_data !aptos-move/aptos-gas-profiling/templates/ -!aptos-move/aptos-release-builder/data/release.yaml +!aptos-move/aptos-release-builder/data/*.yaml !aptos-move/aptos-release-builder/data/proposals/* !aptos-move/framework/ !aptos-move/move-examples/hello_blockchain/ diff --git a/crates/aptos-build-info/build.rs b/crates/aptos-build-info/build.rs index b3339b0eec60f..222f8098919ea 100644 --- a/crates/aptos-build-info/build.rs +++ b/crates/aptos-build-info/build.rs @@ -9,6 +9,11 @@ fn main() -> shadow_rs::SdResult<()> { std::env::var("CARGO_CFG_TOKIO_UNSTABLE").is_ok() ); println!("cargo:rerun-if-changed=build.rs"); - println!("cargo:rerun-if-changed=../../.git/HEAD"); + // Check for this path first, otherwise it will force a rebuild every time + // https://github.com/rust-lang/cargo/issues/4213 + let git_head = std::path::Path::new("../../.git/HEAD"); + if git_head.exists() { + println!("cargo:rerun-if-changed=../../.git/HEAD"); + } shadow_rs::new() } diff --git a/docker/builder/forge.Dockerfile b/docker/builder/forge.Dockerfile index 202ced9e16bd2..3abb3df30b327 100644 --- a/docker/builder/forge.Dockerfile +++ b/docker/builder/forge.Dockerfile @@ -26,6 +26,7 @@ ENV PATH "$PATH:/root/bin" WORKDIR /aptos COPY --link --from=node-builder /aptos/dist/forge /usr/local/bin/forge + ### Get Aptos Framework Release for forge framework upgrade testing COPY --link --from=tools-builder /aptos/aptos-move/framework/ /aptos/aptos-move/framework/ COPY --link --from=tools-builder /aptos/aptos-move/aptos-release-builder/ /aptos/aptos-move/aptos-release-builder/ diff --git a/testsuite/testcases/src/framework_upgrade.rs b/testsuite/testcases/src/framework_upgrade.rs index 974ab91894eb4..37cad29b35511 100644 --- a/testsuite/testcases/src/framework_upgrade.rs +++ b/testsuite/testcases/src/framework_upgrade.rs @@ -9,12 +9,13 @@ use aptos_forge::{ }; use aptos_keygen::KeyGen; use aptos_logger::info; +use aptos_release_builder::ReleaseConfig; use aptos_sdk::crypto::{ed25519::Ed25519PrivateKey, PrivateKey}; use aptos_temppath::TempPath; use aptos_types::transaction::authenticator::AuthenticationKey; use async_trait::async_trait; -use std::ops::DerefMut; -use tokio::time::Duration; +use std::{ops::DerefMut, path::Path}; +use tokio::{fs, time::Duration}; pub struct FrameworkUpgrade; @@ -28,6 +29,16 @@ impl Test for FrameworkUpgrade { } } +const RELEASE_YAML_PATH: &str = "aptos-move/aptos-release-builder/data"; +const IGNORED_YAMLS: [&str; 2] = ["release.yaml", "example.yaml"]; + +fn is_release_yaml(path: &Path) -> bool { + let basename = path.file_name().unwrap().to_str().unwrap(); + path.is_file() + && path.extension().unwrap_or_default() == "yaml" + && !IGNORED_YAMLS.contains(&basename) +} + #[async_trait] impl NetworkTest for FrameworkUpgrade { async fn run<'a>(&self, ctx: NetworkContextSynchronizer<'a>) -> Result<()> { @@ -126,8 +137,26 @@ impl NetworkTest for FrameworkUpgrade { let release_config = aptos_release_builder::current_release_config(); - aptos_release_builder::validate::validate_config(release_config.clone(), network_info) - .await?; + aptos_release_builder::validate::validate_config( + release_config.clone(), + network_info.clone(), + ) + .await?; + + // Execute all the release yaml files + let mut entries = fs::read_dir(RELEASE_YAML_PATH).await?; + while let Some(entry) = entries.next_entry().await? { + let path = entry.path(); + if is_release_yaml(&path) { + let release_config = ReleaseConfig::parse(&fs::read_to_string(&path).await?)?; + info!("Executing release yaml: {}", path.to_string_lossy()); + aptos_release_builder::validate::validate_config( + release_config.clone(), + network_info.clone(), + ) + .await?; + } + } // Update the sequence number for the root account let root_account = { ctx.swarm.read().await.chain_info().root_account().address() };