Update and Build Formulae #5146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update and Build Formulae | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: '0 0 1-31/2 * *' | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
php_source: | |
description: PHP release source | |
required: false | |
github_message: | |
description: Message to pass optional parameters | |
required: false | |
pull_request: | |
env: | |
HOMEBREW_DEVELOPER: 1 | |
HOMEBREW_GITHUB_ACTIONS: 1 | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALL_FROM_API: 1 | |
HOMEBREW_RELOCATABLE_INSTALL_NAMES: 1 | |
concurrency: | |
group: "build-${{ github.ref }}" | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
tap-syntax: | |
if: "!contains(github.event.head_commit.message, 'skip-build')" | |
runs-on: ubuntu-22.04 | |
container: | |
image: ghcr.io/homebrew/ubuntu22.04:master | |
env: | |
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1 | |
outputs: | |
testing_formulae: ${{ steps.formulae-detect.outputs.testing_formulae }} | |
added_formulae: ${{ steps.formulae-detect.outputs.added_formulae }} | |
deleted_formulae: ${{ steps.formulae-detect.outputs.deleted_formulae }} | |
steps: | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
core: true | |
cask: false | |
test-bot: true | |
- run: brew test-bot --only-tap-syntax | |
- run: brew test-bot --only-formulae-detect | |
if: github.event_name == 'pull_request' | |
id: formulae-detect | |
create-pr: | |
if: github.event_name != 'pull_request' && !contains(github.event.head_commit.message, 'skip-build') | |
needs: tap-syntax | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
php: | |
- 'php' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- 'php-zts' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- 'php-debug' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- 'php-debug-zts' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
- '[email protected]' | |
steps: | |
- name: Print details | |
if: github.event_name == 'workflow_dispatch' | |
run: echo php_source=${{github.event.inputs.php_source}} | |
- uses: actions/checkout@v4 | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
core: false | |
cask: false | |
test-bot: false | |
- name: Patch formula | |
env: | |
GITHUB_MESSAGE: ${{ github.event.head_commit.message || github.event.inputs.github_message }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PHP_VERSION: ${{ matrix.php }} | |
PHP_SOURCE: ${{github.event.inputs.php_source}} | |
run: bash ./.github/scripts/edit.sh | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} | |
commit-message: Update ${{ matrix.php }} | |
committer: BrewTestBot <[email protected]> | |
author: BrewTestBot <[email protected]> | |
signoff: false | |
base: master | |
branch: update-${{ matrix.php }} | |
branch-suffix: short-commit-hash | |
delete-branch: true | |
title: 'Update ${{ matrix.php }}' | |
body: | | |
Build ${{ matrix.php }} | |
labels: ${{ matrix.php }},automated-pr | |
assignees: ${{ github.repository_owner }} | |
draft: false | |
- name: Check outputs | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" | |
set-environment: | |
if: github.event_name == 'pull_request' && !contains(github.event.head_commit.message, 'skip-build') | |
runs-on: ubuntu-22.04 | |
needs: tap-syntax | |
outputs: | |
syntax-only: ${{ steps.check-labels.outputs.syntax-only }} | |
linux-runner: ${{ steps.check-labels.outputs.linux-runner }} | |
fail-fast: ${{ steps.check-labels.outputs.fail-fast }} | |
test-dependents: ${{ steps.check-labels.outputs.test-dependents }} | |
timeout-minutes: ${{ steps.check-labels.outputs.timeout-minutes }} | |
container: ${{ steps.check-labels.outputs.container }} | |
test-bot-formulae-args: ${{ steps.check-labels.outputs.test-bot-formulae-args }} | |
test-bot-dependents-args: ${{ steps.check-labels.outputs.test-bot-dependents-args }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check for CI labels | |
id: check-labels | |
uses: actions/github-script@v7 | |
env: | |
SCRIPTS_PATH: .github/scripts | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const path = require('path') | |
const script = require(path.resolve(`${process.env.SCRIPTS_PATH}/environment.js`)) | |
const formula_detect = { | |
testing_formulae: '${{needs.tap-syntax.outputs.testing_formulae}}', | |
added_formulae: '${{needs.tap-syntax.outputs.added_formulae}}', | |
deleted_formulae: '${{needs.tap-syntax.outputs.deleted_formulae}}' | |
} | |
try { | |
await script({github, context, core}, formula_detect) | |
} catch (error) { | |
console.error(error); | |
} | |
build-formula: | |
needs: set-environment | |
if: github.event_name == 'pull_request' && !contains(github.event.head_commit.message, 'skip-build') | |
strategy: | |
matrix: | |
include: | |
- runner: 'macos-13-arm64' | |
cleanup: true | |
- runner: 'macos-15' | |
cleanup: true | |
- runner: 'macos-14' | |
cleanup: true | |
- runner: 'macos-13' | |
cleanup: true | |
- runner: ${{needs.set-environment.outputs.linux-runner}} | |
container: ${{fromJson(needs.set-environment.outputs.container)}} | |
workdir: /github/home | |
cleanup: false | |
timeout: 4320 | |
fail-fast: ${{fromJson(needs.set-environment.outputs.fail-fast)}} | |
runs-on: ${{matrix.runner}} | |
container: ${{matrix.container}} | |
timeout-minutes: ${{ matrix.timeout || fromJson(needs.set-environment.outputs.timeout-minutes) }} | |
defaults: | |
run: | |
shell: /bin/bash -e {0} | |
working-directory: ${{matrix.workdir || github.workspace}} | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
BOTTLES_DIR: ${{matrix.workdir || github.workspace}}/bottles | |
steps: | |
- name: Pre-test steps | |
uses: Homebrew/actions/pre-build@master | |
with: | |
bottles-directory: ${{ env.BOTTLES_DIR }} | |
cleanup: ${{ matrix.cleanup }} | |
- name: Run brew test-bot ${{ needs.set-environment.outputs.test-bot-formulae-args }} | |
id: brew-test-bot-formulae | |
working-directory: ${{ env.BOTTLES_DIR }} | |
run: | | |
brew test-bot ${{ needs.set-environment.outputs.test-bot-formulae-args }} | |
- name: Post-build steps | |
if: always() | |
uses: Homebrew/actions/post-build@master | |
with: | |
runner: ${{ matrix.runner }} | |
cleanup: ${{ matrix.cleanup }} | |
bottles-directory: ${{ env.BOTTLES_DIR }} | |
logs-directory: ${{ format('{0}/logs', env.BOTTLES_DIR) }} | |
label: | |
needs: build-formula | |
if: github.event_name == 'pull_request' && !contains(github.event.head_commit.message, 'skip-build') && github.event.pull_request.user.login == github.repository_owner | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: "Add Label" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh pr edit "$(echo "$GITHUB_REF" | awk 'BEGIN { FS = "/" } ; { print $3 }')" --add-label "build-complete" |