Try to fix CI failures (#15701)
* Use cligens release version * Rework important_packages main loop * Fix * Fix * Create pkgs dir * Don't use nimble develop since it doesn't work for binary only packages, and always install head * Use git to get the latest release/tag instead * Tackle the root cause * Reduce diff * Cleanup
This commit is contained in:
parent
d4022ebe53
commit
e18fc698ed
2 changed files with 120 additions and 130 deletions
|
|
@ -452,15 +452,15 @@ type
|
|||
ppOne
|
||||
ppTwo
|
||||
|
||||
iterator listPackages(part: PkgPart): tuple[name, url, cmd: string, hasDeps: bool, useHead: bool] =
|
||||
iterator listPackages(part: PkgPart): tuple[name, cmd, url: string, useHead: bool] =
|
||||
let packageList = parseFile(packageIndex)
|
||||
let importantList =
|
||||
case part
|
||||
of ppOne: important_packages.packages1
|
||||
of ppTwo: important_packages.packages2
|
||||
for n, cmd, hasDeps, url, useHead in importantList.items:
|
||||
for n, cmd, url, useHead in importantList.items:
|
||||
if url.len != 0:
|
||||
yield (n, url, cmd, hasDeps, useHead)
|
||||
yield (n, cmd, url, useHead)
|
||||
else:
|
||||
var found = false
|
||||
for package in packageList.items:
|
||||
|
|
@ -468,7 +468,7 @@ iterator listPackages(part: PkgPart): tuple[name, url, cmd: string, hasDeps: boo
|
|||
if name == n:
|
||||
found = true
|
||||
let pUrl = package["url"].str
|
||||
yield (name, pUrl, cmd, hasDeps, useHead)
|
||||
yield (name, cmd, pUrl, useHead)
|
||||
break
|
||||
if not found:
|
||||
raise newException(ValueError, "Cannot find package '$#'." % n)
|
||||
|
|
@ -479,16 +479,6 @@ proc makeSupTest(test, options: string, cat: Category): TTest =
|
|||
result.options = options
|
||||
result.startTime = epochTime()
|
||||
|
||||
proc actionRetry(maxRetry: int, backoffDuration: float, action: proc: bool): bool =
|
||||
## retry `action` up to `maxRetry` times with exponential backoff and initial
|
||||
## duraton of `backoffDuration` seconds
|
||||
var t = backoffDuration
|
||||
for i in 0..<maxRetry:
|
||||
if action(): return true
|
||||
if i == maxRetry - 1: break
|
||||
sleep(int(t * 1000))
|
||||
t *= 2 # exponential backoff
|
||||
|
||||
proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string, part: PkgPart) =
|
||||
if nimbleExe == "":
|
||||
echo "[Warning] - Cannot run nimble tests: Nimble binary not found."
|
||||
|
|
@ -499,47 +489,48 @@ proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string, p
|
|||
|
||||
let packageFileTest = makeSupTest("PackageFileParsed", "", cat)
|
||||
let packagesDir = "pkgstemp"
|
||||
createDir(packagesDir)
|
||||
var errors = 0
|
||||
try:
|
||||
for name, url, cmd, hasDep, useHead in listPackages(part):
|
||||
for name, cmd, url, useHead in listPackages(part):
|
||||
if packageFilter notin name:
|
||||
continue
|
||||
inc r.total
|
||||
var test = makeSupTest(url, "", cat)
|
||||
var test = makeSupTest(name, "", cat)
|
||||
let buildPath = packagesDir / name
|
||||
|
||||
if not dirExists(buildPath):
|
||||
if useHead:
|
||||
let (installCmdLine, installOutput, installStatus) = execCmdEx2("git", ["clone", url, buildPath])
|
||||
if installStatus != QuitSuccess:
|
||||
let message = "git clone failed:\n$ " & installCmdLine & "\n" & installOutput
|
||||
r.addResult(test, targetC, "", message, reInstallFailed)
|
||||
let (cloneCmd, cloneOutput, cloneStatus) = execCmdEx2("git", ["clone", url, buildPath])
|
||||
if cloneStatus != QuitSuccess:
|
||||
r.addResult(test, targetC, "", cloneCmd & "\n" & cloneOutput, reInstallFailed)
|
||||
continue
|
||||
|
||||
if not useHead:
|
||||
let (fetchCmd, fetchOutput, fetchStatus) = execCmdEx2("git", ["fetch", "--tags"], workingDir = buildPath)
|
||||
if fetchStatus != QuitSuccess:
|
||||
r.addResult(test, targetC, "", fetchCmd & "\n" & fetchOutput, reInstallFailed)
|
||||
continue
|
||||
|
||||
if hasDep:
|
||||
var message: string
|
||||
if not actionRetry(maxRetry = 3, backoffDuration = 1.0,
|
||||
proc: bool =
|
||||
let (outp, status) = execCmdEx("nimble install -y", workingDir = buildPath)
|
||||
if status != 0:
|
||||
message = "'$1' failed:\n$2" % [cmd, outp]
|
||||
false
|
||||
else: true
|
||||
):
|
||||
r.addResult(test, targetC, "", message, reInstallFailed)
|
||||
continue
|
||||
else:
|
||||
let (installCmdLine, installOutput, installStatus) = execCmdEx2("nimble", ["develop", name, "-y"])
|
||||
if installStatus != QuitSuccess:
|
||||
let message = "nimble develop failed:\n$ " & installCmdLine & "\n" & installOutput
|
||||
r.addResult(test, targetC, "", message, reInstallFailed)
|
||||
let (describeCmd, describeOutput, describeStatus) = execCmdEx2("git", ["describe", "--tags", "--abbrev=0"], workingDir = buildPath)
|
||||
if describeStatus != QuitSuccess:
|
||||
r.addResult(test, targetC, "", describeCmd & "\n" & describeOutput, reInstallFailed)
|
||||
continue
|
||||
|
||||
let (checkoutCmd, checkoutOutput, checkoutStatus) = execCmdEx2("git", ["checkout", describeOutput.strip], workingDir = buildPath)
|
||||
if checkoutStatus != QuitSuccess:
|
||||
r.addResult(test, targetC, "", checkoutCmd & "\n" & checkoutOutput, reInstallFailed)
|
||||
continue
|
||||
|
||||
let (installDepsCmd, installDepsOutput, installDepsStatus) = execCmdEx2("nimble", ["install", "--depsOnly", "-y"], workingDir = buildPath)
|
||||
if installDepsStatus != QuitSuccess:
|
||||
r.addResult(test, targetC, "", "installing dependencies failed:\n$ " & installDepsCmd & "\n" & installDepsOutput, reInstallFailed)
|
||||
continue
|
||||
|
||||
let cmdArgs = parseCmdLine(cmd)
|
||||
|
||||
let (buildCmdLine, buildOutput, buildStatus) = execCmdEx2(cmdArgs[0], cmdArgs[1..^1], workingDir=buildPath)
|
||||
if buildStatus != QuitSuccess:
|
||||
let message = "package test failed\n$ " & buildCmdLine & "\n" & buildOutput
|
||||
r.addResult(test, targetC, "", message, reBuildFailed)
|
||||
let (buildCmd, buildOutput, status) = execCmdEx2(cmdArgs[0], cmdArgs[1..^1], workingDir = buildPath)
|
||||
if status != QuitSuccess:
|
||||
r.addResult(test, targetC, "", "package test failed\n$ " & buildCmd & "\n" & buildOutput, reBuildFailed)
|
||||
else:
|
||||
inc r.passed
|
||||
r.addResult(test, targetC, "", "", reSuccess)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue