CI: Install the pkg we cloned (#14770)
This commit is contained in:
parent
2220ff70be
commit
302e3b7f44
3 changed files with 45 additions and 57 deletions
|
|
@ -1,32 +0,0 @@
|
||||||
##[
|
|
||||||
internal API for now, API subject to change
|
|
||||||
]##
|
|
||||||
|
|
||||||
import std/[os,osproc,sugar,strutils]
|
|
||||||
|
|
||||||
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 = t * 2 # exponential backoff
|
|
||||||
return false
|
|
||||||
|
|
||||||
proc nimbleInstall*(name: string, message: var string): bool =
|
|
||||||
let cmd = "nimble install -y " & name
|
|
||||||
let (outp, status) = execCmdEx(cmd)
|
|
||||||
if status != 0:
|
|
||||||
message = "'$1' failed:\n$2" % [cmd, outp]
|
|
||||||
result = false
|
|
||||||
else: result = true
|
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
block:
|
|
||||||
var msg: string
|
|
||||||
let ok = actionRetry(maxRetry = 2, backoffDuration = 0.1):
|
|
||||||
(proc(): bool = nimbleInstall("nonexistant", msg))
|
|
||||||
doAssert "Package not found" in msg
|
|
||||||
doAssert not ok
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
# included from testament.nim
|
# included from testament.nim
|
||||||
|
|
||||||
import important_packages
|
import important_packages
|
||||||
import std/private/nimbleutils
|
|
||||||
|
|
||||||
const
|
const
|
||||||
specialCategories = [
|
specialCategories = [
|
||||||
|
|
@ -453,15 +452,15 @@ type
|
||||||
ppOne
|
ppOne
|
||||||
ppTwo
|
ppTwo
|
||||||
|
|
||||||
iterator listPackages(part: PkgPart): tuple[name, url, cmd: string, hasDeps: bool] =
|
iterator listPackages(part: PkgPart): tuple[name, url, cmd: string, hasDeps: bool, useHead: bool] =
|
||||||
let packageList = parseFile(packageIndex)
|
let packageList = parseFile(packageIndex)
|
||||||
let importantList =
|
let importantList =
|
||||||
case part
|
case part
|
||||||
of ppOne: important_packages.packages1
|
of ppOne: important_packages.packages1
|
||||||
of ppTwo: important_packages.packages2
|
of ppTwo: important_packages.packages2
|
||||||
for n, cmd, hasDeps, url in importantList.items:
|
for n, cmd, hasDeps, url, useHead in importantList.items:
|
||||||
if url.len != 0:
|
if url.len != 0:
|
||||||
yield (n, url, cmd, hasDeps)
|
yield (n, url, cmd, hasDeps, useHead)
|
||||||
else:
|
else:
|
||||||
var found = false
|
var found = false
|
||||||
for package in packageList.items:
|
for package in packageList.items:
|
||||||
|
|
@ -469,7 +468,7 @@ iterator listPackages(part: PkgPart): tuple[name, url, cmd: string, hasDeps: boo
|
||||||
if name == n:
|
if name == n:
|
||||||
found = true
|
found = true
|
||||||
let pUrl = package["url"].str
|
let pUrl = package["url"].str
|
||||||
yield (name, pUrl, cmd, hasDeps)
|
yield (name, pUrl, cmd, hasDeps, useHead)
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
raise newException(ValueError, "Cannot find package '$#'." % n)
|
raise newException(ValueError, "Cannot find package '$#'." % n)
|
||||||
|
|
@ -480,6 +479,16 @@ proc makeSupTest(test, options: string, cat: Category): TTest =
|
||||||
result.options = options
|
result.options = options
|
||||||
result.startTime = epochTime()
|
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) =
|
proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string, part: PkgPart) =
|
||||||
if nimbleExe == "":
|
if nimbleExe == "":
|
||||||
echo "[Warning] - Cannot run nimble tests: Nimble binary not found."
|
echo "[Warning] - Cannot run nimble tests: Nimble binary not found."
|
||||||
|
|
@ -492,26 +501,38 @@ proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string, p
|
||||||
let packagesDir = "pkgstemp"
|
let packagesDir = "pkgstemp"
|
||||||
var errors = 0
|
var errors = 0
|
||||||
try:
|
try:
|
||||||
for name, url, cmd, hasDep in listPackages(part):
|
for name, url, cmd, hasDep, useHead in listPackages(part):
|
||||||
if packageFilter notin name:
|
if packageFilter notin name:
|
||||||
continue
|
continue
|
||||||
inc r.total
|
inc r.total
|
||||||
var test = makeSupTest(url, "", cat)
|
var test = makeSupTest(url, "", cat)
|
||||||
let buildPath = packagesDir / name
|
let buildPath = packagesDir / name
|
||||||
if not existsDir(buildPath):
|
if not existsDir(buildPath):
|
||||||
if hasDep:
|
if useHead:
|
||||||
let installName = if url.len != 0: url else: name
|
let (installCmdLine, installOutput, installStatus) = execCmdEx2("git", ["clone", url, buildPath])
|
||||||
var message: string
|
if installStatus != QuitSuccess:
|
||||||
if not actionRetry(maxRetry = 3, backoffDuration = 1.0,
|
let message = "git clone failed:\n$ " & installCmdLine & "\n" & installOutput
|
||||||
(proc(): bool = nimbleInstall(installName, message))):
|
|
||||||
r.addResult(test, targetC, "", message, reInstallFailed)
|
r.addResult(test, targetC, "", message, reInstallFailed)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let (installCmdLine, installOutput, installStatus) = execCmdEx2("git", ["clone", url, buildPath])
|
if hasDep:
|
||||||
if installStatus != QuitSuccess:
|
var message: string
|
||||||
let message = "git clone failed:\n$ " & installCmdLine & "\n" & installOutput
|
if not actionRetry(maxRetry = 3, backoffDuration = 1.0,
|
||||||
r.addResult(test, targetC, "", message, reInstallFailed)
|
proc: bool =
|
||||||
continue
|
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)
|
||||||
|
continue
|
||||||
|
|
||||||
let cmdArgs = parseCmdLine(cmd)
|
let cmdArgs = parseCmdLine(cmd)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
template pkg1(name: string; hasDeps = false; cmd = "nimble test"; url = ""): untyped =
|
template pkg1(name: string; hasDeps = false; cmd = "nimble test"; url = "", useHead = true): untyped =
|
||||||
packages1.add((name, cmd, hasDeps, url))
|
packages1.add((name, cmd, hasDeps, url, useHead))
|
||||||
|
|
||||||
template pkg2(name: string; hasDeps = false; cmd = "nimble test"; url = ""): untyped =
|
template pkg2(name: string; hasDeps = false; cmd = "nimble test"; url = "", useHead = true): untyped =
|
||||||
packages2.add((name, cmd, hasDeps, url))
|
packages2.add((name, cmd, hasDeps, url, useHead))
|
||||||
|
|
||||||
var packages1*: seq[tuple[name, cmd: string; hasDeps: bool; url: string]] = @[]
|
var packages1*: seq[tuple[name, cmd: string; hasDeps: bool; url: string, useHead: bool]] = @[]
|
||||||
var packages2*: seq[tuple[name, cmd: string; hasDeps: bool; url: string]] = @[]
|
var packages2*: seq[tuple[name, cmd: string; hasDeps: bool; url: string, useHead: bool]] = @[]
|
||||||
|
|
||||||
|
|
||||||
# packages A-M
|
# packages A-M
|
||||||
pkg1 "alea", true
|
pkg1 "alea", true
|
||||||
pkg1 "argparse"
|
pkg1 "argparse"
|
||||||
pkg1 "arraymancer", true, "nim c tests/tests_cpu.nim"
|
# pkg1 "arraymancer", true, "nim c tests/tests_cpu.nim"
|
||||||
pkg1 "ast_pattern_matching", false, "nim c -r --oldgensym:on tests/test1.nim"
|
pkg1 "ast_pattern_matching", false, "nim c -r --oldgensym:on tests/test1.nim"
|
||||||
pkg1 "asyncmysql", true
|
pkg1 "asyncmysql", true
|
||||||
pkg1 "awk", true
|
pkg1 "awk", true
|
||||||
|
|
@ -49,7 +49,7 @@ pkg1 "gnuplot"
|
||||||
pkg1 "hts", false, "nim c -o:htss src/hts.nim"
|
pkg1 "hts", false, "nim c -o:htss src/hts.nim"
|
||||||
# pkg1 "httpauth", true
|
# pkg1 "httpauth", true
|
||||||
pkg1 "illwill", false, "nimble examples"
|
pkg1 "illwill", false, "nimble examples"
|
||||||
pkg1 "inim", true # pending https://github.com/inim-repl/INim/issues/74
|
pkg1 "inim", true
|
||||||
pkg1 "itertools", false, "nim doc src/itertools.nim"
|
pkg1 "itertools", false, "nim doc src/itertools.nim"
|
||||||
pkg1 "iterutils"
|
pkg1 "iterutils"
|
||||||
pkg1 "jstin"
|
pkg1 "jstin"
|
||||||
|
|
@ -90,7 +90,6 @@ pkg2 "nimsvg"
|
||||||
pkg2 "nimwc", true, "nim c nimwc.nim"
|
pkg2 "nimwc", true, "nim c nimwc.nim"
|
||||||
# pkg2 "nimx", true, "nim c --threads:on test/main.nim"
|
# pkg2 "nimx", true, "nim c --threads:on test/main.nim"
|
||||||
# pkg2 "nitter", true, "nim c src/nitter.nim", "https://github.com/zedeus/nitter"
|
# pkg2 "nitter", true, "nim c src/nitter.nim", "https://github.com/zedeus/nitter"
|
||||||
# pending https://github.com/timotheecour/Nim/issues/167 or new git tag for nitter
|
|
||||||
pkg2 "norm", true, "nim c -r tests/tsqliterows.nim"
|
pkg2 "norm", true, "nim c -r tests/tsqliterows.nim"
|
||||||
pkg2 "npeg", false, "nimble testarc"
|
pkg2 "npeg", false, "nimble testarc"
|
||||||
pkg2 "numericalnim", true, "nim c -r tests/test_integrate.nim"
|
pkg2 "numericalnim", true, "nim c -r tests/test_integrate.nim"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue