@@ -6,6 +6,7 @@ env:
RUST_BACKTRACE: '1'
CARGO_INCREMENTAL: '0'
on:
+ merge_group: {}
pull_request:
branches:
- '**'
@@ -167,7 +168,7 @@ jobs:
clippy_windows:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: self-32vcpu-windows-2022
steps:
- name: steps::checkout_repo
@@ -197,7 +198,7 @@ jobs:
clippy_linux:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-16x32-ubuntu-2204
env:
CC: clang
@@ -235,7 +236,7 @@ jobs:
clippy_mac:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-mac-large
steps:
- name: steps::checkout_repo
@@ -266,7 +267,7 @@ jobs:
run_tests_windows:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: self-32vcpu-windows-2022
steps:
- name: steps::checkout_repo
@@ -308,7 +309,7 @@ jobs:
run_tests_linux:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-16x32-ubuntu-2204
env:
CC: clang
@@ -366,7 +367,7 @@ jobs:
run_tests_mac:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-mac-large
steps:
- name: steps::checkout_repo
@@ -409,7 +410,7 @@ jobs:
doctests:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-16x32-ubuntu-2204
env:
CC: clang
@@ -453,7 +454,7 @@ jobs:
check_workspace_binaries:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-8x16-ubuntu-2204
env:
CC: clang
@@ -497,7 +498,7 @@ jobs:
check_wasm:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-8x16-ubuntu-2204
steps:
- name: steps::checkout_repo
@@ -536,7 +537,7 @@ jobs:
check_dependencies:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_tests == 'true'
+ if: needs.orchestrate.outputs.run_tests == 'true' && github.event_name != merge_group
runs-on: namespace-profile-2x4-ubuntu-2404
env:
CC: clang
@@ -620,7 +621,7 @@ jobs:
check_licenses:
needs:
- orchestrate
- if: needs.orchestrate.outputs.run_licenses == 'true'
+ if: needs.orchestrate.outputs.run_licenses == 'true' && github.event_name != merge_group
runs-on: namespace-profile-2x4-ubuntu-2404
steps:
- name: steps::checkout_repo
@@ -1,5 +1,5 @@
use gh_workflow::{
- Concurrency, Container, Event, Expression, Input, Job, Level, Permissions, Port, PullRequest,
+ Container, Event, Expression, Input, Job, Level, MergeGroup, Permissions, Port, PullRequest,
Push, Run, Step, Strategy, Use, UsesJob, Workflow,
};
use indexmap::IndexMap;
@@ -48,24 +48,49 @@ pub(crate) fn run_tests() -> Workflow {
let mut jobs = vec![
orchestrate,
check_style(),
- should_run_tests.guard(clippy(Platform::Windows)),
- should_run_tests.guard(clippy(Platform::Linux)),
- should_run_tests.guard(clippy(Platform::Mac)),
- should_run_tests.guard(run_platform_tests(Platform::Windows)),
- should_run_tests.guard(run_platform_tests(Platform::Linux)),
- should_run_tests.guard(run_platform_tests(Platform::Mac)),
- should_run_tests.guard(doctests()),
- should_run_tests.guard(check_workspace_binaries()),
- should_run_tests.guard(check_wasm()),
- should_run_tests.guard(check_dependencies()), // could be more specific here?
- should_check_docs.guard(check_docs()),
- should_check_licences.guard(check_licenses()),
- should_check_scripts.guard(check_scripts()),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(clippy(Platform::Windows)),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(clippy(Platform::Linux)),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(clippy(Platform::Mac)),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(run_platform_tests(Platform::Windows)),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(run_platform_tests(Platform::Linux)),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(run_platform_tests(Platform::Mac)),
+ should_run_tests.and_not_in_merge_queue().guard(doctests()),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(check_workspace_binaries()),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(check_wasm()),
+ should_run_tests
+ .and_not_in_merge_queue()
+ .guard(check_dependencies()), // could be more specific here?
+ should_check_docs.and_always().guard(check_docs()),
+ should_check_licences
+ .and_not_in_merge_queue()
+ .guard(check_licenses()),
+ should_check_scripts.and_always().guard(check_scripts()),
];
let ext_tests = extension_tests();
let tests_pass = tests_pass(&jobs, &[&ext_tests.name]);
- jobs.push(should_run_tests.guard(check_postgres_and_protobuf_migrations())); // could be more specific here?
+ // TODO: For merge queues, this should fail in the merge queue context
+ jobs.push(
+ should_run_tests
+ .and_always()
+ .guard(check_postgres_and_protobuf_migrations()),
+ ); // could be more specific here?
named::workflow()
.add_event(
@@ -75,16 +100,10 @@ pub(crate) fn run_tests() -> Workflow {
.add_branch("main")
.add_branch("v[0-9]+.[0-9]+.x"),
)
- .pull_request(PullRequest::default().add_branch("**")),
- )
- .concurrency(
- Concurrency::default()
- .group(concat!(
- "${{ github.workflow }}-${{ github.ref_name }}-",
- "${{ github.ref_name == 'main' && github.sha || 'anysha' }}"
- ))
- .cancel_in_progress(true),
+ .pull_request(PullRequest::default().add_branch("**"))
+ .merge_group(MergeGroup::default()),
)
+ .concurrency(vars::one_workflow_per_non_main_branch())
.add_env(("CARGO_TERM_COLOR", "always"))
.add_env(("RUST_BACKTRACE", 1))
.add_env(("CARGO_INCREMENTAL", 0))
@@ -1,4 +1,4 @@
-use std::cell::RefCell;
+use std::{cell::RefCell, ops::Not};
use gh_workflow::{
Concurrency, Env, Expression, Step, WorkflowCallInput, WorkflowCallSecret,
@@ -130,21 +130,50 @@ impl PathCondition {
set_by_step: Default::default(),
}
}
- pub fn guard(&self, job: NamedJob) -> NamedJob {
+
+ pub fn and_always<'a>(&'a self) -> PathContextCondition<'a> {
+ PathContextCondition {
+ condition: self,
+ run_in_merge_queue: true,
+ }
+ }
+
+ pub fn and_not_in_merge_queue<'a>(&'a self) -> PathContextCondition<'a> {
+ PathContextCondition {
+ condition: self,
+ run_in_merge_queue: false,
+ }
+ }
+}
+
+pub struct PathContextCondition<'a> {
+ condition: &'a PathCondition,
+ run_in_merge_queue: bool,
+}
+
+impl<'a> PathContextCondition<'a> {
+ pub fn guard(&'a self, job: NamedJob) -> NamedJob {
let set_by_step = self
+ .condition
.set_by_step
.borrow()
.clone()
- .unwrap_or_else(|| panic!("condition {},is never set", self.name));
+ .unwrap_or_else(|| panic!("condition {},is never set", self.condition.name));
NamedJob {
name: job.name,
- job: job
- .job
- .add_need(set_by_step.clone())
- .cond(Expression::new(format!(
- "needs.{}.outputs.{} == 'true'",
- &set_by_step, self.name
- ))),
+ job: job.job.add_need(set_by_step.clone()).cond(Expression::new(
+ format!(
+ "needs.{}.outputs.{} == 'true' {merge_queue_condition}",
+ &set_by_step,
+ self.condition.name,
+ merge_queue_condition = self
+ .run_in_merge_queue
+ .not()
+ .then_some("&& github.event_name != merge_group")
+ .unwrap_or_default()
+ )
+ .trim(),
+ )),
}
}
}