Skip to content

Commit 1907a7f

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 d3559b5 commit 1907a7f

File tree

1 file changed

+87
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)