Pārlūkot izejas kodu

Fix version number resolution for validation scripts

Change-Id: I799553cea50cb8e81ab06482f1a971f324da8fa1
tags/7.6.0.alpha3
Teemu Suo-Anttila pirms 9 gadiem
vecāks
revīzija
9458150556
3 mainītis faili ar 36 papildinājumiem un 24 dzēšanām
  1. 14
    13
      scripts/BuildArchetypes.py
  2. 7
    3
      scripts/BuildDemos.py
  3. 15
    8
      scripts/BuildHelpers.py

+ 14
- 13
scripts/BuildArchetypes.py Parādīt failu

# python BuildArchetypes.py version fw-repo-id archetype-repo-id plugin-repo-id # python BuildArchetypes.py version fw-repo-id archetype-repo-id plugin-repo-id
# #


import subprocess
from BuildHelpers import mavenValidate, copyWarFiles, repo, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir, parser, resultPath
import subprocess, sys
from BuildHelpers import mavenValidate, copyWarFiles, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir, parser, resultPath
from DeployHelpers import deployWar from DeployHelpers import deployWar


## DEFAULT VARIABLES ## ## DEFAULT VARIABLES ##
## BUILDING METHODS ## ## BUILDING METHODS ##


# Generates and modifies a maven pom file # Generates and modifies a maven pom file
def generateArchetype(archetype):
artifactId = "test-%s-%s" % (archetype, args.version.replace(".", "-"))

def generateArchetype(archetype, artifactId):
# Generate the required command line for archetype generation # Generate the required command line for archetype generation
cmd = [mavenCmd, "archetype:generate"] cmd = [mavenCmd, "archetype:generate"]
cmd.append("-DarchetypeGroupId=%s" % (archetypeGroup)) cmd.append("-DarchetypeGroupId=%s" % (archetypeGroup))
cmd.append("-Dversion=1.0-SNAPSHOT") cmd.append("-Dversion=1.0-SNAPSHOT")
cmd.append("-DinteractiveMode=false") cmd.append("-DinteractiveMode=false")
if hasattr(args, "maven") and args.maven is not None: if hasattr(args, "maven") and args.maven is not None:
cmd.extends(args.maven.split(" "))
cmd.extend(args.maven.strip('"').split(" "))
# Generate pom.xml # Generate pom.xml
print("Generating pom.xml for archetype %s" % (archetype)) print("Generating pom.xml for archetype %s" % (archetype))
subprocess.check_call(cmd, cwd=resultPath, stdout=log) subprocess.check_call(cmd, cwd=resultPath, stdout=log)
# Return the artifactId so we know the name in the future
return artifactId

## DO THIS IF RUN AS A SCRIPT (not import) ## ## DO THIS IF RUN AS A SCRIPT (not import) ##
if __name__ == "__main__": if __name__ == "__main__":
# Add command line arguments for staging repos # Add command line arguments for staging repos
parser.add_argument("framework", type=int, help="Framework repo id (comvaadin-XXXX)", nargs='?') parser.add_argument("framework", type=int, help="Framework repo id (comvaadin-XXXX)", nargs='?')
parser.add_argument("archetype", type=int, help="Archetype repo id (comvaadin-XXXX)", nargs='?') parser.add_argument("archetype", type=int, help="Archetype repo id (comvaadin-XXXX)", nargs='?')
parser.add_argument("plugin", type=int, help="Maven Plugin repo id (comvaadin-XXXX)", nargs='?') parser.add_argument("plugin", type=int, help="Maven Plugin repo id (comvaadin-XXXX)", nargs='?')
parser.add_argument("--repo", type=str, help="Staging repository template", required=True)


archetypesFailed = False archetypesFailed = False


# Parse the arguments # Parse the arguments
args = getArgs() args = getArgs()

if hasattr(args, "artifactPath") and args.artifactPath is not None:
raise Exception("Archetype validation build does not support artifactPath")

