Skip to content

Commit 5c62b0b

Browse files
committed
[CI] Add a workflow to update the homebrew macs.
1 parent 043327d commit 5c62b0b

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: 'Update Homebrew Macs'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
python_version:
7+
description: "Python version base the virtual environment on"
8+
type: string
9+
required: true
10+
default: 3.12
11+
12+
push:
13+
branches:
14+
- 'master'
15+
paths:
16+
- '.github/workflow/update-brew-macs.yml'
17+
18+
#TODO: Remove the below
19+
pull_request:
20+
branches:
21+
- 'master'
22+
23+
env:
24+
VENV_DIR: ${{ github.workspace }}/ROOT_CI_VENV
25+
26+
jobs:
27+
update-macos:
28+
if: github.repository_owner == 'root-project'
29+
30+
permissions:
31+
contents: read
32+
33+
# Use login shells to have brew and java available
34+
defaults:
35+
run:
36+
shell: bash -leo pipefail {0}
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- runner-label: experimental-brew-ci
43+
- runner-label: experimental-brew-ci-2
44+
45+
runs-on:
46+
- 'self-hosted'
47+
- ${{ matrix.runner-label }}
48+
49+
name: Update homebrew and Python
50+
51+
env:
52+
PYTHON_PACKAGE_BREW: ${{ format('python@{0}', inputs.python_version != '' && inputs.python_version || 3.12 ) }}
53+
PYTHON_EXECUTABLE: ${{ format('python{0}', inputs.python_version != '' && inputs.python_version || 3.12 ) }}
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
with:
59+
path: src/
60+
61+
- name: Install homebrew
62+
run: brew --version || NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
63+
64+
- name: Update brew packages
65+
run: |
66+
brew update
67+
brew install ccache googletest openjdk pyenv "${PYTHON_PACKAGE_BREW}"
68+
echo "Installing official brew deps: $(brew deps --direct --include-build root)"
69+
brew install $(brew deps --direct --include-build root)
70+
71+
- name: Run brew cleanup
72+
run: brew cleanup --prune=7
73+
74+
- name: Display software versions
75+
run: |
76+
java --version
77+
cmake --version
78+
which "${PYTHON_EXECUTABLE}"
79+
"${PYTHON_EXECUTABLE}" --version
80+
81+
- name: Recreate Python venv
82+
run: |
83+
rm -rf ${VENV_DIR}
84+
$(brew --prefix "${PYTHON_PACKAGE_BREW}")/bin/${PYTHON_EXECUTABLE} -m venv "${VENV_DIR}"
85+
source "${VENV_DIR}"/bin/activate
86+
pip3 install --upgrade pip
87+
cat ${{ github.workspace }}/src/requirements.txt | while read PACKAGE; do
88+
if [ -n "${PACKAGE%%#*}" ]; then
89+
PACKAGE="${PACKAGE%%#*}"
90+
pip3 --no-cache-dir install -U "${PACKAGE}" || echo "::error file=update-brew-macs.yml::Could not install package ${PACKAGE}"
91+
fi
92+
done
93+
94+
- name: Purge pip cache
95+
run: ${VENV_DIR}/bin/pip3 cache purge
96+

0 commit comments

Comments
 (0)