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

Add guide command and run guide execution in pull-request-checks #24

Merged
merged 2 commits into from
Jun 18, 2024
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
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[alias]
xtask = "run --manifest-path ./xtask/Cargo.toml --"
xtask = "run --target-dir target/xtask/debug --package xtask --bin xtask --"
6 changes: 4 additions & 2 deletions xtask/src/commands/pull_request_checks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strum::IntoEnumIterator;

use super::ci::{self, CICmdArgs, CICommand};
use super::{ci::{self, CICmdArgs, CICommand}, test::run_guide};

pub(crate) fn handle_command() -> anyhow::Result<()> {
CICommand::iter()
Expand All @@ -10,5 +10,7 @@ pub(crate) fn handle_command() -> anyhow::Result<()> {
target: super::Target::All,
command: c.clone(),
})
)
)?;
// Execute the guide example
run_guide()
}
20 changes: 20 additions & 0 deletions xtask/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use crate::{endgroup, group, utils::workspace::{get_workspace_members, Workspace

use super::Target;

const PROJECT_UUID: &str = "331a3907-bfd8-45e5-af54-1fee73a3c1b1";
const API_KEY: &str = "dcaf7eb9-5acc-47d7-8b93-ca0fbb234096";

#[derive(Args)]
pub(crate) struct TestCmdArgs {
/// Target to test for.
Expand All @@ -26,6 +29,8 @@ enum TestCommand {
Integration,
/// Run documentation tests.
Documentation,
/// Run guide test against Heat dev stack.
Guide,
/// Run all the checks.
All,
}
Expand All @@ -35,6 +40,7 @@ pub(crate) fn handle_command(args: TestCmdArgs) -> anyhow::Result<()> {
TestCommand::Unit => run_unit(&args.target),
TestCommand::Integration => run_integration(&args.target),
TestCommand::Documentation => run_documentation(&args.target),
TestCommand::Guide => run_guide(),
TestCommand::All => {
TestCommand::iter()
.filter(|c| *c != TestCommand::All)
Expand All @@ -48,6 +54,20 @@ pub(crate) fn handle_command(args: TestCmdArgs) -> anyhow::Result<()> {
}
}

pub(crate) fn run_guide() -> Result<()> {
group!("Guide Test");
info!("Command line: cargo run --release --bin guide -- --key \"...\" --project \"...\"");
let status = Command::new("cargo")
.args(["run", "--release", "--bin", "guide", "--", "--key", API_KEY, "--project", PROJECT_UUID])
.status()
.map_err(|e| anyhow!("Failed to execute guide example: {}", e))?;
if !status.success() {
return Err(anyhow!("Failed to execute guide example"));
}
endgroup!();
Ok(())
}

pub(crate) fn run_unit(target: &Target) -> Result<()> {
match target {
Target::Crates | Target::Examples => {
Expand Down
Loading