Skip to content

Commit

Permalink
feat: remove more inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
loispostula committed Jul 22, 2024
1 parent c5961cb commit 65d6b31
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 102 deletions.
193 changes: 99 additions & 94 deletions src/commands/check_workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ impl Result {
self.publish_detail.ci_runner =
Some(format!("rust-{}-scale-set", toolchain.replace('.', "-")));
}

pub fn update_toolchain(&mut self, toolchain: &str) {
self.toolchain = toolchain.to_string();
}

pub async fn update_runtime_information(
&mut self,
release_channel: Option<&str>,
Expand All @@ -344,6 +349,7 @@ impl Result {
) -> anyhow::Result<()> {
self.update_release_channel(release_channel);
self.update_ci_runner(toolchain);
self.update_toolchain(toolchain);

if self.publish_detail.binary.publish {
let rc_version = match self.publish_detail.release_channel {
Expand Down Expand Up @@ -753,98 +759,6 @@ pub async fn check_workspace(

let package_keys: Vec<String> = packages.keys().cloned().collect();

if options.progress {
println!(
"{} {}Resolving packages dependencies...",
style("[3/9]").bold().dim(),
TRUCK
);
}
let mut pb: Option<ProgressBar> = None;
if options.progress {
pb = Some(ProgressBar::new(packages.len() as u64).with_style(
ProgressStyle::with_template("{spinner} {wide_msg} {pos}/{len}")?,
));
}
let publish_status: HashMap<String, bool> = packages
.clone()
.into_iter()
.map(|(k, v)| (k, v.publish))
.collect();
for package_key in package_keys.clone() {
if let Some(ref pb) = pb {
pb.inc(1);
}
// Loop through all the dependencies, if we don't know of it, skip it
if let Some(package) = packages.get_mut(&package_key) {
if let Some(ref pb) = pb {
pb.set_message(format!("{} : {}", package.workspace, package.package));
}
package.dependencies.retain(|d| {
d.package
.as_ref()
.map_or(false, |p| package_keys.contains(p))
});
for dep in &mut package.dependencies {
if let Some(package_name) = &dep.package {
if let Some(dep_p) = publish_status.get(package_name) {
dep.publishable = *dep_p;
}
}
}
}
}

// 4 Feed Dependent
if options.progress {
println!(
"{} {}Feeding packages dependant...",
style("[4/9]").bold().dim(),
TRUCK
);
}

if options.progress {
pb = Some(ProgressBar::new(packages.len() as u64).with_style(
ProgressStyle::with_template("{spinner} {wide_msg} {pos}/{len}")?,
));
}
let package_keys: Vec<String> = packages.keys().cloned().collect();
for package_key in package_keys.clone() {
if let Some(ref pb) = pb {
pb.inc(1);
}
// Loop through all the dependencies, if we don't know of it, skip it
if let Some(package) = packages.get(&package_key).cloned() {
if let Some(ref pb) = pb {
pb.set_message(format!("{} : {}", package.workspace, package.package));
}
// for each dependency we need to edit it and add ourself as a dependeant
for dependency in package.dependencies.clone() {
if let Some(package_name) = dependency.package {
if let Some(dependant) = packages.get_mut(&package_name) {
dependant.dependant.push(ResultDependency {
package: Some(package.package.clone()),
version: package.version.clone(),
path: Some(package.path.clone()),
publishable: package.publish,
publishable_details: HashMap::from([
("docker".to_string(), package.publish_detail.docker.publish),
("cargo".to_string(), package.publish_detail.cargo.publish),
(
"npm_napi".to_string(),
package.publish_detail.npm_napi.publish,
),
("binary".to_string(), package.publish_detail.binary.publish),
]),
guid_suffix: None,
});
}
}
}
}
}

// 5. Compute Runtime information
if options.progress {
println!(
Expand All @@ -854,6 +768,7 @@ pub async fn check_workspace(
);
}

let mut pb: Option<ProgressBar> = None;
if options.progress {
pb = Some(ProgressBar::new(packages.len() as u64).with_style(
ProgressStyle::with_template("{spinner} {wide_msg} {pos}/{len}")?,
Expand Down Expand Up @@ -984,10 +899,100 @@ pub async fn check_workspace(
}
}

if options.progress {
println!(
"{} {}Resolving packages dependencies...",
style("[3/9]").bold().dim(),
TRUCK
);
}
let mut pb: Option<ProgressBar> = None;
if options.progress {
pb = Some(ProgressBar::new(packages.len() as u64).with_style(
ProgressStyle::with_template("{spinner} {wide_msg} {pos}/{len}")?,
));
}
let publish_status: HashMap<String, bool> = packages
.clone()
.into_iter()
.map(|(k, v)| (k, v.publish))
.collect();
for package_key in package_keys.clone() {
if let Some(ref pb) = pb {
pb.inc(1);
}
// Loop through all the dependencies, if we don't know of it, skip it
if let Some(package) = packages.get_mut(&package_key) {
if let Some(ref pb) = pb {
pb.set_message(format!("{} : {}", package.workspace, package.package));
}
package.dependencies.retain(|d| {
d.package
.as_ref()
.map_or(false, |p| package_keys.contains(p))
});
for dep in &mut package.dependencies {
if let Some(package_name) = &dep.package {
if let Some(dep_p) = publish_status.get(package_name) {
dep.publishable = *dep_p;
}
}
}
}
}
// 4 Feed Dependent
if options.progress {
println!(
"{} {}Feeding packages dependant...",
style("[7/9]").bold().dim(),
TRUCK
);
}
if options.progress {
pb = Some(ProgressBar::new(packages.len() as u64).with_style(
ProgressStyle::with_template("{spinner} {wide_msg} {pos}/{len}")?,
));
}
let package_keys: Vec<String> = packages.keys().cloned().collect();
for package_key in package_keys.clone() {
if let Some(ref pb) = pb {
pb.inc(1);
}
// Loop through all the dependencies, if we don't know of it, skip it
if let Some(package) = packages.get(&package_key).cloned() {
if let Some(ref pb) = pb {
pb.set_message(format!("{} : {}", package.workspace, package.package));
}
// for each dependency we need to edit it and add ourself as a dependeant
for dependency in package.dependencies.clone() {
if let Some(package_name) = dependency.package {
if let Some(dependant) = packages.get_mut(&package_name) {
dependant.dependant.push(ResultDependency {
package: Some(package.package.clone()),
version: package.version.clone(),
path: Some(package.path.clone()),
publishable: package.publish,
publishable_details: HashMap::from([
("docker".to_string(), package.publish_detail.docker.publish),
("cargo".to_string(), package.publish_detail.cargo.publish),
(
"npm_napi".to_string(),
package.publish_detail.npm_napi.publish,
),
("binary".to_string(), package.publish_detail.binary.publish),
]),
guid_suffix: None,
});
}
}
}
}
}

if options.progress {
println!(
"{} {}Checking if packages changed...",
style("[6/7]").bold().dim(),
style("[8/9]").bold().dim(),
TRUCK
);
}
Expand Down Expand Up @@ -1081,7 +1086,7 @@ pub async fn check_workspace(
if options.progress {
println!(
"{} {}Marking packages dependency as changed...",
style("[7/7]").bold().dim(),
style("[9/9]").bold().dim(),
TRUCK
);
}
Expand Down
29 changes: 21 additions & 8 deletions src/commands/generate_workflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ else
CHECK_CHANGED=('--check-changed' '--changed-base-ref' "origin/${BASE_REF}" '--changed-head-ref' "${HEAD_REF}")
git fetch origin ${BASE_REF} --depth 1
fi
workspace=$(fslabscli check-workspace --json --check-publish "${CHECK_CHANGED[@]}" --binary-store-storage-account ${{ secrets.BINARY_STORE_STORAGE_ACCOUNT }} --binary-store-container-name ${{ secrets.BINARY_STORE_CONTAINER_NAME }} --binary-store-access-key ${{ secrets.BINARY_STORE_ACCESS_KEY }} --cargo-default-publish --cargo-registry foresight-mining-software-corporation --cargo-registry-url https://shipyard.rs/api/v1/shipyard/krates/by-name/ --cargo-registry-user-agent "shipyard ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }}")
workspace=$(fslabscli check-workspace --json --check-publish "${CHECK_CHANGED[@]}" --binary-store-storage-account ${{ vars.BINARY_STORE_STORAGE_ACCOUNT }} --binary-store-container-name ${{ vars.BINARY_STORE_CONTAINER_NAME }} --binary-store-access-key ${{ secrets.BINARY_STORE_ACCESS_KEY }} --cargo-default-publish --cargo-registry foresight-mining-software-corporation --cargo-registry-url https://shipyard.rs/api/v1/shipyard/krates/by-name/ --cargo-registry-user-agent "shipyard ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }}")
if [ $? -ne 0 ]; then
echo "Could not check workspace"
exit 1
Expand Down Expand Up @@ -648,13 +648,26 @@ pub async fn generate_workflow(
if let Some(package_name) = dependency.package.clone() {
testing_requirements.push(format!("test_{}", package_name));
if dependency.publishable {
let publishers = vec!["docker", "cargo", "npm_napi", "binary"];
for publisher in publishers {
if let Some(publish) = dependency.publishable_details.get(publisher) {
if *publish {
publishing_requirements
.push(format!("publish_{}_{}", publisher, package_name,));
}
if let Some(dependency_package) = members.0.get(&package_name) {
if dependency_package.publish_detail.binary.publish {
publishing_requirements
.push(format!("publish_rust_binary_{}", package_name,));
}
if dependency_package.publish_detail.binary.installer.publish {
publishing_requirements
.push(format!("publish_rust_installer_{}", package_name,));
}
if dependency_package.publish_detail.cargo.publish {
publishing_requirements
.push(format!("publish_rust_registry_{}", package_name,));
}
if dependency_package.publish_detail.docker.publish {
publishing_requirements
.push(format!("publish_docker_{}", package_name,));
}
if dependency_package.publish_detail.npm_napi.publish {
publishing_requirements
.push(format!("publish_npm_napi_{}", package_name,));
}
}
}
Expand Down

0 comments on commit 65d6b31

Please sign in to comment.