diff --git a/.github/workflows/drupal-contrib-integration-test.yml b/.github/workflows/drupal-contrib-integration-test.yml index 052a977..7718e2d 100644 --- a/.github/workflows/drupal-contrib-integration-test.yml +++ b/.github/workflows/drupal-contrib-integration-test.yml @@ -479,7 +479,7 @@ jobs: run: shell: bash -euo pipefail {0} env: - WORKSPACE_NAME: gc-${{ matrix.project }}-d${{ matrix.drupal_version }}-${{ github.run_number }}-${{ github.run_attempt }} + WORKSPACE_NAME: gc-${{ matrix.project }}-d${{ matrix.drupal_version }}-${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name == 'main' && 'main' || format('x{0}', github.run_number) }}-${{ github.run_number }}-${{ github.run_attempt }} CI: "true" DDEV_NONINTERACTIVE: "true" NO_COLOR: "1" @@ -512,7 +512,7 @@ jobs: --variable github_token=${{ secrets.GITHUB_TOKEN }} - name: Reap predecessor workspaces (cancelled prior runs of this cell) - run: ./scripts/ci-reap-family.sh "gc-${{ matrix.project }}-d${{ matrix.drupal_version }}-" "${{ env.WORKSPACE_NAME }}" + run: ./scripts/ci-reap-family.sh "${WORKSPACE_NAME%-*-*}-" "$WORKSPACE_NAME" - name: Acquire staging box lock run: ./scripts/ci-acquire-staging-lock.sh @@ -696,7 +696,7 @@ jobs: run: shell: bash -euo pipefail {0} env: - WORKSPACE_NAME: gc-fork-${{ github.run_number }}-${{ github.run_attempt }} + WORKSPACE_NAME: gc-fork-${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name == 'main' && 'main' || format('x{0}', github.run_number) }}-${{ github.run_number }}-${{ github.run_attempt }} CI: "true" DDEV_NONINTERACTIVE: "true" NO_COLOR: "1" @@ -765,7 +765,7 @@ jobs: --variable github_token=${{ secrets.GITHUB_TOKEN }} - name: Reap predecessor workspaces (cancelled prior runs of this cell) - run: ./scripts/ci-reap-family.sh "gc-fork-" "${{ env.WORKSPACE_NAME }}" + run: ./scripts/ci-reap-family.sh "${WORKSPACE_NAME%-*-*}-" "$WORKSPACE_NAME" - name: Acquire staging box lock run: ./scripts/ci-acquire-staging-lock.sh @@ -906,7 +906,7 @@ jobs: run: shell: bash -euo pipefail {0} env: - WORKSPACE_NAME: gc-glfork-${{ github.run_number }}-${{ github.run_attempt }} + WORKSPACE_NAME: gc-glfork-${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name == 'main' && 'main' || format('x{0}', github.run_number) }}-${{ github.run_number }}-${{ github.run_attempt }} CI: "true" DDEV_NONINTERACTIVE: "true" NO_COLOR: "1" @@ -975,7 +975,7 @@ jobs: --variable github_token=${{ secrets.GITHUB_TOKEN }} - name: Reap predecessor workspaces (cancelled prior runs of this cell) - run: ./scripts/ci-reap-family.sh "gc-glfork-" "${{ env.WORKSPACE_NAME }}" + run: ./scripts/ci-reap-family.sh "${WORKSPACE_NAME%-*-*}-" "$WORKSPACE_NAME" - name: Acquire staging box lock run: ./scripts/ci-acquire-staging-lock.sh diff --git a/.github/workflows/drupal-integration-test.yml b/.github/workflows/drupal-integration-test.yml index 6aad51f..3ace2fb 100644 --- a/.github/workflows/drupal-integration-test.yml +++ b/.github/workflows/drupal-integration-test.yml @@ -256,7 +256,7 @@ jobs: run: shell: bash -euo pipefail {0} env: - WORKSPACE_NAME: gd-${{ matrix.drupal_version }}-${{ github.run_number }}-${{ github.run_attempt }} + WORKSPACE_NAME: gd-${{ matrix.drupal_version }}-${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name == 'main' && 'main' || format('x{0}', github.run_number) }}-${{ github.run_number }}-${{ github.run_attempt }} CI: "true" DDEV_NONINTERACTIVE: "true" NO_COLOR: "1" @@ -290,7 +290,7 @@ jobs: --variable github_token=${{ secrets.GITHUB_TOKEN }} - name: Reap predecessor workspaces (cancelled prior runs of this cell) - run: ./scripts/ci-reap-family.sh "gd-${{ matrix.drupal_version }}-" "${{ env.WORKSPACE_NAME }}" + run: ./scripts/ci-reap-family.sh "${WORKSPACE_NAME%-*-*}-" "$WORKSPACE_NAME" - name: Acquire staging box lock run: ./scripts/ci-acquire-staging-lock.sh @@ -568,7 +568,7 @@ jobs: run: shell: bash -euo pipefail {0} env: - WORKSPACE_NAME: gd-fork-${{ github.run_number }}-${{ github.run_attempt }} + WORKSPACE_NAME: gd-fork-${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name == 'main' && 'main' || format('x{0}', github.run_number) }}-${{ github.run_number }}-${{ github.run_attempt }} CI: "true" DDEV_NONINTERACTIVE: "true" NO_COLOR: "1" @@ -621,7 +621,7 @@ jobs: --variable github_token=${{ secrets.GITHUB_TOKEN }} - name: Reap predecessor workspaces (cancelled prior runs of this cell) - run: ./scripts/ci-reap-family.sh "gd-fork-" "${{ env.WORKSPACE_NAME }}" + run: ./scripts/ci-reap-family.sh "${WORKSPACE_NAME%-*-*}-" "$WORKSPACE_NAME" - name: Acquire staging box lock run: ./scripts/ci-acquire-staging-lock.sh diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index bcc13ff..b072c83 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -323,7 +323,7 @@ jobs: shell: bash -euo pipefail {0} env: CI_TAG: ${{ github.run_number }}-${{ github.run_attempt }} - WORKSPACE_NAME: gh-${{ matrix.ws_name }}-${{ github.run_number }}-${{ github.run_attempt }} + WORKSPACE_NAME: gh-${{ matrix.ws_name }}-${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name == 'main' && 'main' || format('x{0}', github.run_number) }}-${{ github.run_number }}-${{ github.run_attempt }} CI: "true" DDEV_NONINTERACTIVE: "true" NO_COLOR: "1" @@ -363,7 +363,7 @@ jobs: ${{ matrix.extra_vars }} - name: Reap predecessor workspaces (cancelled prior runs of this cell) - run: ./scripts/ci-reap-family.sh "gh-${{ matrix.ws_name }}-" "${{ env.WORKSPACE_NAME }}" + run: ./scripts/ci-reap-family.sh "${WORKSPACE_NAME%-*-*}-" "$WORKSPACE_NAME" - name: Acquire staging box lock run: ./scripts/ci-acquire-staging-lock.sh diff --git a/scripts/ci-reap-family.sh b/scripts/ci-reap-family.sh index fdb7e5d..41cef78 100755 --- a/scripts/ci-reap-family.sh +++ b/scripts/ci-reap-family.sh @@ -10,9 +10,17 @@ # its own family and can delete any older sibling before creating its own. # # Workspace names are -- (e.g. -# gc-pathauto-d11-152-1). The family is the stable part shared across runs of -# the same matrix cell. Passing the family prefix here deletes every ci-bot -# workspace that starts with it EXCEPT the one this run is about to create. +# gc-pathauto-d11-pr212-152-1). The family is the stable part shared across +# runs of the same matrix cell ON THE SAME REF. Passing the family prefix here +# deletes every ci-bot workspace that starts with it EXCEPT the one this run +# is about to create. +# +# The family MUST include a ref tag (pr for pull requests, main for +# push/schedule/dispatch on main, x elsewhere). Runs on different +# refs are in different concurrency groups and legitimately overlap; without +# the ref tag, a PR run's reap would delete main's in-flight workspace (this +# happened on main run 407, deleted by PR run 408). Callers derive the family +# from WORKSPACE_NAME as "${WORKSPACE_NAME%-*-*}-" so the two cannot drift. # # Usage: # ci-reap-family.sh [keep-name]