Skip to content

Commit

Permalink
[forge] Framework upgrade test all proposals
Browse files Browse the repository at this point in the history
Add and test any proposal release yaml in the data dir of release builder

Test Plan: Build / runs on PR with label
  • Loading branch information
perryjrandall committed Jul 17, 2024
1 parent 1d0603d commit 42d561d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
7 changes: 6 additions & 1 deletion crates/aptos-build-info/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
1 change: 1 addition & 0 deletions docker/builder/forge.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
37 changes: 33 additions & 4 deletions testsuite/testcases/src/framework_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<()> {
Expand Down Expand Up @@ -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() };
Expand Down

0 comments on commit 42d561d

Please sign in to comment.