Skip to content

Commit 0c01521

Browse files
committed
feat: add setup-homebrew action with pristine and update inputs
refactor: remove pristine-homebrew action and integrate into setup-homebrew refactor: remove prepare-pristine-homebrew job and use pristine option in test-destructive job chore: remove brew cache cleaning from clean_homebrew.sh script
1 parent 27f89e6 commit 0c01521

File tree

4 files changed

+48
-150
lines changed

4 files changed

+48
-150
lines changed

.github/actions/pristine-homebrew/action.yml

Lines changed: 0 additions & 127 deletions
This file was deleted.

.github/actions/setup-homebrew/action.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
name: setup Homebrew
22
description: Setup Homebrew
33

4+
inputs:
5+
pristine:
6+
description: Make Homebrew Pristine
7+
required: true
8+
default: 'false'
9+
update:
10+
description: Update Homebrew
11+
required: true
12+
default: 'false'
13+
414
runs:
515
using: composite
616
steps:
@@ -20,3 +30,39 @@ runs:
2030
echo "HOMEBREW_PREFIX=$(brew --prefix)" >> "$GITHUB_ENV"
2131
echo "HOMEBREW_CELLAR=$(brew --cellar)" >> "$GITHUB_ENV"
2232
echo "HOMEBREW_REPOSITORY=$(brew --repository)" >> "$GITHUB_ENV"
33+
- name: Make Homebrew pristine
34+
if: inputs.pristine == 'true'
35+
shell: bash
36+
run: |
37+
set -euo pipefail
38+
39+
formulae=()
40+
while IFS= read -r f; do
41+
formulae+=("$f")
42+
done < <(brew list --formula)
43+
if [ "${#formulae[@]}" -gt 0 ]; then
44+
brew uninstall --formula --force "${formulae[@]}"
45+
fi
46+
47+
casks=()
48+
while IFS= read -r c; do
49+
casks+=("$c")
50+
done < <(brew list --cask)
51+
if [ "${#casks[@]}" -gt 0 ]; then
52+
brew uninstall --cask --zap --force "${casks[@]}"
53+
fi
54+
55+
taps=()
56+
while IFS= read -r t; do
57+
taps+=("$t")
58+
done < <(brew tap)
59+
if [ "${#taps[@]}" -gt 0 ]; then
60+
brew untap "${taps[@]}"
61+
fi
62+
- name: Update Homebrew
63+
if: inputs.update == 'true'
64+
shell: bash
65+
run: |
66+
set -euo pipefail
67+
brew update
68+
brew upgrade

.github/workflows/test.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,6 @@ jobs:
134134
github_token: "${{github.token}}"
135135
pre-commit: "${{ env.IS_MAIN }}"
136136
tmate: "${{ env.DEBUG }}"
137-
prepare-pristine-homebrew:
138-
strategy:
139-
fail-fast: false
140-
matrix:
141-
#os: [macos-latest, ubuntu-latest]
142-
os: [macos-latest]
143-
runs-on: ${{ matrix.os }}
144-
steps:
145-
- uses: actions/checkout@v4
146-
with:
147-
persist-credentials: false
148-
fetch-depth: 0
149-
- uses: ./.github/actions/setup-homebrew
150-
- uses: ./.github/actions/pristine-homebrew
151-
with:
152-
os: ${{ runner.os }}
153-
restore: false
154137
test-destructive:
155138
strategy:
156139
fail-fast: false
@@ -174,18 +157,16 @@ jobs:
174157
- destructive_others
175158
#os: [macos-latest, ubuntu-latest]
176159
os: [macos-latest]
177-
needs: [prepare-pristine-homebrew]
178160
runs-on: ${{ matrix.os }}
179161
steps:
180162
- uses: actions/checkout@v4
181163
with:
182164
persist-credentials: false
183165
fetch-depth: 0
184166
- uses: ./.github/actions/setup-homebrew
185-
- uses: ./.github/actions/pristine-homebrew
186167
with:
187-
os: ${{ runner.os }}
188-
restore: true
168+
pristine: true
169+
update: true
189170
- name: Set pseudo git user
190171
run: |
191172
git config --global user.name "runner"

tests/scripts/clean_homebrew.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
brew list --formula | xargs brew uninstall --formula --force
44
brew list --cask | xargs brew uninstall --cask --zap --force
55
brew tap | xargs brew untap
6-
7-
rm -rf "$(brew --cache)"

0 commit comments

Comments
 (0)