2021-10-25 03:11:55 +00:00
|
|
|
name: Dispatch build bottle (for chosen OS versions)
|
2020-10-11 11:05:10 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
2021-06-25 18:24:26 +00:00
|
|
|
runner:
|
2021-10-25 03:11:55 +00:00
|
|
|
description: Build runner(s) (macOS version or Linux)
|
2020-10-11 11:05:10 +00:00
|
|
|
required: true
|
|
|
|
formula:
|
|
|
|
description: Formula name
|
|
|
|
required: true
|
2021-07-08 13:17:21 +00:00
|
|
|
timeout:
|
|
|
|
description: "Build timeout (in minutes, default: 60 minutes)"
|
|
|
|
default: "60"
|
|
|
|
required: true
|
2020-10-11 11:05:10 +00:00
|
|
|
issue:
|
|
|
|
description: Issue number, where comment on failure would be posted
|
|
|
|
required: false
|
|
|
|
upload:
|
2021-04-12 12:23:38 +00:00
|
|
|
description: "Whether to upload built bottles or not (default: false)"
|
2020-10-11 11:05:10 +00:00
|
|
|
required: false
|
2021-06-25 18:24:26 +00:00
|
|
|
wheezy:
|
|
|
|
description: Whether to build the bottle in Debian Wheezy container
|
|
|
|
required: false
|
2020-10-11 11:05:10 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
HOMEBREW_DEVELOPER: 1
|
|
|
|
HOMEBREW_GITHUB_ACTIONS: 1
|
|
|
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
2020-12-05 19:31:07 +00:00
|
|
|
HOMEBREW_CHANGE_ARCH_TO_ARM: 1
|
2020-10-11 11:05:10 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-10-25 03:11:55 +00:00
|
|
|
prepare:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
runners: ${{steps.runner-matrix.outputs.result}}
|
|
|
|
steps:
|
|
|
|
- name: Prepare runner matrix
|
|
|
|
id: runner-matrix
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
return context.payload.inputs.runner.split(",")
|
|
|
|
.map(s => s.trim())
|
|
|
|
.filter(Boolean);
|
2020-10-11 11:05:10 +00:00
|
|
|
bottle:
|
2021-10-25 03:11:55 +00:00
|
|
|
needs: prepare
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
runner: ${{fromJson(needs.prepare.outputs.runners)}}
|
|
|
|
runs-on: ${{matrix.runner}}
|
2021-07-08 13:17:21 +00:00
|
|
|
timeout-minutes: ${{fromJson(github.event.inputs.timeout)}}
|
2021-07-01 05:32:39 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: /bin/bash -e {0}
|
2020-10-11 11:05:10 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
2021-06-25 18:24:26 +00:00
|
|
|
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
2020-10-11 11:05:10 +00:00
|
|
|
steps:
|
2020-11-15 08:17:00 +00:00
|
|
|
- name: ${{github.event.inputs.formula}}
|
2020-11-15 08:04:59 +00:00
|
|
|
id: print_details
|
|
|
|
run: |
|
|
|
|
echo sender=${{github.event.sender.login}}
|
|
|
|
echo formula=${{github.event.inputs.formula}}
|
2021-06-25 18:24:26 +00:00
|
|
|
echo runner=${{github.event.inputs.runner}}
|
2021-10-28 12:50:40 +00:00
|
|
|
echo timeout=${{github.event.inputs.timeout}}
|
2020-11-15 08:04:59 +00:00
|
|
|
echo issue=${{github.event.inputs.issue}}
|
|
|
|
echo upload=${{github.event.inputs.upload}}
|
2021-06-25 18:24:26 +00:00
|
|
|
echo wheezy=${{github.event.inputs.wheezy}}
|
|
|
|
|
|
|
|
- name: Set environment variables
|
2021-12-14 19:09:41 +00:00
|
|
|
if: runner.os == 'macOS'
|
2021-06-25 18:24:26 +00:00
|
|
|
run: |
|
2021-12-14 19:09:41 +00:00
|
|
|
echo 'PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' >> $GITHUB_ENV
|
|
|
|
# TODO: remove the line below once set in the runner .env file
|
|
|
|
echo 'GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED=1' >> $GITHUB_ENV
|
2020-11-15 08:04:59 +00:00
|
|
|
|
2021-06-25 18:24:26 +00:00
|
|
|
- name: Run Docker container
|
|
|
|
if: runner.os == 'Linux'
|
2021-07-08 13:17:21 +00:00
|
|
|
env:
|
|
|
|
TAP_PATH: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core
|
2021-06-25 18:24:26 +00:00
|
|
|
run: |
|
|
|
|
docker run \
|
|
|
|
--detach \
|
|
|
|
--user linuxbrew \
|
|
|
|
--name ${{github.sha}} \
|
|
|
|
--env-file <(env | egrep 'HOMEBREW|GITHUB') \
|
|
|
|
--workdir /tmp/bottles \
|
2021-06-29 21:37:14 +00:00
|
|
|
--pull always \
|
2021-06-25 18:32:08 +00:00
|
|
|
${{github.event.inputs.wheezy && 'homebrew/debian7:latest' || 'ghcr.io/homebrew/ubuntu16.04:master'}} \
|
2021-06-25 18:24:26 +00:00
|
|
|
sleep inf
|
|
|
|
# Fix working directory permissions
|
|
|
|
docker exec --user root ${{github.sha}} chmod 777 /tmp/bottles
|
|
|
|
|
|
|
|
docker exec --workdir "$TAP_PATH" ${{github.sha}} git remote set-url origin ${{github.event.repository.html_url}}
|
|
|
|
docker exec --workdir "$TAP_PATH" ${{github.sha}} git fetch origin ${{github.sha}} '+refs/heads/*:refs/remotes/origin/*'
|
|
|
|
docker exec --workdir "$TAP_PATH" ${{github.sha}} git remote set-head origin --auto
|
|
|
|
docker exec --workdir "$TAP_PATH" ${{github.sha}} git checkout --force -B master FETCH_HEAD
|
|
|
|
|
2021-06-27 16:18:10 +00:00
|
|
|
- name: Set up Homebrew
|
|
|
|
id: set-up-homebrew
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
uses: Homebrew/actions/setup-homebrew@master
|
|
|
|
|
|
|
|
- if: runner.os == 'macOS'
|
|
|
|
run: brew test-bot --only-cleanup-before
|
|
|
|
|
|
|
|
- name: Run brew test-bot --only-setup
|
|
|
|
run: |
|
|
|
|
if [ "$RUNNER_OS" = 'macOS' ]; then
|
|
|
|
brew test-bot --only-setup
|
|
|
|
else
|
|
|
|
docker exec ${{github.sha}} brew test-bot --only-setup
|
|
|
|
fi
|
|
|
|
|
2021-11-12 12:29:25 +00:00
|
|
|
- name: Run brew test-bot --only-formulae --keep-old --only-json-tab --skip-online-checks --skip-dependents ${{github.event.inputs.formula}}
|
2021-06-25 18:24:26 +00:00
|
|
|
run: |
|
|
|
|
if [ "$RUNNER_OS" = 'macOS' ]; then
|
|
|
|
mkdir bottles
|
|
|
|
cd bottles
|
2021-11-12 12:29:25 +00:00
|
|
|
brew test-bot --only-formulae --keep-old --only-json-tab --skip-online-checks --skip-dependents ${{github.event.inputs.formula}}
|
2021-06-25 18:24:26 +00:00
|
|
|
else
|
2021-11-12 12:29:25 +00:00
|
|
|
docker exec ${{github.sha}} brew test-bot --only-formulae --keep-old --only-json-tab --skip-online-checks --skip-dependents ${{github.event.inputs.formula}}
|
2021-06-25 18:24:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Copy bottles from container
|
|
|
|
if: always() && runner.os == 'Linux'
|
|
|
|
run: docker cp ${{github.sha}}:/tmp/bottles .
|
2020-10-11 11:05:10 +00:00
|
|
|
|
2021-07-08 18:14:12 +00:00
|
|
|
- name: Failures summary for brew test-bot --only-formulae
|
2020-10-11 11:05:10 +00:00
|
|
|
if: always()
|
|
|
|
run: |
|
2021-07-08 18:14:12 +00:00
|
|
|
touch bottles/steps_output.txt
|
2020-10-11 11:05:10 +00:00
|
|
|
cat bottles/steps_output.txt
|
|
|
|
rm bottles/steps_output.txt
|
|
|
|
|
2021-05-04 19:33:35 +00:00
|
|
|
- name: Output brew bottle result
|
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
cat bottles/bottle_output.txt
|
|
|
|
rm bottles/bottle_output.txt
|
|
|
|
|
2020-10-11 11:05:10 +00:00
|
|
|
- name: Upload logs
|
2022-01-30 14:46:45 +00:00
|
|
|
if: always()
|
2020-10-11 11:05:10 +00:00
|
|
|
uses: actions/upload-artifact@main
|
|
|
|
with:
|
|
|
|
name: logs
|
|
|
|
path: bottles/logs
|
|
|
|
|
|
|
|
- name: Delete logs and home
|
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
rm -rvf bottles/logs
|
|
|
|
rm -rvf bottles/home
|
|
|
|
|
|
|
|
- name: Count bottles
|
|
|
|
id: bottles
|
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
cd bottles
|
|
|
|
count=$(ls *.json | wc -l | xargs echo -n)
|
|
|
|
echo "$count bottles"
|
|
|
|
echo "::set-output name=count::$count"
|
2021-10-28 12:50:40 +00:00
|
|
|
failures=$(ls failed/*.json | wc -l | xargs echo -n)
|
|
|
|
echo "$failures failed bottles"
|
|
|
|
echo "::set-output name=failures::$failures"
|
|
|
|
|
|
|
|
- name: Upload failed bottles
|
|
|
|
if: always() && steps.bottles.outputs.failures > 0
|
|
|
|
uses: actions/upload-artifact@main
|
|
|
|
with:
|
|
|
|
name: bottles-${{ matrix.runner }}
|
|
|
|
path: bottles/failed
|
|
|
|
|
|
|
|
# Must be run before the `Upload bottles` step so that failed
|
|
|
|
# bottles are not included in the `bottles` artifact.
|
|
|
|
- name: Delete failed bottles
|
|
|
|
if: always()
|
|
|
|
run: rm -rvf bottles/failed
|
2020-10-11 11:05:10 +00:00
|
|
|
|
2020-10-12 08:23:31 +00:00
|
|
|
- name: Upload bottles to GitHub Actions
|
2020-10-11 11:05:10 +00:00
|
|
|
if: always() && steps.bottles.outputs.count > 0
|
|
|
|
uses: actions/upload-artifact@main
|
|
|
|
with:
|
|
|
|
name: bottles
|
|
|
|
path: bottles
|
|
|
|
|
2021-06-25 18:24:26 +00:00
|
|
|
- name: Post cleanup
|
2020-10-15 11:03:54 +00:00
|
|
|
if: always()
|
2021-06-25 18:24:26 +00:00
|
|
|
run: |
|
|
|
|
if [ "$RUNNER_OS" = 'Linux' ]; then
|
|
|
|
docker rm -f ${{github.sha}}
|
|
|
|
else
|
|
|
|
brew test-bot --only-cleanup-after
|
|
|
|
fi
|
|
|
|
rm -rvf bottles
|
2020-11-14 10:59:50 +00:00
|
|
|
|
|
|
|
- name: Post comment on failure
|
2020-11-14 11:50:46 +00:00
|
|
|
if: ${{!success() && github.event.inputs.issue > 0}}
|
2020-11-14 10:59:50 +00:00
|
|
|
uses: Homebrew/actions/post-comment@master
|
|
|
|
with:
|
2021-04-06 12:40:44 +00:00
|
|
|
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
|
2020-11-14 10:59:50 +00:00
|
|
|
issue: ${{github.event.inputs.issue}}
|
2021-03-18 13:16:54 +00:00
|
|
|
body: ":x: @${{github.actor}} bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
|
|
|
|
bot_body: ":x: Bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
|
2020-11-14 10:59:50 +00:00
|
|
|
bot: BrewTestBot
|
2020-10-15 11:03:54 +00:00
|
|
|
upload:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: bottle
|
|
|
|
if: github.event.inputs.upload
|
2020-11-14 09:45:52 +00:00
|
|
|
env:
|
2021-06-27 16:18:10 +00:00
|
|
|
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
|
2020-10-15 11:03:54 +00:00
|
|
|
steps:
|
|
|
|
- name: Set up Homebrew
|
|
|
|
id: set-up-homebrew
|
|
|
|
uses: Homebrew/actions/setup-homebrew@master
|
|
|
|
|
|
|
|
- name: Download bottles from GitHub Actions
|
|
|
|
uses: actions/download-artifact@main
|
|
|
|
with:
|
|
|
|
name: bottles
|
2020-11-14 09:14:02 +00:00
|
|
|
path: ~/bottles/
|
2020-10-15 11:03:54 +00:00
|
|
|
|
2021-06-27 17:02:21 +00:00
|
|
|
# Workaround until the `cache` action uses the changes from
|
|
|
|
# https://github.com/actions/toolkit/pull/580.
|
|
|
|
- name: Unlink workspace
|
|
|
|
run: |
|
|
|
|
mv "${GITHUB_WORKSPACE}" "${GITHUB_WORKSPACE}-link"
|
|
|
|
mkdir "${GITHUB_WORKSPACE}"
|
|
|
|
|
|
|
|
- name: Cache gems
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ${{steps.set-up-homebrew.outputs.gems-path}}
|
|
|
|
key: ${{runner.os}}-rubygems-v2-${{steps.set-up-homebrew.outputs.gems-hash}}
|
|
|
|
restore-keys: ${{runner.os}}-rubygems-v2-
|
|
|
|
|
|
|
|
# Workaround until the `cache` action uses the changes from
|
|
|
|
# https://github.com/actions/toolkit/pull/580.
|
|
|
|
- name: Re-link workspace
|
|
|
|
run: |
|
|
|
|
rmdir "${GITHUB_WORKSPACE}"
|
|
|
|
mv "${GITHUB_WORKSPACE}-link" "${GITHUB_WORKSPACE}"
|
|
|
|
|
|
|
|
- name: Install gems
|
|
|
|
run: brew install-bundler-gems
|
|
|
|
|
|
|
|
- name: Configure Git user
|
2020-10-11 11:05:10 +00:00
|
|
|
uses: Homebrew/actions/git-user-config@master
|
|
|
|
|
2021-04-01 21:36:14 +00:00
|
|
|
- name: Set up commit signing
|
|
|
|
uses: Homebrew/actions/setup-commit-signing@master
|
|
|
|
with:
|
|
|
|
signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}
|
|
|
|
|
2021-04-08 15:29:54 +00:00
|
|
|
- name: Upload bottles to GitHub Packages
|
2020-10-11 11:05:10 +00:00
|
|
|
env:
|
2021-04-08 15:29:54 +00:00
|
|
|
HOMEBREW_GITHUB_PACKAGES_USER: brewtestbot
|
|
|
|
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.HOMEBREW_CORE_GITHUB_PACKAGES_TOKEN}}
|
2021-04-01 21:36:14 +00:00
|
|
|
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
|
|
|
|
BREWTESTBOT_NAME_EMAIL: "BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>"
|
2020-11-14 09:14:02 +00:00
|
|
|
run: |
|
|
|
|
cd ~/bottles
|
2021-04-08 15:29:54 +00:00
|
|
|
brew pr-upload --verbose --keep-old --committer="$BREWTESTBOT_NAME_EMAIL" --root-url="https://ghcr.io/v2/homebrew/core"
|
2020-10-11 11:05:10 +00:00
|
|
|
|
2021-04-02 15:56:24 +00:00
|
|
|
- name: Push commits
|
|
|
|
uses: Homebrew/actions/git-try-push@master
|
|
|
|
with:
|
2021-04-06 12:40:44 +00:00
|
|
|
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
|
2021-04-03 13:30:43 +00:00
|
|
|
env:
|
|
|
|
GIT_COMMITTER_NAME: BrewTestBot
|
|
|
|
GIT_COMMITTER_EMAIL: 1589480+BrewTestBot@users.noreply.github.com
|
|
|
|
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
|
2021-04-02 15:56:24 +00:00
|
|
|
|
2020-10-11 11:05:10 +00:00
|
|
|
- name: Post comment on failure
|
2020-11-14 11:50:46 +00:00
|
|
|
if: ${{!success() && github.event.inputs.issue > 0}}
|
2020-10-11 11:05:10 +00:00
|
|
|
uses: Homebrew/actions/post-comment@master
|
|
|
|
with:
|
2021-04-06 12:40:44 +00:00
|
|
|
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
|
2020-10-11 11:05:10 +00:00
|
|
|
issue: ${{github.event.inputs.issue}}
|
2021-03-18 13:16:54 +00:00
|
|
|
body: ":x: @${{github.actor}} bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
|
|
|
|
bot_body: ":x: Bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
|
2020-10-11 11:05:10 +00:00
|
|
|
bot: BrewTestBot
|
2021-06-27 17:02:21 +00:00
|
|
|
|
|
|
|
# Workaround until the `cache` action uses the changes from
|
|
|
|
# https://github.com/actions/toolkit/pull/580.
|
|
|
|
- name: Unlink workspace
|
|
|
|
run: |
|
|
|
|
rm "${GITHUB_WORKSPACE}"
|
|
|
|
mkdir "${GITHUB_WORKSPACE}"
|