Skip to content

Commit e18fc69

Browse files
authored
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
1 parent d4022eb commit e18fc69

File tree

2 files changed

+120
-130
lines changed

2 files changed

+120
-130
lines changed

testament/categories.nim

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -452,23 +452,23 @@ type
452452
ppOne
453453
ppTwo
454454

455-
iterator listPackages(part: PkgPart): tuple[name, url, cmd: string, hasDeps: bool, useHead: bool] =
455+
iterator listPackages(part: PkgPart): tuple[name, cmd, url: string, useHead: bool] =
456456
let packageList = parseFile(packageIndex)
457457
let importantList =
458458
case part
459459
of ppOne: important_packages.packages1
460460
of ppTwo: important_packages.packages2
461-
for n, cmd, hasDeps, url, useHead in importantList.items:
461+
for n, cmd, url, useHead in importantList.items:
462462
if url.len != 0:
463-
yield (n, url, cmd, hasDeps, useHead)
463+
yield (n, cmd, url, useHead)
464464
else:
465465
var found = false
466466
for package in packageList.items:
467467
let name = package["name"].str
468468
if name == n:
469469
found = true
470470
let pUrl = package["url"].str
471-
yield (name, pUrl, cmd, hasDeps, useHead)
471+
yield (name, cmd, pUrl, useHead)
472472
break
473473
if not found:
474474
raise newException(ValueError, "Cannot find package '$#'." % n)
@@ -479,16 +479,6 @@ proc makeSupTest(test, options: string, cat: Category): TTest =
479479
result.options = options
480480
result.startTime = epochTime()
481481

482-
proc actionRetry(maxRetry: int, backoffDuration: float, action: proc: bool): bool =
483-
## retry `action` up to `maxRetry` times with exponential backoff and initial
484-
## duraton of `backoffDuration` seconds
485-
var t = backoffDuration
486-
for i in 0..<maxRetry:
487-
if action(): return true
488-
if i == maxRetry - 1: break
489-
sleep(int(t * 1000))
490-
t *= 2 # exponential backoff
491-
492482
proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string, part: PkgPart) =
493483
if nimbleExe == "":
494484
echo "[Warning] - Cannot run nimble tests: Nimble binary not found."
@@ -499,47 +489,48 @@ proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string, p
499489

500490
let packageFileTest = makeSupTest("PackageFileParsed", "", cat)
501491
let packagesDir = "pkgstemp"
492+
createDir(packagesDir)
502493
var errors = 0
503494
try:
504-
for name, url, cmd, hasDep, useHead in listPackages(part):
495+
for name, cmd, url, useHead in listPackages(part):
505496
if packageFilter notin name:
506497
continue
507498
inc r.total
508-
var test = makeSupTest(url, "", cat)
499+
var test = makeSupTest(name, "", cat)
509500
let buildPath = packagesDir / name
501+
510502
if not dirExists(buildPath):
511-
if useHead:
512-
let (installCmdLine, installOutput, installStatus) = execCmdEx2("git", ["clone", url, buildPath])
513-
if installStatus != QuitSuccess:
514-
let message = "git clone failed:\n$ " & installCmdLine & "\n" & installOutput
515-
r.addResult(test, targetC, "", message, reInstallFailed)
503+
let (cloneCmd, cloneOutput, cloneStatus) = execCmdEx2("git", ["clone", url, buildPath])
504+
if cloneStatus != QuitSuccess:
505+
r.addResult(test, targetC, "", cloneCmd & "\n" & cloneOutput, reInstallFailed)
506+
continue
507+
508+
if not useHead:
509+
let (fetchCmd, fetchOutput, fetchStatus) = execCmdEx2("git", ["fetch", "--tags"], workingDir = buildPath)
510+
if fetchStatus != QuitSuccess:
511+
r.addResult(test, targetC, "", fetchCmd & "\n" & fetchOutput, reInstallFailed)
516512
continue
517513

518-
if hasDep:
519-
var message: string
520-
if not actionRetry(maxRetry = 3, backoffDuration = 1.0,
521-
proc: bool =
522-
let (outp, status) = execCmdEx("nimble install -y", workingDir = buildPath)
523-
if status != 0:
524-
message = "'$1' failed:\n$2" % [cmd, outp]
525-
false
526-
else: true
527-
):
528-
r.addResult(test, targetC, "", message, reInstallFailed)
529-
continue
530-
else:
531-
let (installCmdLine, installOutput, installStatus) = execCmdEx2("nimble", ["develop", name, "-y"])
532-
if installStatus != QuitSuccess:
533-
let message = "nimble develop failed:\n$ " & installCmdLine & "\n" & installOutput
534-
r.addResult(test, targetC, "", message, reInstallFailed)
514+
let (describeCmd, describeOutput, describeStatus) = execCmdEx2("git", ["describe", "--tags", "--abbrev=0"], workingDir = buildPath)
515+
if describeStatus != QuitSuccess:
516+
r.addResult(test, targetC, "", describeCmd & "\n" & describeOutput, reInstallFailed)
535517
continue
536518

519+
let (checkoutCmd, checkoutOutput, checkoutStatus) = execCmdEx2("git", ["checkout", describeOutput.strip], workingDir = buildPath)
520+
if checkoutStatus != QuitSuccess:
521+
r.addResult(test, targetC, "", checkoutCmd & "\n" & checkoutOutput, reInstallFailed)
522+
continue
523+
524+
let (installDepsCmd, installDepsOutput, installDepsStatus) = execCmdEx2("nimble", ["install", "--depsOnly", "-y"], workingDir = buildPath)
525+
if installDepsStatus != QuitSuccess:
526+
r.addResult(test, targetC, "", "installing dependencies failed:\n$ " & installDepsCmd & "\n" & installDepsOutput, reInstallFailed)
527+
continue
528+
537529
let cmdArgs = parseCmdLine(cmd)
538530

539-
let (buildCmdLine, buildOutput, buildStatus) = execCmdEx2(cmdArgs[0], cmdArgs[1..^1], workingDir=buildPath)
540-
if buildStatus != QuitSuccess:
541-
let message = "package test failed\n$ " & buildCmdLine & "\n" & buildOutput
542-
r.addResult(test, targetC, "", message, reBuildFailed)
531+
let (buildCmd, buildOutput, status) = execCmdEx2(cmdArgs[0], cmdArgs[1..^1], workingDir = buildPath)
532+
if status != QuitSuccess:
533+
r.addResult(test, targetC, "", "package test failed\n$ " & buildCmd & "\n" & buildOutput, reBuildFailed)
543534
else:
544535
inc r.passed
545536
r.addResult(test, targetC, "", "", reSuccess)

testament/important_packages.nim

Lines changed: 87 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,133 @@
1-
template pkg1(name: string; hasDeps = false; cmd = "nimble test"; url = "", useHead = true): untyped =
2-
packages1.add((name, cmd, hasDeps, url, useHead))
1+
template pkg1(name: string; cmd = "nimble test"; url = "", useHead = true): untyped =
2+
packages1.add((name, cmd, url, useHead))
33

4-
template pkg2(name: string; hasDeps = false; cmd = "nimble test"; url = "", useHead = true): untyped =
5-
packages2.add((name, cmd, hasDeps, url, useHead))
6-
7-
var packages1*: seq[tuple[name, cmd: string; hasDeps: bool; url: string, useHead: bool]] = @[]
8-
var packages2*: seq[tuple[name, cmd: string; hasDeps: bool; url: string, useHead: bool]] = @[]
4+
template pkg2(name: string; cmd = "nimble test"; url = "", useHead = true): untyped =
5+
packages2.add((name, cmd, url, useHead))
96

7+
var packages1*: seq[tuple[name, cmd: string; url: string, useHead: bool]] = @[]
8+
var packages2*: seq[tuple[name, cmd: string; url: string, useHead: bool]] = @[]
109

