Merge branch 'master' into man-page-text

This commit is contained in:
Mike McQuaid 2019-08-20 14:42:24 +01:00 committed by GitHub
commit c1960b2fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 77 deletions

38
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: GitHub Actions CI
on:
push:
branches: master
pull_request: []
jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- name: Set up Git repository
uses: actions/checkout@master
- 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'
- name: Build Docker image
run: docker-compose -f Dockerfile.yml build sut
if: matrix.os == 'ubuntu-latest'
- name: Run brew test-bot
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
docker-compose -f Dockerfile.yml run --rm -v $GITHUB_WORKSPACE:/tmp/test-bot sut
else
brew test-bot
fi
env:
HOMEBREW_COVERALLS_REPO_TOKEN: ${{ secrets.HOMEBREW_COVERALLS_REPO_TOKEN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -4,16 +4,24 @@ sut:
- sh - sh
- -xc - -xc
- | - |
sudo -E -u linuxbrew /home/linuxbrew/.linuxbrew/bin/brew test-bot /home/linuxbrew/.linuxbrew/bin/brew test-bot
status=$$? status=$$?
cp brew-test-bot.xml /tmp/test-bot/
exit $$status exit $$status
environment: environment:
- HOME=/home/linuxbrew # GitHub Actions
- GITHUB_ACTIONS
- GITHUB_BASE_REF
- GITHUB_EVENT_NAME
- GITHUB_REF
- GITHUB_REPOSITORY
- GITHUB_SHA
- HEAD_GITHUB_REF
# Azure Pipelines
- BUILD_REASON - BUILD_REASON
- BUILD_REPOSITORY_URI - BUILD_REPOSITORY_URI
- BUILD_SOURCEVERSION - BUILD_SOURCEVERSION
- HOMEBREW_GITHUB_API_TOKEN
- SYSTEM_PULLREQUEST_PULLREQUESTNUMBER - SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
- SYSTEM_PULLREQUEST_TARGETBRANCH - SYSTEM_PULLREQUEST_TARGETBRANCH
- TF_BUILD - TF_BUILD
# GitHub API
- HOMEBREW_GITHUB_API_TOKEN

View File

@ -46,19 +46,24 @@ module Homebrew
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
elsif args.to_tag? elsif args.to_tag?
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname") tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
previous_tag = tags.lines.second if tags.blank?
previous_tag ||= begin tags = if (HOMEBREW_REPOSITORY/".git/shallow").exist?
if (HOMEBREW_REPOSITORY/".git/shallow").exist?
safe_system "git", "fetch", "--tags", "--depth=1" safe_system "git", "fetch", "--tags", "--depth=1"
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname") Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
elsif OS.linux? elsif OS.linux?
tags = Utils.popen_read("git tag --list | sort -rV") Utils.popen_read("git tag --list | sort -rV")
end end
tags.lines.second
end end
current_tag, previous_tag, = tags.lines
current_tag = current_tag.to_s.chomp
odie "Could not find current tag in:\n#{tags}" if current_tag.empty?
# ^0 ensures this points to the commit rather than the tag object.
end_commit = "#{current_tag}^0"
previous_tag = previous_tag.to_s.chomp previous_tag = previous_tag.to_s.chomp
odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty? odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty?
previous_tag # ^0 ensures this points to the commit rather than the tag object.
"#{previous_tag}^0"
else else
Utils.popen_read("git", "rev-parse", "origin/master").chomp Utils.popen_read("git", "rev-parse", "origin/master").chomp
end end
@ -67,8 +72,13 @@ module Homebrew
start_commit = Utils.popen_read("git", "rev-parse", start_commit).chomp start_commit = Utils.popen_read("git", "rev-parse", start_commit).chomp
odie "Could not find start commit!" if start_commit.empty? odie "Could not find start commit!" if start_commit.empty?
end_commit = Utils.popen_read("git", "rev-parse", "HEAD").chomp end_commit ||= "HEAD"
end_commit = Utils.popen_read("git", "rev-parse", end_commit).chomp
odie "Could not find end commit!" if end_commit.empty? odie "Could not find end commit!" if end_commit.empty?
if Utils.popen_read("git", "branch", "--list", "master").blank?
safe_system "git", "branch", "master", "origin/master"
end
end end
puts "Start commit: #{start_commit}" puts "Start commit: #{start_commit}"
@ -80,10 +90,12 @@ module Homebrew
oh1 "Setup test environment..." oh1 "Setup test environment..."
# copy Homebrew installation # copy Homebrew installation
safe_system "git", "clone", "--local", "#{HOMEBREW_REPOSITORY}/.git", "." safe_system "git", "clone", "#{HOMEBREW_REPOSITORY}/.git", ".",
"--local", "--branch", "master", "--single-branch"
# set git origin to another copy # set git origin to another copy
safe_system "git", "clone", "--local", "--bare", "#{HOMEBREW_REPOSITORY}/.git", "remote.git" safe_system "git", "clone", "#{HOMEBREW_REPOSITORY}/.git", "remote.git",
"--local", "--bare", "--branch", "master", "--single-branch"
safe_system "git", "config", "remote.origin.url", "#{curdir}/remote.git" safe_system "git", "config", "remote.origin.url", "#{curdir}/remote.git"
# force push origin to end_commit # force push origin to end_commit
@ -100,7 +112,7 @@ module Homebrew
oh1 "Running brew update..." oh1 "Running brew update..."
safe_system "brew", "update", "--verbose" safe_system "brew", "update", "--verbose"
actual_end_commit = Utils.popen_read("git", "rev-parse", branch).chomp actual_end_commit = Utils.popen_read("git", "rev-parse", branch).chomp
if start_commit != end_commit && start_commit == actual_end_commit if actual_end_commit != end_commit
raise <<~EOS raise <<~EOS
brew update didn't update #{branch}! brew update didn't update #{branch}!
Start commit: #{start_commit} Start commit: #{start_commit}
@ -110,6 +122,6 @@ module Homebrew
end end
end end
ensure ensure
FileUtils.rm_r "update-test" unless args.keep_tmp? FileUtils.rm_rf "update-test" unless args.keep_tmp?
end end
end end

View File

@ -72,7 +72,7 @@ module Homebrew
# `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
# repository. This only needs to support whatever CI providers # repository. This only needs to support whatever CI providers
# Homebrew/brew is currently using. # Homebrew/brew is currently using.
return if ENV["HOMEBREW_AZURE_PIPELINES"] || ENV["HOMEBREW_GITHUB_ACTIONS"] return if ENV["HOMEBREW_GITHUB_ACTIONS"]
message = <<~EOS message = <<~EOS
Your Xcode (#{MacOS::Xcode.version}) is outdated. Your Xcode (#{MacOS::Xcode.version}) is outdated.
@ -99,7 +99,7 @@ module Homebrew
# `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
# repository. This only needs to support whatever CI providers # repository. This only needs to support whatever CI providers
# Homebrew/brew is currently using. # Homebrew/brew is currently using.
return if ENV["HOMEBREW_AZURE_PIPELINES"] || ENV["HOMEBREW_GITHUB_ACTIONS"] return if ENV["HOMEBREW_GITHUB_ACTIONS"]
<<~EOS <<~EOS
A newer Command Line Tools release is available. A newer Command Line Tools release is available.

View File

@ -27,11 +27,6 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
ENV["COVERALLS_REPO_TOKEN"] = ENV["HOMEBREW_COVERALLS_REPO_TOKEN"] ENV["COVERALLS_REPO_TOKEN"] = ENV["HOMEBREW_COVERALLS_REPO_TOKEN"]
end end
if ENV["HOMEBREW_AZURE_PIPELINES"]
require "simplecov-cobertura"
formatters << SimpleCov::Formatter::CoberturaFormatter
end
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters) SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)
end end

View File

@ -1,52 +0,0 @@
jobs:
- job: macOS
pool:
vmImage: macOS-10.14
steps:
- bash: |
set -e
sudo xcode-select --switch /Applications/Xcode_10.2.app/Contents/Developer
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
brew test-bot
displayName: Run brew test-bot
env:
HOMEBREW_GITHUB_API_TOKEN: $(github.publicApiToken)
HOMEBREW_COVERALLS_REPO_TOKEN: $(coveralls.homebrewBrewApiToken)
- task: PublishTestResults@2
displayName: Publish test-bot test results
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: brew-test-bot.xml
- task: PublishCodeCoverageResults@1
displayName: Publish brew tests code coverage
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverage/coverage.xml
reportDirectory: $(Build.SourcesDirectory)/coverage
failIfCoverageEmpty: true
- job: Linux
pool:
vmImage: ubuntu-16.04
steps:
- bash: docker-compose -f Dockerfile.yml build sut
displayName: Build Docker image
- bash: docker-compose -f Dockerfile.yml run --rm -v $(Build.ArtifactStagingDirectory):/tmp/test-bot sut
displayName: Run brew test-bot
env:
HOMEBREW_GITHUB_API_TOKEN: $(github.publicApiToken)
- task: PublishTestResults@2
displayName: Publish test-bot test results
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: $(Build.ArtifactStagingDirectory)/brew-test-bot.xml

View File

@ -65,8 +65,9 @@ do
export "$VAR_NEW"="${!VAR}" export "$VAR_NEW"="${!VAR}"
done done
# Set CI variable for Azure Pipelines, Jenkins. # Set CI variable for GitHub Actions, Azure Pipelines, Jenkins
if [[ -n "$TF_BUILD" || -n "$JENKINS_HOME" ]] # (Set by default on Circle and Travis CI)
if [[ -n "$GITHUB_ACTIONS" || -n "$TF_BUILD" || -n "$JENKINS_HOME" ]]
then then
export CI="1" export CI="1"
fi fi