Skip to content

Commit 2499a5e

Browse files
committed
[CI] Add a workflow to update the homebrew macs.
Add a new yml to run a brew update and create a python virtual environment containing the packages from ROOT's requirements.txt
1 parent ac5e7e9 commit 2499a5e

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
pull_request:
19+
branches:
20+
- 'master'
21+
env:
22+
VENV_DIR: ${{ github.workspace }}/ROOT_CI_VENV
23+
24+
jobs:
25+
update-macos:
26+
if: github.repository_owner == 'root-project'
27+
28+
permissions:
29+
contents: read
30+
31+
# Use login shells to have brew and java available
32+
defaults:
33+
run:
34+
shell: bash -leo pipefail {0}
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
runner-label: [ experimental-brew-ci, experimental-brew-ci-2 ]
40+
41+
runs-on:
42+
- 'self-hosted'
43+
- ${{ matrix.runner-label }}
44+
45+
name: Update homebrew and Python
46+
47+
env:
48+
PYTHON_PACKAGE_BREW: ${{ format('python@{0}', inputs.python_version != '' && inputs.python_version || 3.12 ) }}
49+
PYTHON_EXECUTABLE: ${{ format('python{0}', inputs.python_version != '' && inputs.python_version || 3.12 ) }}
50+
OPENJDK_PACKAGE_BREW: openjdk@17
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
with:
56+
path: src/
57+
58+
- name: Update brew packages
59+
run: |
60+
brew update
61+
brew install ca-certificates ccache googletest "${OPENJDK_PACKAGE_BREW}" pyenv "${PYTHON_PACKAGE_BREW}"
62+
echo "Installing official brew deps: $(brew deps --direct --include-build root)"
63+
brew install $(brew deps --direct --include-build root)
64+
65+
- name: Run brew cleanup
66+
run: brew cleanup --prune=7
67+
68+
- name: Display software versions
69+
run: |
70+
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; }
71+
cmake --version || { echo "Error when checking for cmake"; false; }
72+
which "${PYTHON_EXECUTABLE}"
73+
"${PYTHON_EXECUTABLE}" --version
74+
75+
- name: Recreate Python venv
76+
run: |
77+
rm -rf ${VENV_DIR}
78+
$(brew --prefix "${PYTHON_PACKAGE_BREW}")/bin/${PYTHON_EXECUTABLE} -m venv "${VENV_DIR}"
79+
source "${VENV_DIR}"/bin/activate
80+
pip3 install --upgrade pip
81+
while read -r PACKAGE; do
82+
PACKAGE="${PACKAGE%%#*}" # Skip comments
83+
if [ -n "${PACKAGE}" ]; then
84+
pip3 --no-cache-dir install -U "${PACKAGE}" || echo "::error file=update-brew-macs.yml::Could not install package ${PACKAGE}"
85+
fi
86+
done < ${{ github.workspace }}/src/requirements.txt
87+
88+
- name: Purge pip cache
89+
run: ${VENV_DIR}/bin/pip3 cache purge
90+

0 commit comments

Comments
 (0)