test ansible builder #55
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: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test-bot: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-12, macos-13, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
- name: Cache Homebrew Bundler RubyGems | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.set-up-homebrew.outputs.gems-path }} | |
key: ${{ matrix.os }}-${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} | |
restore-keys: ${{ matrix.os }}-${{ runner.os }}-rubygems- | |
- name: Install Homebrew Bundler RubyGems | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: brew install-bundler-gems | |
- name: Set BREWFILE_PATH env var | |
run: | | |
echo "BREWFILE_PATH=${GITHUB_WORKSPACE}/Brewfile.ci" >> "$GITHUB_ENV" | |
- name: Create brewed-bottles dir | |
run: | | |
mkdir "${RUNNER_TEMP}/brewed-bottles" | |
pwd | |
ls -lA "${RUNNER_TEMP}/brewed-bottles" | |
- name: HACK - Bottle go + Force link conflicting go binaries | |
env: | |
HOMEBREW_COLOR: 1 | |
HOMEBREW_DEVELOPER: 1 | |
run: | | |
if [ -e "/usr/local/opt/[email protected]" ]; then | |
brew install --build-bottle go || true | |
brew link --overwrite go | |
brew bottle go | |
# find "${GITHUB_WORKSPACE}" -iname '*.bottle.*' -exec mv '{}' "${RUNNER_TEMP}/brewed-bottles/" \; | |
ls -l "${RUNNER_TEMP}/brewed-bottles/" | |
fi | |
: | |
- name: Install Brewfile.ci dependencies | |
env: | |
HOMEBREW_COLOR: 1 | |
HOMEBREW_DEVELOPER: 1 | |
run: | | |
brew bundle install --file="${BREWFILE_PATH}" | |
- run: brew test-bot --only-cleanup-before | |
- run: brew test-bot --only-setup | |
# Allow our own tap style overrides | |
- run: | | |
sed -i'' -e '/Style\/DisableCopsWithinSourceCodeDirective:/{n;s/.*Enabled: true/ Enabled: false/;}' "$(brew --repository)"/Library/.rubocop.yml | |
- run: brew test-bot --only-tap-syntax | |
- run: | | |
brew test-bot --only-formulae --only-json-tab --skip-recursive-dependents --root-url="https://ghcr.io/v2/LyraPhase/right2repair" | |
if: github.event_name == 'pull_request' | |
- name: Move bottle files | |
run: | | |
find "${GITHUB_WORKSPACE}" -iname '*.bottle.*' -exec mv '{}' "${RUNNER_TEMP}/brewed-bottles/" \; | |
ls -lA "${RUNNER_TEMP}/brewed-bottles/" | |
if: github.event_name == 'pull_request' | |
- name: Upload bottles as artifact | |
if: always() && github.event_name == 'pull_request' | |
uses: actions/upload-artifact@main | |
with: | |
name: bottles_${{ matrix.os }}-${{ runner.arch }} | |
path: '${{ runner.temp }}/brewed-bottles/*.bottle.*' | |
autoreview-check: | |
needs: test-bot | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check triggering user permissions | |
id: check_user_permissions | |
uses: actions-cool/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
username: ${{ github.triggering_actor }} | |
require: admin | |
outputs: | |
authorized: ${{ steps.check_user_permissions.outputs.require-result }} | |
autoreview: | |
if: format('{0}', needs.autoreview-check.outputs.authorized) == 'true' && github.event_name == 'pull_request' && github.event.pull_request.merged != true | |
needs: [test-bot, autoreview-check] | |
runs-on: ubuntu-latest | |
env: | |
PR: ${{ github.event.pull_request.number }} | |
steps: | |
- name: Auto-approve review for admins | |
env: | |
GH_TOKEN: ${{ secrets.LYRAPHASE_RUNNER_PACKAGES_TOKEN }} | |
run: | | |
pr_data="$( | |
gh api \ | |
--header 'Accept: application/vnd.github+json' \ | |
--header 'X-GitHub-Api-Version: 2022-11-28' \ | |
"repos/$GITHUB_REPOSITORY/pulls/$PR" | |
)" | |
state="$(jq --raw-output .state <<< "$pr_data")" | |
merged="$(jq --raw-output .merged <<< "$pr_data")" | |
automerge_enabled="$(jq --raw-output '.auto_merge != null' <<< "$pr_data")" | |
if [[ -z "$state" ]] || | |
[[ -z "$merged" ]] || | |
[[ -z "$automerge_enabled" ]] | |
then | |
echo "::error ::Failed to get PR data!" | |
exit 1 | |
fi | |
if [[ "$state" == "closed" ]]; then | |
echo "::error ::PR #$PR is closed!" | |
exit 1 | |
fi | |
requires_merge=true | |
if [[ "$merged" == "true" || "$automerge_enabled" == "true" ]]; then | |
echo '::notice ::Pull request is either already merged or queued to merge.' | |
requires_merge=false | |
fi | |
if [[ "$requires_merge" == "true" ]]; then | |
gh pr comment "$PR" --body "Auto-approving repo owner PR" --repo "$GITHUB_REPOSITORY" | |
gh pr review --approve "$PR" --repo "$GITHUB_REPOSITORY" | |
fi |