Skip to content

Commit 921408b

Browse files
committed
Update documentation about the validate command
1 parent 1056bac commit 921408b

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -661,52 +661,54 @@ jobs:
661661
662662
## Special command 'validate'
663663
664-
The command `Validate` can been added via the macro `tracel_xtask_macros::commands`, this command has no implementations in `xtask_common` though.
664+
By convention this command is responsible to run all the checks, builds, and/or tests that validate the code
665+
before opening a pull request or merge request.
665666
666-
This is a special command that you can implement in your repository to perform all the checks and tests needed to validate your code base.
667+
The command `Validate` can been added via the macro `tracel_xtask_macros::commands` like the other commands.
667668

668-
Here is a simple example to perform all checks, build and test:
669+
By default all the checks from the `check` command are run as well as both unit and integration tests from
670+
the `test` command.
671+
672+
You can make your own `handle_command` function if you need to perform more validations. Ideally this function
673+
should only call the other commands `handle_command` functions.
674+
675+
For quick reference here is a simple example to perform all checks and test against the workspace:
669676

670677
```rust
671-
pub fn handle_command() -> anyhow::Result<()> {
672-
let target = tracel_xtask::commands::Target::Workspace;
678+
pub fn handle_command(args: ValidateCmdArgs) -> anyhow::Result<()> {
679+
let target = Target::Workspace;
673680
let exclude = vec![];
674681
let only = vec![];
682+
675683
// checks
676684
[
677-
tracel_xtask::commands::check::CheckCommand::Audit,
678-
tracel_xtask::commands::check::CheckCommand::Format,
679-
tracel_xtask::commands::check::CheckCommand::Lint,
680-
tracel_xtask::commands::check::CheckCommand::Typos,
685+
CheckSubCommand::Audit,
686+
CheckSubCommand::Format,
687+
CheckSubCommand::Lint,
688+
CheckSubCommand::Typos,
681689
]
682690
.iter()
683691
.try_for_each(|c| {
684-
tracel_xtask::commands::check::handle_command(tracel_xtask::commands::check::CheckCmdArgs {
692+
super::check::handle_command(CheckCmdArgs {
685693
target: target.clone(),
686694
exclude: exclude.clone(),
687695
only: only.clone(),
688-
command: c.clone(),
696+
command: Some(c.clone()),
697+
ignore_audit: args.ignore_audit,
689698
})
690699
})?;
691700
692-
// build
693-
tracel_xtask::commands::build::handle_command(
694-
tracel_xtask::commands::build::BuildCmdArgs {
695-
target: target.clone(),
696-
exclude: exclude.clone(),
697-
only: only.clone(),
698-
},
699-
)?;
700-
701701
// tests
702-
tracel_xtask::commands::test::handle_command(
703-
tracel_xtask::commands::test::TestCmdArgs {
704-
target: target.clone(),
705-
exclude: exclude.clone(),
706-
only: only.clone(),
707-
command: tracel_xtask::commands::test::TestCommand::All,
708-
},
709-
)?;
702+
super::test::handle_command(TestCmdArgs {
703+
target: target.clone(),
704+
exclude: exclude.clone(),
705+
only: only.clone(),
706+
threads: None,
707+
jobs: None,
708+
command: Some(TestSubCommand::All),
709+
})?;
710+
711+
Ok(())
710712
}
711713
```
712714

0 commit comments

Comments
 (0)