From 67840c691e1b618a8a273b3aee1cc1bed8bad208 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 10 Dec 2013 20:14:15 +0000 Subject: [PATCH] brew-test-bot: move logic from Jenkins to Ruby. --- Library/Contributions/cmd/brew-test-bot.rb | 55 ++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/Library/Contributions/cmd/brew-test-bot.rb b/Library/Contributions/cmd/brew-test-bot.rb index c180db643e..209852abae 100755 --- a/Library/Contributions/cmd/brew-test-bot.rb +++ b/Library/Contributions/cmd/brew-test-bot.rb @@ -10,6 +10,13 @@ # --email: Generate an email subject file. # --no-bottle: Run brew install without --build-bottle # --HEAD: Run brew install with --HEAD +# --local: Output logs and cache downloads under ./{logs,cache} +# +# --ci-master: Shortcut for Homebrew master branch CI options. +# --ci-pr: Shortcut for Homebrew pull request CI options. +# --ci-testing: Shortcut for Homebrew testing CI options. +# --ci-pr-upload: Homebrew CI pull request bottle upload. +# --ci-testing-upload: Homebrew CI testing bottle upload. require 'formula' require 'utils' @@ -368,13 +375,40 @@ class Test cleanup_before download setup unless ARGV.include? "--skip-setup" - homebrew - formulae.each do |f| - formula(f) + if ARGV.include? '--ci-pr-upload' or ARGV.include? '--ci-testing-upload' + bottle_upload + else + homebrew + formulae.each do |f| + formula(f) + end end cleanup_after check_results end + + def bottle_upload + @category = __method__ + jenkins = ENV['JENKINS_HOME'] + job = ENV['UPSTREAM_JOB_NAME'] + id = ENV['UPSTREAM_BUILD_ID'] + raise "Missing Jenkins variables!" unless jenkins and job and id + + test "cp #{jenkins}/jobs/'#{job}'/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.* ." + test "brew bottle --merge --write *.bottle*.rb" + + remote = "https://github.com/BrewTestBot/homebrew.git" + pr = ENV['UPSTREAM_PULL_REQUEST'] + tag = pr ? "pr-#{pr}" : "testing-#{id}" + test "git push --force #{remote} :refs/tags/#{tag}" + + path = "/home/frs/project/m/ma/machomebrew/Bottles/" + url = "mikemcquaid,machomebrew@frs.sourceforge.net:#{path}" + options = "--partial --progress --human-readable --compress" + test "rsync #{options} *.bottle.tar.gz #{url}" + test "git tag --force #{tag}" + test "git push --force #{remote} refs/tags/#{tag}" + end end if Pathname.pwd == HOMEBREW_PREFIX and ARGV.include? "--cleanup" @@ -389,6 +423,21 @@ if ARGV.include? "--email" end end +ENV['HOMEBREW_DEVELOPER'] = '1' +ENV['HOMEBREW_NO_EMOJI'] = '1' +if ARGV.include? '--ci-master' or ARGV.include? '--ci-pr' \ + or ARGV.include? '--ci-testing' + ARGV << '--cleanup' << '--junit' << '--local' +end +if ARGV.include? '--ci-master' + ARGV << '--no-bottle' << '--email' +end + +if ARGV.include? '--local' + ENV['HOMEBREW_LOGS'] = "#{Dir.pwd}/logs" + ENV['HOMEBREW_CACHE'] = "#{Dir.pwd}/cache" +end + tests = [] any_errors = false if ARGV.named.empty?