Skip to content

Commit ce221fa

Browse files
committed
[CI] Add a workflow to update the homebrew macs.
1 parent d3559b5 commit ce221fa

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: 'Update Homebrew Macs'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
python_version:
7+
description: "Python version to use for the virtual environment"
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+
OPENJDK_PACKAGE_BREW: openjdk@17
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
path: src/
61+
62+
- name: Update brew packages
63+
run: |
64+
brew update
65+
brew ca-certificates install ccache googletest "${OPENJDK_PACKAGE_BREW}" pyenv "${PYTHON_PACKAGE_BREW}"
66+
echo "Installing official brew deps: $(brew deps --direct --include-build root)"
67+
brew install $(brew deps --direct --include-build root)
68+
69+
- name: Run brew cleanup
70+
run: brew cleanup --prune=7
71+
72+
- name: Display software versions
73+
run: |
74+
java --version || echo "Probably missing the homebrew link for openjdk: sudo ln -sfn $(brew --prefix "${OPENJDK_PACKAGE_BREW}")/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk" && false
75+
cmake --version || echo "Error when checking for cmake" && false
76+
which "${PYTHON_EXECUTABLE}"
77+
"${PYTHON_EXECUTABLE}" --version
78+
79+
- name: Recreate Python venv
80+
run: |
81+
rm -rf ${VENV_DIR}
82+
$(brew --prefix "${PYTHON_PACKAGE_BREW}")/bin/${PYTHON_EXECUTABLE} -m venv "${VENV_DIR}"
83+
source "${VENV_DIR}"/bin/activate
84+
pip3 install --upgrade pip
85+
cat ${{ github.workspace }}/src/requirements.txt | while read PACKAGE; do
86+
if [ -n "${PACKAGE%%#*}" ]; then
87+
PACKAGE="${PACKAGE%%#*}"
88+
pip3 --no-cache-dir install -U "${PACKAGE}" || echo "::error file=update-brew-macs.yml::Could not install package ${PACKAGE}"
89+
fi
90+
done
91+
92+
- name: Purge pip cache
93+
run: ${VENV_DIR}/bin/pip3 cache purge
94+

0 commit comments

Comments
 (0)