1110
# packages A-M
12-
# pkg1 "alea", true
11+
# pkg1 "alea"
1312
pkg1 "argparse"
14-
pkg1 "arraymancer", true, "nim c tests/tests_cpu.nim"
15-
#pkg1 "ast_pattern_matching", false, "nim c -r --oldgensym:on tests/test1.nim"
16-
pkg1 "awk", true
13+
pkg1 "arraymancer", "nim c tests/tests_cpu.nim"
14+
#pkg1 "ast_pattern_matching", "nim c -r --oldgensym:on tests/test1.nim"
15+
pkg1 "awk"
1716
pkg1 "bigints", url = "https://github.com/Araq/nim-bigints"
18-
pkg1 "binaryheap", false, "nim c -r binaryheap.nim"
17+
pkg1 "binaryheap", "nim c -r binaryheap.nim"
1918
pkg1 "BipBuffer"
20-
# pkg1 "blscurve", true # pending https://github.com/status-im/nim-blscurve/issues/39
21-
pkg1 "bncurve", true
22-
pkg1 "brainfuck", true, "nim c -d:release -r tests/compile.nim"
23-
pkg1 "bump", true, "nim c --gc:arc -r tests/tbump.nim", "https://github.com/disruptek/bump"
24-
pkg1 "c2nim", false, "nim c testsuite/tester.nim"
19+
# pkg1 "blscurve" # pending https://github.com/status-im/nim-blscurve/issues/39
20+
pkg1 "bncurve"
21+
pkg1 "brainfuck", "nim c -d:release -r tests/compile.nim"
22+
pkg1 "bump", "nim c --gc:arc -r tests/tbump.nim", "https://github.com/disruptek/bump"
23+
pkg1 "c2nim", "nim c testsuite/tester.nim"
2524
pkg1 "cascade"
26-
pkg1 "cello", true
25+
pkg1 "cello"
2726
pkg1 "chroma"
28-
pkg1 "chronicles", true, "nim c -o:chr -r chronicles.nim"
27+
pkg1 "chronicles", "nim c -o:chr -r chronicles.nim"
2928
when not defined(osx): # testdatagram.nim(560, 54): Check failed
30-
pkg1 "chronos", true, "nim c -r -d:release tests/testall"
31-
pkg1 "cligen", false, "nim c -o:cligenn -r cligen.nim"
32-
pkg1 "combparser", false, "nimble test --gc:orc"
29+
pkg1 "chronos", "nim c -r -d:release tests/testall"
30+
pkg1 "cligen", "nim c --path:. -r cligen.nim"
31+
pkg1 "combparser", "nimble test --gc:orc"
3332
pkg1 "compactdict"
34-
pkg1 "comprehension", false, "nimble test", "https://github.com/alehander42/comprehension"
35-
pkg1 "dashing", false, "nim c tests/functional.nim"
33+
pkg1 "comprehension", "nimble test", "https://github.com/alehander42/comprehension"
34+
pkg1 "dashing", "nim c tests/functional.nim"
3635
pkg1 "delaunay"
3736
pkg1 "docopt"
38-
pkg1 "easygl", true, "nim c -o:egl -r src/easygl.nim", "https://github.com/jackmott/easygl"
37+
pkg1 "easygl", "nim c -o:egl -r src/easygl.nim", "https://github.com/jackmott/easygl"
3938
pkg1 "elvis"
40-
pkg1 "fidget", true
41-
pkg1 "fragments", false, "nim c -r fragments/dsl.nim"
39+
pkg1 "fidget"
40+
pkg1 "fragments", "nim c -r fragments/dsl.nim"
4241
pkg1 "gara"
43-
pkg1 "ggplotnim", true, "nim c -d:noCairo -r tests/tests.nim"
44-
# pkg1 "gittyup", true, "nimble test", "https://github.com/disruptek/gittyup"
42+
pkg1 "ggplotnim", "nim c -d:noCairo -r tests/tests.nim"
43+
# pkg1 "gittyup", "nimble test", "https://github.com/disruptek/gittyup"
4544
# pkg1 "glob" # pending https://github.com/citycide/glob/issues/49
46-
pkg1 "gnuplot", false, "nim c gnuplot.nim"
47-
pkg1 "hts", false, "nim c -o:htss src/hts.nim"
48-
# pkg1 "httpauth", true
49-
pkg1 "illwill", false, "nimble examples"
50-
pkg1 "inim", true
51-
pkg1 "itertools", false, "nim doc src/itertools.nim"
45+
pkg1 "gnuplot", "nim c gnuplot.nim"
46+
pkg1 "hts", "nim c -o:htss src/hts.nim"
47+
# pkg1 "httpauth"
48+
pkg1 "illwill", "nimble examples"
49+
pkg1 "inim"
50+
pkg1 "itertools", "nim doc src/itertools.nim"
5251
pkg1 "iterutils"
5352
pkg1 "jstin"
54-
pkg1 "karax", false, "nim c -r tests/tester.nim"
55-
pkg1 "kdtree", false, "nimble test", "https://github.com/jblindsay/kdtree"
53+
pkg1 "karax", "nim c -r tests/tester.nim"
54+
pkg1 "kdtree", "nimble test", "https://github.com/jblindsay/kdtree"
5655
pkg1 "loopfusion"
5756
pkg1 "macroutils"
5857
pkg1 "markdown"
5958
pkg1 "memo"
60-
pkg1 "msgpack4nim", false, "nim c -r tests/test_spec.nim"
59+
pkg1 "msgpack4nim", "nim c -r tests/test_spec.nim"
6160

