From c85e482fa0c1bf4a24a34d4af2193d6535b1b024 Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Mon, 29 Aug 2022 20:11:05 -0400 Subject: [PATCH] ci(concurrency)!: run a single CI workflow as required (#4981) * ci(concurrency)!: run a single CI workflow as required Previous behavior: Multiple Mainnet full syncs were able to run on the main branch at the same time, and pushing multiple commits to the same branch would run multiple CI workflows, when only the run from last commit was relevant Expected behavior: Ensure that only a single CI workflow runs at the same time in PRs. The latest commit should cancel any previous running workflows from the same PR. Solution: Use GitHub actions concurrency feature https://docs.github.com/en/actions/using-jobs/using-concurrency Fixes https://github.com/ZcashFoundation/zebra/issues/4977 Fixes https://github.com/ZcashFoundation/zebra/issues/4857 * docs: typo * ci(concurrency): do not cancel running full syncs Co-authored-by: teor * fix(concurrency): explain the behavior better & add new ones Co-authored-by: teor --- .github/workflows/build-crates-individually.yml | 7 +++++++ .github/workflows/continous-delivery.yml | 7 +++++++ .../workflows/continous-integration-docker.yml | 15 +++++++++++++++ .github/workflows/continous-integration-os.yml | 7 +++++++ .github/workflows/coverage.yml | 7 +++++++ .github/workflows/docs.yml | 7 +++++++ .github/workflows/lint.yml | 7 +++++++ .github/workflows/zcash-params.yml | 7 +++++++ 8 files changed, 64 insertions(+) diff --git a/.github/workflows/build-crates-individually.yml b/.github/workflows/build-crates-individually.yml index 57b25707..8dd84409 100644 --- a/.github/workflows/build-crates-individually.yml +++ b/.github/workflows/build-crates-individually.yml @@ -1,5 +1,12 @@ name: Build crates individually +# Ensures that only one workflow task will run at a time. Previous builds, if +# already in process, will get cancelled. Only the latest commit will be allowed +# to run, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + on: workflow_dispatch: push: diff --git a/.github/workflows/continous-delivery.yml b/.github/workflows/continous-delivery.yml index 3b14683c..7414e8d3 100644 --- a/.github/workflows/continous-delivery.yml +++ b/.github/workflows/continous-delivery.yml @@ -1,5 +1,12 @@ name: CD +# Ensures that only one workflow task will run at a time. Previous deployments, if +# already in process, won't get cancelled. Instead, we let the first to complete +# then queue the latest pending workflow, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + on: workflow_dispatch: inputs: diff --git a/.github/workflows/continous-integration-docker.yml b/.github/workflows/continous-integration-docker.yml index 6fc73bf7..df965681 100644 --- a/.github/workflows/continous-integration-docker.yml +++ b/.github/workflows/continous-integration-docker.yml @@ -1,5 +1,12 @@ name: CI Docker +# Ensures that only one workflow task will run at a time. Previous builds, if +# already in process, will get cancelled. Only the latest commit will be allowed +# to run, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + on: workflow_dispatch: inputs: @@ -312,6 +319,14 @@ jobs: saves_to_disk: true disk_suffix: tip height_grep_text: 'current_height.*=.*Height' + # We don't want to cancel running full syncs on `main` if a new PR gets merged, + # because we might never finish a full sync during busy weeks. Instead, we let the + # first sync complete, then queue the latest pending sync, cancelling any syncs in between. + # (As the general workflow concurrency group just gets matched in Pull Requests, + # it has no impact on this job.) + concurrency: + group: github.workflow−{{ github.ref }} + cancel-in-progress: false # Test that Zebra can sync to the chain tip, using a cached Zebra tip state, # without launching `lightwalletd`. diff --git a/.github/workflows/continous-integration-os.yml b/.github/workflows/continous-integration-os.yml index 0bf90b8d..b89400f5 100644 --- a/.github/workflows/continous-integration-os.yml +++ b/.github/workflows/continous-integration-os.yml @@ -1,5 +1,12 @@ name: CI OSes +# Ensures that only one workflow task will run at a time. Previous builds, if +# already in process, will get cancelled. Only the latest commit will be allowed +# to run, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + on: workflow_dispatch: # we build Rust and Zcash parameter caches on main, diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 230afd68..b0e8ebea 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,5 +1,12 @@ name: Coverage +# Ensures that only one workflow task will run at a time. Previous builds, if +# already in process, will get cancelled. Only the latest commit will be allowed +# to run, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + on: workflow_dispatch: push: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ddff8841..c797c92e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,5 +1,12 @@ name: Docs +# Ensures that only one workflow task will run at a time. Previous deployments, if +# already in process, won't get cancelled. Instead, we let the first to complete +# then queue the latest pending workflow, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + on: workflow_dispatch: push: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 254fe14c..42e3484f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,12 @@ name: Lint +# Ensures that only one workflow task will run at a time. Previous builds, if +# already in process, will get cancelled. Only the latest commit will be allowed +# to run, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + on: # we build Rust caches on main, so they can be shared by all branches: # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache diff --git a/.github/workflows/zcash-params.yml b/.github/workflows/zcash-params.yml index b2f59fb0..e283c744 100644 --- a/.github/workflows/zcash-params.yml +++ b/.github/workflows/zcash-params.yml @@ -1,5 +1,12 @@ name: zcash-params +# Ensures that only one workflow task will run at a time. Previous deployments, if +# already in process, won't get cancelled. Instead, we let the first to complete +# then queue the latest pending workflow, cancelling any workflows in between +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + on: workflow_dispatch: push: