Skip to content

Commit

Permalink
Add guide command and run guide execution in pull-request-checks (#24)
Browse files Browse the repository at this point in the history
* Add guide command and run guide execution in pull-request-checks

* Build xtask crate in dedicated directory
  • Loading branch information
syl20bnr authored Jun 18, 2024
1 parent a9380b3 commit 38810e4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
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

0 comments on commit 38810e4

Please sign in to comment.