|
| 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 | + |
| 44 | + runs-on: |
| 45 | + - 'self-hosted' |
| 46 | + - ${{ matrix.runner-label }} |
| 47 | + |
| 48 | + name: Update homebrew and Python |
| 49 | + |
| 50 | + env: |
| 51 | + PYTHON_PACKAGE_BREW: ${{ format('python@{0}', inputs.python_version != '' && inputs.python_version || 3.12 ) }} |
| 52 | + PYTHON_EXECUTABLE: ${{ format('python{0}', inputs.python_version != '' && inputs.python_version || 3.12 ) }} |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + path: src/ |
| 59 | + |
| 60 | + - name: Install homebrew |
| 61 | + run: brew --version || NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 62 | + |
| 63 | + - name: Update brew packages |
| 64 | + run: | |
| 65 | + brew update |
| 66 | + brew install ccache googletest openjdk pyenv "${PYTHON_PACKAGE_BREW}" |
| 67 | + echo "Installing official brew deps: $(brew deps --direct --include-build root)" |
| 68 | + brew install $(brew deps --direct --include-build root) |
| 69 | +
|
| 70 | + - name: Run brew cleanup |
| 71 | + run: brew cleanup --prune=7 |
| 72 | + |
| 73 | + - name: Display software versions |
| 74 | + run: | |
| 75 | + java --version |
| 76 | + cmake --version |
| 77 | + which "${PYTHON_EXECUTABLE}" |
| 78 | + "${PYTHON_EXECUTABLE}" --version |
| 79 | +
|
| 80 | + - name: Recreate Python venv |
| 81 | + run: | |
| 82 | + rm -rf ${VENV_DIR} |
| 83 | + $(brew --prefix "${PYTHON_PACKAGE_BREW}")/bin/${PYTHON_EXECUTABLE} -m venv "${VENV_DIR}" |
| 84 | + source "${VENV_DIR}"/bin/activate |
| 85 | + pip3 install --upgrade pip |
| 86 | + cat ${{ github.workspace }}/src/requirements.txt | while read PACKAGE; do |
| 87 | + if [ -n "${PACKAGE%%#*}" ]; then |
| 88 | + PACKAGE="${PACKAGE%%#*}" |
| 89 | + pip3 --no-cache-dir install -U "${PACKAGE}" || echo "::error file=update-brew-macs.yml::Could not install package ${PACKAGE}" |
| 90 | + fi |
| 91 | + done |
| 92 | +
|
| 93 | + - name: Purge pip cache |
| 94 | + run: ${VENV_DIR}/bin/pip3 cache purge |
| 95 | + |
0 commit comments