Fix tests; update docs #188
Workflow file for this run
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: brew test-bot | |
on: | |
workflow_dispatch: | |
inputs: | |
checkout_ref: | |
description: 'Ref to checkout' | |
required: true | |
type: string | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [ "opened", "reopened", "synchronize", "ready_for_review" ] | |
branches: [ "main" ] | |
jobs: | |
test-bot: | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, macos-13, macos-14] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Determine Checkout Ref | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' | |
run: | | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
echo "checkout ref is ${{ github.event.pull_request.head.ref }} from pull_request" | |
echo "checkout_ref=${{ github.event.pull_request.head.ref }}" >> "$GITHUB_ENV" | |
else | |
echo "checkout ref is ${{ github.event.inputs.checkout_ref }} from dispatch" | |
echo "checkout_ref=${{ github.event.inputs.checkout_ref }}" >> "$GITHUB_ENV" | |
fi | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
if: ${{ env.checkout_ref != '' }} | |
with: | |
ref: ${{ env.checkout_ref }} | |
fetch-depth: 0 # Required for brew test-bot to detect changes | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
- name: Find changed versioned mkectl formulas | |
id: find_versions | |
if: ${{ env.checkout_ref != '' }} | |
run: | | |
versions=$(git diff --name-only origin/main ${{ github.sha }} | grep -oE 'Formula/mkectl@[0-9.]+' | sed 's/Formula\/mkectl@//') | |
echo "Versions changed: $versions" | |
echo "versions=$versions" >> "GITHUB_OUTPUT" | |
- name: Cache Homebrew Bundler RubyGems | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.set-up-homebrew.outputs.gems-path }} | |
key: ${{ matrix.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} | |
restore-keys: ${{ matrix.os }}-rubygems- | |
- run: | | |
brew test-bot --only-cleanup-before | tee brew_test_log.txt | |
if grep -q "Warning: 1 failed step ignored!" brew_test_log.txt; then | |
echo "Test failed. Exiting with failure." | |
exit 1 | |
fi | |
- run: | | |
brew test-bot --only-setup | tee brew_test_log.txt | |
if grep -q "Warning: 1 failed step ignored!" brew_test_log.txt; then | |
echo "Test failed. Exiting with failure." | |
exit 1 | |
fi | |
- run: | | |
brew test-bot --only-tap-syntax | tee brew_test_log.txt | |
- if: ${{ env.checkout_ref != '' }} | |
run: | | |
brew test-bot --only-formulae mkectl | tee brew_test_log.txt | |
if grep -q "Warning: 1 failed step ignored!" brew_test_log.txt; then | |
echo "Test failed. Exiting with failure." | |
exit 1 | |
fi | |
- name: Run pr-pull for each changed version | |
if: ${{ env.checkout_ref != '' }} && steps.find_versions.outputs.versions != '' | |
run: | | |
versions=${{ steps.find_versions.outputs.versions }} | |
for version in $versions; do | |
echo "Running test-bot for mkectl@$version" | |
brew test-bot --only-formulae mkectl@$version | tee brew_test_log.txt | |
done | |
- name: Upload bottles as artifact | |
uses: actions/upload-artifact@v4 | |
if: ${{ env.checkout_ref != '' }} | |
with: | |
name: bottles_${{ matrix.os }} | |
path: '*.bottle.*' |