Skip to content

Commit

Permalink
workflows: use set -xeuo pipefail globally
Browse files Browse the repository at this point in the history
This is the same change as Homebrew/brew#18369.
  • Loading branch information
carlocab committed Sep 28, 2024
1 parent 41d21e0 commit d7ccd4a
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 27 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
paths:
- '.github/workflows/*.ya?ml'

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: "actionlint-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
Expand All @@ -35,7 +39,6 @@ jobs:
test-bot: false

- name: Set up actionlint
shell: bash
env:
HOMEBREW_TAP_REPOSITORY: ${{ steps.setup-homebrew.outputs.repository-path }}
run: |
Expand All @@ -48,7 +51,7 @@ jobs:
# Setting `shell: /bin/bash` prevents shellcheck from running on
# those steps, so let's change them to `shell: bash` for linting.
sed -i 's:/bin/bash -e {0}:bash:' .github/workflows/*.y*ml
sed -i 's|shell: /bin/bash -x|shell: bash -x|' .github/workflows/*.y*ml
# The JSON matcher needs to be accessible to the container host.
cp "$(brew --repository)/.github/actionlint-matcher.json" "$HOME"
echo "::add-matcher::$HOME/actionlint-matcher.json"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/autobump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
permissions:
contents: read

defaults:
run:
shell: bash -xeuo pipefail {0}

jobs:
autobump:
if: github.repository == 'Homebrew/homebrew-core'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/automerge-from-merge-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
types:
- completed

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: automerge-merge_queue-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.id }}
cancel-in-progress: true
Expand Down Expand Up @@ -252,9 +256,6 @@ jobs:
contents: read
pull-requests: read
actions: write # to dispatch publish workflow
defaults:
run:
shell: bash
steps:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/automerge-triggers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
- unlabeled
- ready_for_review

defaults:
run:
shell: bash -xeuo pipefail {0}

jobs:
check:
if: >
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
types:
- completed

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: automerge-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.id }}
cancel-in-progress: true
Expand Down Expand Up @@ -182,9 +186,6 @@ jobs:
contents: read
pull-requests: read
actions: write # to dispatch publish workflow
defaults:
run:
shell: bash
steps:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ env:
HOMEBREW_DEVELOPER: 1
HOMEBREW_NO_AUTO_UPDATE: 1

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: cache-${{ github.event.pull_request.number }}
cancel-in-progress: true
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/clean-up-closed-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
types:
- closed

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
Expand All @@ -23,9 +27,6 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/homebrew/ubuntu22.04:master
defaults:
run:
shell: bash
permissions:
contents: read
actions: write # for `gh run cancel`
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/create-replacement-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Create replacement pull request
run-name: "Replace PR #${{ inputs.pull_request }}"

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.pull_request }}-${{ github.event.inputs.upload }}
cancel-in-progress: ${{ !fromJson(github.event.inputs.upload) }}
Expand Down Expand Up @@ -56,9 +60,6 @@ jobs:
repository-projects: write # for `gh pr edit`
attestations: write # for actions/attest-build-provenance
id-token: write # for actions/attest-build-provenance
defaults:
run:
shell: bash
steps:
- name: Post comment once started
uses: Homebrew/actions/post-comment@master
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/dispatch-build-bottle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ env:
DISPATCH_BUILD_BOTTLE_ISSUE: ${{ inputs.issue }}
DISPATCH_BUILD_BOTTLE_UPLOAD: ${{ inputs.upload }}

defaults:
run:
shell: bash -xeuo pipefail {0}

# Intentionally the same as dispatch-rebottle
concurrency: bottle-${{ github.event.inputs.formula }}

Expand Down Expand Up @@ -143,7 +147,7 @@ jobs:
contents: read
defaults:
run:
shell: /bin/bash -e {0}
shell: /bin/bash -xeuo pipefail {0}
working-directory: ${{matrix.workdir || github.workspace}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -197,9 +201,6 @@ jobs:
if: inputs.upload
container:
image: ghcr.io/homebrew/ubuntu22.04:master
defaults:
run:
shell: bash
env:
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
GH_REPO: ${{github.repository}}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/dispatch-rebottle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ on:
default: true
required: false

defaults:
run:
shell: bash -xeuo pipefail {0}

# Intentionally the same as dispatch-build-bottle
concurrency: bottle-${{ github.event.inputs.formula }}

Expand Down Expand Up @@ -84,7 +88,7 @@ jobs:
timeout-minutes: ${{fromJson(inputs.timeout)}}
defaults:
run:
shell: /bin/bash -e {0}
shell: /bin/bash -xeuo pipefail {0}
working-directory: ${{matrix.workdir || github.workspace}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -134,9 +138,6 @@ jobs:
if: inputs.upload
container:
image: ghcr.io/homebrew/ubuntu22.04:master
defaults:
run:
shell: bash
env:
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
GH_REPO: ${{github.repository}}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/manage-pull-request-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
types:
- unlabeled

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.label.name }}
cancel-in-progress: true
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/publish-commit-bottles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ on:
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds (requires autosquash)"
required: false

defaults:
run:
shell: bash -xeuo pipefail {0}

env:
PR: ${{inputs.pull_request}}
INPUT_MESSAGE: ${{ inputs.message }}
Expand Down Expand Up @@ -251,9 +255,6 @@ jobs:
actions: read # for `brew pr-pull`
pull-requests: write # for `gh pr edit|review`
repository-projects: write # for `gh pr edit`
defaults:
run:
shell: bash
steps:
- name: Post comment once started
uses: Homebrew/actions/post-comment@master
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/recreate-linux-runners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
types:
- completed

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: recreate-linux-runners-${{ github.event.workflow_run.id || github.ref }}
cancel-in-progress: true
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/remove-disabled-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
env:
RUN_URL: ${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: remove-disabled-packages
cancel-in-progress: true
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
# Once every day at 1AM
- cron: "0 1 * * *"

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: scheduled
cancel-in-progress: true
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ env:
GH_PROMPT_DISABLED: 1
SCRIPTS_PATH: .github/workflows/scripts

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: "tests-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
Expand Down Expand Up @@ -213,7 +217,7 @@ jobs:
timeout-minutes: ${{ matrix.timeout }}
defaults:
run:
shell: /bin/bash -e {0}
shell: /bin/bash -xeuo pipefail {0}
working-directory: ${{matrix.workdir || github.workspace}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -332,7 +336,7 @@ jobs:
timeout-minutes: ${{ matrix.timeout }}
defaults:
run:
shell: /bin/bash -e {0}
shell: /bin/bash -xeuo pipefail {0}
working-directory: ${{matrix.workdir || github.workspace}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/triage-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
types:
- completed

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: triage-ci-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.id }}
cancel-in-progress: true
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ env:
GH_NO_UPDATE_NOTIFIER: 1
GH_PROMPT_DISABLED: 1

defaults:
run:
shell: bash -xeuo pipefail {0}

concurrency:
group: "triage-${{ github.event.number }}"
cancel-in-progress: true
Expand Down

0 comments on commit d7ccd4a

Please sign in to comment.