Move some brew-test-bot logic to GitHub Actions.

This will improve the output and ease of parsing while allowing code to
be removed from brew-test-bot which relates only to a single repo (this
one).
This commit is contained in:
Mike McQuaid 2019-11-21 19:50:23 +00:00
parent 8c6c0039ab
commit 04835db85e
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
6 changed files with 118 additions and 33 deletions

View File

@ -15,12 +15,83 @@ jobs:
- name: Set up Homebrew
run: |
HOMEBREW_REPOSITORY="$(brew --repo)"
mv "$HOMEBREW_REPOSITORY/Library/Taps" "$PWD/Library"
sudo rm -rf "$HOMEBREW_REPOSITORY"
sudo ln -s "$PWD" "$HOMEBREW_REPOSITORY"
brew update-reset Library/Taps/homebrew/homebrew-core
if: matrix.os == 'macOS-latest'
if [ "$RUNNER_OS" = "Linux" ]; then
HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew
sudo mkdir -p /home/linuxbrew
sudo ln -s "$PWD" "$HOMEBREW_REPOSITORY"
sudo chown -R "$USER" /home/linuxbrew
else
HOMEBREW_REPOSITORY="$(brew --repo)"
mv "$HOMEBREW_REPOSITORY/Library/Taps" "$PWD/Library"
sudo rm -rf "$HOMEBREW_REPOSITORY"
sudo ln -s "$PWD" "$HOMEBREW_REPOSITORY"
brew update-reset Library/Taps/homebrew/homebrew-core
# Install taps needed for 'brew tests'
brew tap homebrew/cask
brew tap homebrew/bundle
brew tap homebrew/services
fi
- name: Install Bundler RubyGems
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew install-bundler-gems
# Check for uncommitted gems
git -C $(brew --repo) diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby
if [ "$RUNNER_OS" = "Linux" ]; then
# Fix permissions for 'brew tests'
sudo chmod -R g-w,o-w /home/linuxbrew /home/runner /opt
fi
- name: Run brew tests
run: |
# brew tests doesn't like world writable directories
umask 022
# set variables for coverage reporting
export HOMEBREW_CI_BUILD_NUMBER="$GITHUB_REF"
export HOMEBREW_CI_BRANCH="$HEAD_GITHUB_REF"
export HOMEBREW_GITHUB_REPOSITORY="$GITHUB_REPOSITORY"
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew tests --no-compat --online
brew tests --generic --online
brew tests --online --coverage
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# set variables for coverage reporting
HOMEBREW_GITHUB_ACTIONS: 1
HOMEBREW_CI_NAME: github-actions
HOMEBREW_COVERALLS_REPO_TOKEN: 3F6U6ZqctoNJwKyREremsqMgpU3qYgxFk
# These cannot be queried at the macOS level on GitHub Actions.
HOMEBREW_LANGUAGES: en-GB
- name: Run brew style
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew style
- name: Run brew man
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew man --fail-if-changed
- name: Run brew update-tests
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew update-test
brew update-test --to-tag
brew update-test --commit=HEAD
- name: Run brew readall
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew readall --aliases
- name: Build Docker image
run: |
@ -35,6 +106,3 @@ jobs:
else
brew test-bot
fi
env:
HOMEBREW_COVERALLS_REPO_TOKEN: 3F6U6ZqctoNJwKyREremsqMgpU3qYgxFk
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -15,21 +15,3 @@ services:
/home/linuxbrew/.linuxbrew/bin/brew test-bot
status=$$?
exit $$status
environment:
# GitHub Actions
- GITHUB_ACTIONS
- GITHUB_BASE_REF
- GITHUB_EVENT_NAME
- GITHUB_REF
- GITHUB_REPOSITORY
- GITHUB_SHA
- HEAD_GITHUB_REF
# Azure Pipelines
- BUILD_REASON
- BUILD_REPOSITORY_URI
- BUILD_SOURCEVERSION
- SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
- SYSTEM_PULLREQUEST_TARGETBRANCH
- TF_BUILD
# GitHub API
- HOMEBREW_GITHUB_API_TOKEN

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
require "formula"
require "cli/parser"
module Homebrew
module_function
def install_bundler_gems_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`install-bundler-gems`
Install Homebrew's Bundler gems.
EOS
switch :debug
end
end
def install_bundler_gems
install_bundler_gems_args.parse
Homebrew.install_bundler_gems!
end
end

View File

@ -4,7 +4,7 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
require "simplecov"
formatters = [SimpleCov::Formatter::HTMLFormatter]
if ENV["HOMEBREW_COVERALLS_REPO_TOKEN"]
if ENV["HOMEBREW_COVERALLS_REPO_TOKEN"] && RUBY_PLATFORM[/darwin/]
require "coveralls"
Coveralls::Output.no_color if !ENV["HOMEBREW_COLOR"] && (ENV["HOMEBREW_NO_COLOR"] || !$stdout.tty?)
@ -19,12 +19,15 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
end
ENV["CI_NAME"] = ENV["HOMEBREW_CI_NAME"]
ENV["CI_JOB_ID"] = ENV["TEST_ENV_NUMBER"] || "1"
ENV["CI_BUILD_NUMBER"] = ENV["HOMEBREW_CI_BUILD_NUMBER"]
ENV["CI_BUILD_URL"] = ENV["HOMEBREW_CI_BUILD_URL"]
ENV["CI_BRANCH"] = ENV["HOMEBREW_CI_BRANCH"]
ENV["CI_PULL_REQUEST"] = ENV["HOMEBREW_CI_PULL_REQUEST"]
ENV["COVERALLS_REPO_TOKEN"] = ENV["HOMEBREW_COVERALLS_REPO_TOKEN"]
ENV["CI_BUILD_NUMBER"] = ENV["HOMEBREW_CI_BUILD_NUMBER"]
ENV["CI_BRANCH"] = ENV["HOMEBREW_CI_BRANCH"]
%r{refs/pull/(?<pr>\d+)/merge} =~ ENV["HOMEBREW_CI_BUILD_NUMBER"]
ENV["CI_PULL_REQUEST"] = pr
ENV["CI_BUILD_URL"] = "https://github.com/#{ENV["HOMEBREW_GITHUB_REPOSITORY"]}/pull/#{pr}/checks"
ENV["CI_JOB_ID"] = ENV["TEST_ENV_NUMBER"] || "1"
end
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)

View File

@ -840,6 +840,10 @@ formula from a tap that is not `homebrew/core` use its fully-qualified form of
Display the path where *`formula`* is located.
### `install-bundler-gems`
Install Homebrew's Bundler gems.
### `irb` [*`options`*]
Enter the interactive Homebrew Ruby shell.

View File

@ -1068,6 +1068,9 @@ Extract the specified \fIversion\fR of \fIformula\fR instead of the most recent\
.SS "\fBformula\fR \fIformula\fR"
Display the path where \fIformula\fR is located\.
.
.SS "\fBinstall\-bundler\-gems\fR"
Install Homebrew\'s Bundler gems\.
.
.SS "\fBirb\fR [\fIoptions\fR]"
Enter the interactive Homebrew Ruby shell\.
.