From 36c4be2cfab15973b9bb58990e5f9fc96d454474 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 28 Nov 2024 16:52:12 +0000 Subject: [PATCH] feat: backend concurrency --- .github/workflows/release.yml | 2 +- .github/workflows/scala-new.yml | 15 +++------------ build/build/src/ci_gen.rs | 18 +++++++++++++++--- .../src/actions/workflow/definition.rs | 4 ++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96794e5a2a6d..db824a4ad201 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,7 @@ on: required: false type: string default: nodejs +concurrency: release jobs: enso-build-ci-gen-draft-release-linux-amd64: name: Create a release draft. @@ -725,4 +726,3 @@ env: ENSO_EDITION: ${{ inputs.version }} ENSO_VERSION: ${{ inputs.version }} RUST_BACKTRACE: full -concurrency: release diff --git a/.github/workflows/scala-new.yml b/.github/workflows/scala-new.yml index 12adf675b49d..0615bdee35f0 100644 --- a/.github/workflows/scala-new.yml +++ b/.github/workflows/scala-new.yml @@ -14,19 +14,10 @@ on: required: false type: boolean default: false +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/develop' }} jobs: - enso-build-ci-gen-job-cancel-workflow-linux-amd64: - name: Cancel Previous Runs - if: github.ref != 'refs/heads/develop' - runs-on: - - ubuntu-latest - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - permissions: - actions: write enso-build-ci-gen-job-ci-check-backend-graal-vm-ce-linux-amd64: name: Engine (GraalVM CE) (linux, amd64) runs-on: diff --git a/build/build/src/ci_gen.rs b/build/build/src/ci_gen.rs index 47a3f58152e6..b5f4c9242019 100644 --- a/build/build/src/ci_gen.rs +++ b/build/build/src/ci_gen.rs @@ -670,10 +670,22 @@ pub fn gui_tests() -> Result { Ok(workflow) } +fn concurrency() -> Concurrency { + let github_workflow = wrap_expression("github.workflow"); + let github_ref = wrap_expression("github.ref"); + Concurrency::Map { + group: format!("{github_workflow}-{github_ref}"), + cancel_in_progress: wrap_expression(not_default_branch()), + } +} + pub fn backend() -> Result { - let on = typical_check_triggers(); - let mut workflow = Workflow { name: "Engine CI".into(), on, ..default() }; - workflow.add(PRIMARY_TARGET, job::CancelWorkflow); + let mut workflow = Workflow { + name: "Engine CI".into(), + on: typical_check_triggers(), + concurrency: Some(concurrency()), + ..default() + }; workflow.add(PRIMARY_TARGET, job::VerifyLicensePackages); for target in PR_CHECKED_TARGETS { add_backend_checks(&mut workflow, target, graalvm::Edition::Community); diff --git a/build/ci_utils/src/actions/workflow/definition.rs b/build/ci_utils/src/actions/workflow/definition.rs index ede82b57ebc9..a5c25ffd0e94 100644 --- a/build/ci_utils/src/actions/workflow/definition.rs +++ b/build/ci_utils/src/actions/workflow/definition.rs @@ -193,14 +193,14 @@ pub struct Workflow { #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, pub on: Event, + #[serde(skip_serializing_if = "Option::is_none")] + pub concurrency: Option, #[serde(skip_serializing_if = "BTreeMap::is_empty")] pub permissions: BTreeMap, // No additional clause, as the jobs must be non-empty. pub jobs: BTreeMap, #[serde(skip_serializing_if = "BTreeMap::is_empty")] pub env: BTreeMap, - #[serde(skip_serializing_if = "Option::is_none")] - pub concurrency: Option, } impl Default for Workflow {