for archetype in archetypes: for archetype in archetypes:
artifactId = "test-%s-%s" % (archetype, args.version.replace(".", "-"))
try: try:
log = getLogFile(archetype) log = getLogFile(archetype)
artifactId = generateArchetype(archetype)
generateArchetype(archetype, artifactId)
updateRepositories(artifactId) updateRepositories(artifactId)
mavenValidate(artifactId, logFile=log) mavenValidate(artifactId, logFile=log)
warFiles = copyWarFiles(artifactId, name=archetype) warFiles = copyWarFiles(artifactId, name=archetype)
for war in warFiles: for war in warFiles:
try: try:
deployWar(war, "%s.war" % (archetype.split("-", 2)[2]))
deployWar(war, "%s-%s.war" % (archetype.split("-", 2)[2], args.version))
except Exception as e: except Exception as e:
print("War %s failed to deploy: %s" % (war, e)) print("War %s failed to deploy: %s" % (war, e))
archetypesFailed = True archetypesFailed = True
except:
print("Archetype %s build failed" % (archetype))
except Exception as e:
print("Archetype %s build failed" % (archetype, e))
archetypesFailed = True archetypesFailed = True
removeDir(artifactId) removeDir(artifactId)
print("") print("")

+ 7
- 3
scripts/BuildDemos.py Parādīt failu

import sys, os import sys, os
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


# Validated demos. name -> git url # Validated demos. name -> git url
demos = { demos = {
except: except:
print("BuildDemos depends on gitpython. Install it with `pip install gitpython`") print("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
sys.exit(1) sys.exit(1)
from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath
from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath, readPomFile
from DeployHelpers import deployWar from DeployHelpers import deployWar



if hasattr(getArgs(), "artifactPath") and getArgs().artifactPath is not None: if hasattr(getArgs(), "artifactPath") and getArgs().artifactPath is not None:
version = False
basePath = getArgs().artifactPath basePath = getArgs().artifactPath
poms = [] poms = []
for root, dirs, files in os.walk(basePath): for root, dirs, files in os.walk(basePath):
mavenInstall(pom, jarFile) mavenInstall(pom, jarFile)
else: else:
mavenInstall(pom) mavenInstall(pom)
if "vaadin-server" in pom:
pomXml, nameSpace = readPomFile(pom)
for version in pomXml.getroot().findall("./{%s}version" % (nameSpace)):
getArgs().version = version.text
demosFailed = False demosFailed = False
for demo in demos: for demo in demos:

+ 15
- 8
scripts/BuildHelpers.py Parādīt failu



# Default argument parser # Default argument parser
parser = argparse.ArgumentParser(description="Automated staging validation") parser = argparse.ArgumentParser(description="Automated staging validation")
parser.add_argument("version", type=str, help="Vaadin version to use")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--version", help="Vaadin version to use")
group.add_argument("--artifactPath", help="Path to local folder with Vaadin artifacts")

parser.add_argument("--maven", help="Additional maven command line parameters", default=None) parser.add_argument("--maven", help="Additional maven command line parameters", default=None)
parser.add_argument("--artifactPath", help="Path to local folder with Vaadin artifacts", default=None)


# Parse command line arguments <version> # Parse command line arguments <version>
def parseArgs(): def parseArgs():
copiedWars.append(join(resultDir, deployName)) copiedWars.append(join(resultDir, deployName))
return copiedWars return copiedWars


def readPomFile(pomFile):
# pom.xml namespace workaround
root = ElementTree.parse(pomFile).getroot()
nameSpace = root.tag[1:root.tag.index('}')]
print("Using namespace: %s" % (nameSpace))
ElementTree.register_namespace('', nameSpace)

# Read the pom.xml correctly
return ElementTree.parse(pomFile), nameSpace

# Recursive pom.xml update script # Recursive pom.xml update script
def updateRepositories(path, repoIds = None, repoUrl = repo): def updateRepositories(path, repoIds = None, repoUrl = repo):
# If versions are not supplied, parse arguments # If versions are not supplied, parse arguments
# Read pom.xml # Read pom.xml
pomXml = join(path, "pom.xml") pomXml = join(path, "pom.xml")
if isfile(pomXml): if isfile(pomXml):
# pom.xml namespace workaround
root = ElementTree.parse(pomXml).getroot()
nameSpace = root.tag[1:root.tag.index('}')]
ElementTree.register_namespace('', nameSpace)
# Read the pom.xml correctly # Read the pom.xml correctly
tree = ElementTree.parse(pomXml)
tree, nameSpace = readPomFile(pomXml)
# NameSpace needed for finding the repositories node # NameSpace needed for finding the repositories node
repoNode = tree.getroot().find("{%s}repositories" % (nameSpace)) repoNode = tree.getroot().find("{%s}repositories" % (nameSpace))

Notiek ielāde…
Atcelt
Saglabāt