Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(risedev): add build dashboard config #1086

Merged
merged 3 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ dependencies = ["link-standalone-binaries", "link-all-in-one-binaries", "link-us
[tasks.extract-dashboard-artifact]
category = "RisingWave"
description = "Extract dashboard artifact"
condition = { env_not_set = [ "ENABLE_BUILD_DASHBOARD_V2" ] }
script = '''
#!@shell
#!/bin/bash

# we allow this script to fail
Expand All @@ -152,6 +152,18 @@ git worktree prune
git worktree add "${PREFIX_UI}" origin/dashboard-artifact
'''

[tasks.export-dashboard-v2]
category = "RisingWave"
condition = { env_set = [ "ENABLE_BUILD_DASHBOARD_V2" ] }
script = """
#!/bin/bash
set -e

rm -rf "${PREFIX_UI}"
cd dashboard && npm run build-static
cd .. && ln -s "$(pwd)/dashboard/out" "${PREFIX_UI}"
"""

[tasks.build-risingwave]
category = "RisingWave"
description = "Build RisingWave compute-node and meta-node"
Expand Down Expand Up @@ -217,6 +229,7 @@ dependencies = [
"build-frontend",
"post-build-frontend",
"extract-dashboard-artifact",
"export-dashboard-v2",
"prepare-config"
]

Expand Down
81 changes: 64 additions & 17 deletions rust/risedevtool/src/bin/risedev-config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub enum Components {
Tracing,
ComputeNodeAndMetaNode,
Frontend,
Dashboard,
Release,
AllInOne,
}
Expand All @@ -43,6 +44,7 @@ impl Components {
Self::Etcd => "[Component] Etcd",
Self::ComputeNodeAndMetaNode => "[Build] Rust components",
Self::Frontend => "[Build] Java frontend",
Self::Dashboard => "[Build] Dashboard v2",
Self::Tracing => "[Component] Tracing: Jaeger",
Self::Release => "[Build] Enable release mode",
Self::AllInOne => "[Build] Enable all-in-one binary",
Expand Down Expand Up @@ -75,6 +77,10 @@ to RiseDev directory."
"
Required if you want to build frontend. Otherwise you will
need to manually download and copy it to RiseDev directory."
}
Self::Dashboard => {
"
Required if you want to build dashboard v2 from source."
}
Self::Tracing => {
"
Expand Down Expand Up @@ -116,6 +122,7 @@ and use `risingwave` in all-in-one mode."
Self::Etcd => "ENABLE_ETCD",
Self::ComputeNodeAndMetaNode => "ENABLE_BUILD_RUST",
Self::Frontend => "ENABLE_BUILD_FRONTEND",
Self::Dashboard => "ENABLE_BUILD_DASHBOARD_V2",
Self::Tracing => "ENABLE_COMPUTE_TRACING",
Self::Release => "ENABLE_RELEASE_PROFILE",
Self::AllInOne => "ENABLE_ALL_IN_ONE",
Expand All @@ -134,38 +141,52 @@ fn configure(chosen: &[Components]) -> Result<Vec<Components>> {
println!("RiseDev includes several components. You can select the ones you need, so as to reduce build time.");
println!();
println!(
"Use {} to navigate, and use {} to select. Press {} to continue.",
style("arrow keys").bold(),
"Use {} to navigate, use {} to go to next page, and use {} to select. Press {} to continue.",
style("arrow up / down").bold(),
style("arrow left / right").bold(),
style("space").bold(),
style("enter").bold()
);
println!();

let all_components = Components::into_enum_iter().collect_vec();

const ITEMS_PER_PAGE: usize = 6;

let items = all_components
.iter()
.map(|c| {
(
format!(
"{}{}",
c.title(),
style(
("\n".to_string() + c.description().trim())
.split('\n')
.join("\n ")
)
.dim()
),
chosen.contains(c),
.enumerate()
.map(|(idx, c)| {
let title = c.title();
let desc = style(
("\n".to_string() + c.description().trim())
.split('\n')
.join("\n "),
)
.dim();

let instruction = if (idx + 1) % ITEMS_PER_PAGE == 0 || idx == all_components.len() - 1
{
format!(
"\n\n page {}/{}, use {} to navigate",
style(((idx + ITEMS_PER_PAGE - 1) / ITEMS_PER_PAGE).to_string()).bold(),
(all_components.len() + ITEMS_PER_PAGE - 1) / ITEMS_PER_PAGE,
style("arrow key left / right").blue(),
)
} else {
String::new()
};

(format!("{title}{desc}{instruction}",), chosen.contains(c))
})
.collect_vec();

let chosen_indices: Vec<usize> = MultiSelect::new()
.items_checked(&items)
.max_length(ITEMS_PER_PAGE)
.interact_opt()?
.ok_or_else(|| anyhow!("no selection made"))?;

let chosen = chosen_indices
.into_iter()
.map(|i| all_components[i])
Expand Down Expand Up @@ -221,6 +242,19 @@ fn main() -> Result<()> {
configure(&chosen)?
};

for component in Components::into_enum_iter() {
println!(
"{}: {}",
component.title(),
if chosen.contains(&component) {
style("enabled").green()
} else {
style("disabled").dim()
}
);
}
println!();

println!("Writing configuration into {}...", file_path);

let mut file = BufWriter::new(
Expand All @@ -233,8 +267,21 @@ fn main() -> Result<()> {
);

writeln!(file, "RISEDEV_CONFIGURED=true")?;
for component in chosen {
writeln!(file, "{}=true", component.env())?;
writeln!(file)?;

for component in Components::into_enum_iter() {
writeln!(file, "# {}", component.title())?;
writeln!(
file,
"# {}",
component.description().trim().split('\n').join("\n# ")
)?;
if chosen.contains(&component) {
writeln!(file, "{}=true", component.env())?;
} else {
writeln!(file, "# {}=true", component.env())?;
}
writeln!(file)?;
}

file.flush()?;
Expand Down