Skip to content

Commit

Permalink
ci(concurrency)!: run a single CI workflow as required (#4981)
Browse files Browse the repository at this point in the history
* 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 #4977
Fixes #4857

* docs: typo

* ci(concurrency): do not cancel running full syncs

Co-authored-by: teor <teor@riseup.net>

* fix(concurrency): explain the behavior better & add new ones

Co-authored-by: teor <teor@riseup.net>
  • Loading branch information
gustavovalverde and teor2345 authored Aug 30, 2022
1 parent e5c0e10 commit c85e482
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build-crates-individually.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/continous-delivery.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/continous-integration-docker.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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`.
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/continous-integration-os.yml
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/zcash-params.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit c85e482

Please sign in to comment.