6261
# these two are special snowflakes
63-
pkg1 "nimcrypto", false, "nim c -r tests/testall.nim"
64-
pkg1 "stint", false, "nim c -o:stintt -r stint.nim"
62+
pkg1 "nimcrypto", "nim c -r tests/testall.nim"
63+
pkg1 "stint", "nim c -o:stintt -r stint.nim"
6564

6665

6766
# packages N-Z
68-
pkg2 "nake", false, "nim c nakefile.nim"
69-
pkg2 "neo", true, "nim c -d:blas=openblas tests/all.nim"
70-
# pkg2 "nesm", false, "nimble tests" # notice plural 'tests'
71-
# pkg2 "nico", true
72-
pkg2 "nicy", false, "nim c -r src/nicy.nim"
73-
pkg2 "nigui", false, "nim c -o:niguii -r src/nigui.nim"
74-
pkg2 "NimData", true, "nim c -o:nimdataa src/nimdata.nim"
75-
pkg2 "nimes", true, "nim c src/nimes.nim"
76-
pkg2 "nimfp", true, "nim c -o:nfp -r src/fp.nim"
77-
pkg2 "nimgame2", true, "nim c nimgame2/nimgame.nim"
78-
pkg2 "nimgen", true, "nim c -o:nimgenn -r src/nimgen/runcfg.nim"
79-
pkg2 "nimlsp", true
80-
pkg2 "nimly", true, "nim c -r tests/test_readme_example.nim"
81-
# pkg2 "nimongo", true, "nimble test_ci"
82-
# pkg2 "nimph", true, "nimble test", "https://github.com/disruptek/nimph"
83-
pkg2 "nimpy", false, "nim c -r tests/nimfrompy.nim"
67+
pkg2 "nake", "nim c nakefile.nim"
68+
pkg2 "neo", "nim c -d:blas=openblas tests/all.nim"
69+
# pkg2 "nesm", "nimble tests" # notice plural 'tests'
70+
# pkg2 "nico"
71+
pkg2 "nicy", "nim c -r src/nicy.nim"
72+
pkg2 "nigui", "nim c -o:niguii -r src/nigui.nim"
73+
pkg2 "NimData", "nim c -o:nimdataa src/nimdata.nim"
74+
pkg2 "nimes", "nim c src/nimes.nim"
75+
pkg2 "nimfp", "nim c -o:nfp -r src/fp.nim"
76+
pkg2 "nimgame2", "nim c nimgame2/nimgame.nim"
77+
pkg2 "nimgen", "nim c -o:nimgenn -r src/nimgen/runcfg.nim"
78+
pkg2 "nimlsp"
79+
pkg2 "nimly", "nim c -r tests/test_readme_example.nim"
80+
# pkg2 "nimongo", "nimble test_ci"
81+
# pkg2 "nimph", "nimble test", "https://github.com/disruptek/nimph"
82+
pkg2 "nimpy", "nim c -r tests/nimfrompy.nim"
8483
pkg2 "nimquery"
85-
pkg2 "nimsl", true
84+
pkg2 "nimsl"
8685
pkg2 "nimsvg"
87-
pkg2 "nimterop", true, "nimble minitest"
88-
pkg2 "nimwc", true, "nim c nimwc.nim"
89-
# pkg2 "nimx", true, "nim c --threads:on test/main.nim"
90-
# pkg2 "nitter", true, "nim c src/nitter.nim", "https://github.com/zedeus/nitter"
91-
pkg2 "norm", true, "nim c -r tests/tsqliterows.nim"
92-
pkg2 "npeg", false, "nimble testarc"
93-
pkg2 "numericalnim", true, "nim c -r tests/test_integrate.nim"
86+
pkg2 "nimterop", "nimble minitest"
87+
pkg2 "nimwc", "nim c nimwc.nim"
88+
# pkg2 "nimx", "nim c --threads:on test/main.nim"
89+
# pkg2 "nitter", "nim c src/nitter.nim", "https://github.com/zedeus/nitter"
90+
pkg2 "norm", "nim c -r tests/tsqliterows.nim"
91+
pkg2 "npeg", "nimble testarc"
92+
pkg2 "numericalnim", "nim c -r tests/test_integrate.nim"
9493
pkg2 "optionsutils"
95-
pkg2 "ormin", true, "nim c -o:orminn ormin.nim"
94+
pkg2 "ormin", "nim c -o:orminn ormin.nim"
9695
pkg2 "parsetoml"
9796
pkg2 "patty"
98-
pkg2 "plotly", true, "nim c examples/all.nim"
97+
pkg2 "plotly", "nim c examples/all.nim"
9998
pkg2 "pnm"
10099
pkg2 "polypbren"
101-
pkg2 "prologue", true, "nimble tcompile"
102-
pkg2 "protobuf", true, "nim c -o:protobuff -r src/protobuf.nim"
100+
pkg2 "prologue", "nimble tcompile"
101+
pkg2 "protobuf", "nim c -o:protobuff -r src/protobuf.nim"
103102
pkg2 "pylib"
104103
pkg2 "rbtree"
105-
pkg2 "react", false, "nimble example"
106-
pkg2 "regex", true, "nim c src/regex"
107-
pkg2 "result", false, "nim c -r result.nim"
108-
pkg2 "RollingHash", false, "nim c -r tests/test_cyclichash.nim"
109-
pkg2 "rosencrantz", false, "nim c -o:rsncntz -r rosencrantz.nim"
110-
pkg2 "sdl1", false, "nim c -r src/sdl.nim"
111-
pkg2 "sdl2_nim", false, "nim c -r sdl2/sdl.nim"
112-
pkg2 "sigv4", true, "nim c --gc:arc -r sigv4.nim", "https://github.com/disruptek/sigv4"
113-
pkg2 "snip", false, "nimble test", "https://github.com/genotrance/snip"
104+
pkg2 "react", "nimble example"
105+
pkg2 "regex", "nim c src/regex"
106+
pkg2 "result", "nim c -r result.nim"
107+
pkg2 "RollingHash", "nim c -r tests/test_cyclichash.nim"
108+
pkg2 "rosencrantz", "nim c -o:rsncntz -r rosencrantz.nim"
109+
pkg2 "sdl1", "nim c -r src/sdl.nim"
110+
pkg2 "sdl2_nim", "nim c -r sdl2/sdl.nim"
111+
pkg2 "sigv4", "nim c --gc:arc -r sigv4.nim", "https://github.com/disruptek/sigv4"
112+
pkg2 "snip", "nimble test", "https://github.com/genotrance/snip"
114113
pkg2 "strslice"
115-
pkg2 "strunicode", true, "nim c -r src/strunicode.nim"
114+
pkg2 "strunicode", "nim c -r src/strunicode.nim"
116115
pkg2 "synthesis"
117-
pkg2 "telebot", true, "nim c -o:tbot -r src/telebot.nim"
116+
pkg2 "telebot", "nim c -o:tbot -r src/telebot.nim"
118117
pkg2 "tempdir"
119118
pkg2 "templates"
120-
pkg2 "tensordsl", false, "nim c -r tests/tests.nim", "https://[email protected]/krux02/tensordslnim.git"
121-
pkg2 "terminaltables", false, "nim c src/terminaltables.nim"
122-
pkg2 "termstyle", false, "nim c -r termstyle.nim"
119+
pkg2 "tensordsl", "nim c -r tests/tests.nim", "https://[email protected]/krux02/tensordslnim.git"
120+
pkg2 "terminaltables", "nim c src/terminaltables.nim"
121+
pkg2 "termstyle", "nim c -r termstyle.nim"
123122
pkg2 "timeit"
124123
pkg2 "timezones"
125124
pkg2 "tiny_sqlite"
126-
pkg2 "unicodedb", false, "nim c -d:release -r tests/tests.nim"
127-
pkg2 "unicodeplus", true, "nim c -d:release -r tests/tests.nim"
125+
pkg2 "unicodedb", "nim c -d:release -r tests/tests.nim"
126+
pkg2 "unicodeplus", "nim c -d:release -r tests/tests.nim"
128127
pkg2 "unpack"
129-
pkg2 "websocket", false, "nim c websocket.nim"
130-
# pkg2 "winim", true
128+
pkg2 "websocket", "nim c websocket.nim"
129+
# pkg2 "winim"
131130
pkg2 "with"
132131
pkg2 "ws"
133-
pkg2 "yaml", false, "nim build"
134-
pkg2 "zero_functional", false, "nim c -r -d:nimWorkaround14447 test.nim"
132+
pkg2 "yaml", "nim build"
133+
pkg2 "zero_functional", "nim c -r -d:nimWorkaround14447 test.nim"

0 commit comments

Comments
 (0)