@@ -661,52 +661,54 @@ jobs:
661
661
662
662
## Special command 'validate'
663
663
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.
665
666
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 .
667
668
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 :
669
676
670
677
` ` ` 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;
673
680
let exclude = vec![];
674
681
let only = vec![];
682
+
675
683
// checks
676
684
[
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,
681
689
]
682
690
.iter()
683
691
.try_for_each(|c| {
684
- tracel_xtask::commands:: check::handle_command(tracel_xtask::commands::check:: CheckCmdArgs {
692
+ super:: check::handle_command(CheckCmdArgs {
685
693
target: target.clone(),
686
694
exclude: exclude.clone(),
687
695
only: only.clone(),
688
- command: c.clone(),
696
+ command: Some(c.clone()),
697
+ ignore_audit: args.ignore_audit,
689
698
})
690
699
})?;
691
700
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
-
701
701
// 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(())
710
712
}
711
713
` ` `
712
714
0 commit comments