-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
CI: can filter jobs to run depending on modified files #22032
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
base: main
Are you sure you want to change the base?
Conversation
|
@NicoZweifel @janhohenheim you were interested in this |
|
Nice, it's apparent that you put a lot of thought into this already, I think this looks pretty good for a PoC (maybe it could be converted to a draft for now). I do have a few thoughts about it: A minor maintenance issue in A job runner is always provisioned and the tools are always built but I think that is an okay trade-off to make. Maybe you already thought about this too, but the pub struct Context {
pub trigger: Trigger,
pub changed_files: Vec<String>,
}
pub trait Workflow {
fn suite(&self, context: &Context) -> Vec<Commands>;
}This also simplifies some of the existing code for running everything since you can just return a fn prepare<'a>(&self, sh: &'a xshell::Shell) -> Vec<PreparedCommand<'a>> {
let args = self.into();
match &self.command {
Some(command) => command.prepare(sh, args),
None => {
// Note that we are running the subcommands directly rather than using any aliases
let mut cmds = vec![];
cmds.append(&mut commands::FormatCommand::default().prepare(sh, args));
cmds.append(&mut commands::ClippyCommand::default().prepare(sh, args));
cmds.append(&mut commands::TestCommand::default().prepare(sh, args));
cmds.append(&mut commands::TestCheckCommand::default().prepare(sh, args));
cmds.append(&mut commands::IntegrationTestCommand::default().prepare(sh, args));
cmds.append(
&mut commands::IntegrationTestCheckCommand::default().prepare(sh, args),
);
cmds.append(
&mut commands::IntegrationTestCleanCommand::default().prepare(sh, args),
);
cmds.append(&mut commands::DocCheckCommand::default().prepare(sh, args));
cmds.append(&mut commands::DocTestCommand::default().prepare(sh, args));
cmds.append(&mut commands::CompileCheckCommand::default().prepare(sh, args));
cmds.append(&mut commands::CompileFailCommand::default().prepare(sh, args));
cmds.append(&mut commands::BenchCheckCommand::default().prepare(sh, args));
cmds.append(&mut commands::ExampleCheckCommand::default().prepare(sh, args));
cmds
}
}
} |
| Commands::ExampleCheck(subcommand) => subcommand.prepare(sh, args), | ||
| Commands::WhatToRun(subcommand) => { | ||
| subcommand.run(sh, args); | ||
| vec![] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit odd, maybe it's just temporary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could differentiate between shell and rust commands?
| jobs.push(r#""cargo run -p ci -- test""#); | ||
| jobs.push(r#""cargo run -p ci -- lints""#); | ||
|
|
||
| println!("[{}]", jobs.join(", ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit fragile. I assume this is so that there is no dependency on github ($GITHUB_OUTPUT) here?
NicoZweifel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer to pass an env variable as argument that the script should set, following the same logic/pattern (prepare/run) that the rest of the commands use.
The command could prepare: set $ENV_VARIABLE = [workflow] , which then resolves to set $GITHUB_OUTPUT = [cargo test, etc...].
I would also recommend something like the Workflow trait I mentioned earlier to help with organizing the workflows. Happy to help with any of this if you'd like.
Objective
Solution
cargo run -p ci -- what-to-run --trigger pull_request --head main --rust-version stablethat list commands to be runFor now, this is just the shape of it to open discussion, no filtering is done