Added Windows ReviewBot script. This adds a support script used to run the Windows ReviewBot in a loop, while properly logging the output and providing a URL for the log.
Unlike the other (Ubuntu) ReviewBot script, this script is standalone and should be run on the machine that is performing the builds (rather than given to Jenkins). Review: https://reviews.apache.org/r/59500/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/750c3663 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/750c3663 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/750c3663 Branch: refs/heads/master Commit: 750c366380a4fa7db3839bdff53837159236b6fe Parents: 98e2f8e Author: Andrew Schwartzmeyer <[email protected]> Authored: Wed Jun 21 14:14:51 2017 -0700 Committer: Joseph Wu <[email protected]> Committed: Wed Jun 21 14:24:00 2017 -0700 ---------------------------------------------------------------------- support/mesos-reviewbot.ps1 | 66 ++++++++++++++++++++++++++++++++++++++++ support/verify-reviews.py | 3 +- 2 files changed, 68 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/750c3663/support/mesos-reviewbot.ps1 ---------------------------------------------------------------------- diff --git a/support/mesos-reviewbot.ps1 b/support/mesos-reviewbot.ps1 new file mode 100644 index 0000000..8efd7d4 --- /dev/null +++ b/support/mesos-reviewbot.ps1 @@ -0,0 +1,66 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +param( + [string]$username = "mesos-review-windows", + [string]$password = $(Read-Host "Input Password"), + + # Query can be adjusted per the API: + # https://www.reviewboard.org/docs/manual/2.5/webapi/2.0/resources/review-request-list/ + [string]$query = "?to-groups=mesos&status=pending&last-updated-from=2017-01-01T00:00:00", + [switch]$pull, + [string]$folder = "$PSScriptRoot/../../logs", + [string]$url = $(Read-Host "Input URL") +) + +$ErrorActionPreference = "Stop" + +# Check for Python. +$null = Get-Command python + +# Script lives in support, cd up a directory. +Push-Location "$PSScriptRoot/.." + +# Logs are saved to this folder. +if (!(Test-Path "$folder")) { + $null = New-Item -ItemType Directory "$folder" +} + +# Run ReviewBot in a loop, saving incrementally numbered logs. +while ($true) { + $i = [int](Get-ChildItem $folder | Sort-Object { [int]$_.Name } | Select-Object -Last 1).Name + 1 + $logfolder = "$folder/$i" + $null = New-Item -ItemType Directory $logfolder + + # We assume the $folder is being served at url/folder (not url/path/to/folder), + # and split here to avoid any relative paths in the url. NOTE: The trailing + # slash must remain for Python's urlparse to include the leaf. + $env:BUILD_URL = "$url/$(Split-Path -Leaf $folder)/$i/" + if ($pull) { + git pull --rebase origin master + } + + python .\support\verify-reviews.py $username $password 1 $query 2>&1 | Tee-Object -FilePath "$logfolder/console" + + # If the log is short, we assume there was nothing to test and so delete the log. + # Otherwise we'd end up with thousands of logs. + if ((Get-Item "$logfolder/console").Length -lt 10000) { + Remove-Item -Recurse $logfolder + Start-Sleep -Seconds 300 + } +} + +Pop-Location http://git-wip-us.apache.org/repos/asf/mesos/blob/750c3663/support/verify-reviews.py ---------------------------------------------------------------------- diff --git a/support/verify-reviews.py b/support/verify-reviews.py index 391bef5..eb8f76e 100755 --- a/support/verify-reviews.py +++ b/support/verify-reviews.py @@ -11,6 +11,7 @@ import subprocess import sys import urllib import urllib2 +import urlparse from datetime import datetime, timedelta @@ -180,7 +181,7 @@ def verify_review(review_request): # Truncate the output when posting the review as it can be very large. output = output if len(output) <= REVIEW_SIZE else "...<truncated>...\n" + output[-REVIEW_SIZE:] - output = output + "\nFull log: " + os.path.join(os.environ['BUILD_URL'], 'console') + output = output + "\nFull log: " + urlparse.urljoin(os.environ['BUILD_URL'], 'console') post_review( review_request,
