Преглед на файлове

Add demo validation and deployment status traffic light to new build report

Change-Id: I0cd71e14c213d3c96a41599aaa03f33b15b797c7
tags/8.0.0.alpha7
Aleksi Hietanen преди 7 години
родител
ревизия
9e10d5d29c
променени са 2 файла, в които са добавени 38 реда и са изтрити 16 реда
  1. 20
    7
      scripts/BuildDemos.py
  2. 18
    9
      scripts/GenerateBuildTestAndStagingReport.py

+ 20
- 7
scripts/BuildDemos.py Целия файл

# pip install requests # pip install requests
# Deploy depends on .deployUrl and .deployCredentials files in home folder # Deploy depends on .deployUrl and .deployCredentials files in home folder


import sys, os
import sys, os, pickle
from os.path import join, isfile from os.path import join, isfile
from fnmatch import fnmatch from fnmatch import fnmatch
from xml.etree.ElementTree import ElementTree from xml.etree.ElementTree import ElementTree
# "my-demo" : ("my_demo_url_or_path", "my-demo-dev-branch") # "my-demo" : ("my_demo_url_or_path", "my-demo-dev-branch")
} }


status_dump = {"messages": []}

def dump_status(error_occurred):
status_dump["error"] = error_occurred
pickle.dump(status_dump, open("result/demo_validation_status.pickle", "wb"))

def log_status(log_string):
status_dump["messages"].add(log_string)
print(log_string)

def checkout(folder, url, repoBranch = "master"): def checkout(folder, url, repoBranch = "master"):
Repo.clone_from(url, join(resultPath, folder), branch = repoBranch) Repo.clone_from(url, join(resultPath, folder), branch = repoBranch)


try: try:
from git import Repo from git import Repo
except: except:
print("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
log_status("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
dump_status(True)
sys.exit(1) sys.exit(1)
from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath, readPomFile, parser from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath, readPomFile, parser
from DeployHelpers import deployWar from DeployHelpers import deployWar
args = getArgs() args = getArgs()
demosFailed = False demosFailed = False
ignoredDemos = args.ignore.split(",") ignoredDemos = args.ignore.split(",")
wars = [] wars = []


for demo in demos: for demo in demos:
updateRepositories(join(resultPath, demo), args.pluginRepo, postfix="plugin") updateRepositories(join(resultPath, demo), args.pluginRepo, postfix="plugin")
mavenValidate(demo, logFile=getLogFile(demo)) mavenValidate(demo, logFile=getLogFile(demo))
wars.extend(copyWarFiles(demo)) wars.extend(copyWarFiles(demo))
print("%s demo validation succeeded!" % (demo))
log_status("%s demo validation succeeded!" % (demo))
except Exception as e: except Exception as e:
print("%s demo validation failed: %s" % (demo, e))
log_status("%s demo validation failed: %s" % (demo, e))
if demo not in ignoredDemos: if demo not in ignoredDemos:
demosFailed = True demosFailed = True
except EnvironmentError as e: except EnvironmentError as e:
print("%s demo validation failed: %s" % (demo, e))
log_status("%s demo validation failed: %s" % (demo, e))
if demo not in ignoredDemos: if demo not in ignoredDemos:
demosFailed = True demosFailed = True
try: try:
try: try:
deployWar(war) deployWar(war)
except Exception as e: except Exception as e:
print("War %s failed to deploy: %s" % (war, e))
log_status("War %s failed to deploy: %s" % (war, e))
demosFailed = True demosFailed = True


if demosFailed: if demosFailed:
dump_status(True)
sys.exit(1) sys.exit(1)

dump_status(False)

+ 18
- 9
scripts/GenerateBuildTestAndStagingReport.py Целия файл

from BuildDemos import demos from BuildDemos import demos
import argparse, requests, json, subprocess, re
import argparse, requests, json, subprocess, re, pickle


parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("version", type=str, help="Vaadin version that was just built") parser.add_argument("version", type=str, help="Vaadin version that was just built")
html += "<td>" + column + "</td>" html += "<td>" + column + "</td>"
return html + "</tr>" return html + "</tr>"


def getHtmlList(array):
html = "<ul>"
for item in array:
html += "<li>" + item + "</li>"
return html + "</ul>"

def getBuildStatusHtml(): def getBuildStatusHtml():
build_steps_request_string = "http://{}/app/rest/problemOccurrences?locator=build:{}".format(args.teamcityUrl, args.buildId) build_steps_request_string = "http://{}/app/rest/problemOccurrences?locator=build:{}".format(args.teamcityUrl, args.buildId)
build_steps_request = requests.get(build_steps_request_string, auth=(args.teamcityUser, args.teamcityPassword), headers={'Accept':'application/json'}) build_steps_request = requests.get(build_steps_request_string, auth=(args.teamcityUser, args.teamcityPassword), headers={'Accept':'application/json'})
else: else:
return createTableRow(traffic_light.format(color="red"), "Test status: there are " + str(test_failures_json["count"]) + " failing tests, <a href=\"http://r2d2.devnet.vaadin.com/viewLog.html?buildId={}&buildTypeId=Vaadin80_Releases_BuildTestAndStageRelease&tab=testsInfo\">see report</a>.".format(args.buildId)) return createTableRow(traffic_light.format(color="red"), "Test status: there are " + str(test_failures_json["count"]) + " failing tests, <a href=\"http://r2d2.devnet.vaadin.com/viewLog.html?buildId={}&buildTypeId=Vaadin80_Releases_BuildTestAndStageRelease&tab=testsInfo\">see report</a>.".format(args.buildId))


def getDemoValidationStatusHtml():
status = pickle.load(open("result/demo_validation_status.pickle", "rb"))
if status["error"]:
return createTableRow(traffic_light.format(color="red"), getHtmlList(status["messages"]))
else:
return createTableRow(traffic_light.format(color="green"), getHtmlList(status["messages"]))

def getDemoLinksHtml(): def getDemoLinksHtml():
demos_html = "Try demos" demos_html = "Try demos"
demos_html += "<ul>"
for demo in demos:
demos_html += "<li><a href='{url}/{demoName}-{version}'>{demoName}</a></li>".format(url=args.deployUrl, demoName=demo, version=args.version)
return demos_html + "</ul>"
link_list = list(map(lambda demo: "<a href='{url}/{demoName}-{version}'>{demoName}</a>".format(url=args.deployUrl, demoName=demo, version=args.version), demos))
return demos_html + getHtmlList(link_list)


def getApiDiffHtml(): def getApiDiffHtml():
apidiff_html = "Check API diff" apidiff_html = "Check API diff"
apidiff_html += "<ul>"
modules = [ modules = [
"client", "client-compiler", "client", "client-compiler",
"compatibility-client", "compatibility-client",
"compatibility-shared", "compatibility-shared",
"server", "shared" "server", "shared"
] ]
for module in modules:
apidiff_html += "<li><a href='http://r2d2.devnet.vaadin.com/repository/download/Vaadin80_Releases_BuildTestAndStageRelease/{}:id/apidiff/{}/japicmp.html'>{}</a></li>".format(args.buildId, module, module)
return apidiff_html + "</ul>"
link_list = list(map(lambda module: "<li><a href='http://r2d2.devnet.vaadin.com/repository/download/Vaadin80_Releases_BuildTestAndStageRelease/{}:id/apidiff/{}/japicmp.html'>{}</a></li>".format(args.buildId, module, module), modules))
return apidiff_html + getHtmlList(link_list)


def getDirs(url): def getDirs(url):
page = requests.get(url) page = requests.get(url)

Loading…
Отказ
Запис