From c60916a2aff121fc0220f9452803a7bcfb6300d0 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 8 Jan 2019 04:08:19 -0800 Subject: [PATCH] [CI] fixes #10041 move bulk of `travis` and `appveyor` logic to koch.nim (#10183) --- .travis.yml | 21 +++------------------ appveyor.yml | 18 +----------------- koch.nim | 46 +++++++++++++++++++++++++++++++++++++++++++--- tools/kochdocs.nim | 6 ++++++ 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index abd115701f..32a40bcaf0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,26 +40,11 @@ before_script: - sh build.sh - cd .. - export PATH=$(pwd)/bin${PATH:+:$PATH} + - echo PATH:${PATH} + script: - nim c koch - - env NIM_COMPILE_TO_CPP=false ./koch boot - - ./koch boot -d:release - - ./koch nimble - - nim e tests/test_nimscript.nims - #- nimble install zip -y - #- nimble install opengl - #- nimble install sdl1 - #- nimble install jester@#head -y - #- nimble install niminst - - nim c -d:nimCoroutines testament/tester - - testament/tester --pedantic all -d:nimCoroutines - - nim c -o:bin/nimpretty nimpretty/nimpretty.nim - - nim c -r nimpretty/tester.nim - - ./koch docs --git.commit:devel - - ./koch csource - - ./koch nimsuggest - - nim c -r nimsuggest/tester - - nim c -r nimdoc/tester + - ./koch runCI before_deploy: # Make https://nim-lang.github.io/Nim work the same as https://nim-lang.github.io/Nim/overview.html diff --git a/appveyor.yml b/appveyor.yml index 9c8525d724..8c4b2a07e7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -44,22 +44,6 @@ install: build_script: - bin\nim c koch - - koch boot -d:release - - koch nimble - - nim e tests/test_nimscript.nims - - nim c -o:bin/nimpretty.exe nimpretty/nimpretty.nim - - nim c -r nimpretty/tester.nim -# - nimble install zip -y -# - nimble install opengl -y -# - nimble install sdl1 -y -# - nimble install jester@#head -y - - nim c -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester - - nim c -d:nimCoroutines testament/tester - -test_script: - - testament\tester --pedantic all -d:nimCoroutines - - nim c -r nimdoc\tester -# - koch csource -# - koch zip + - koch runCI deploy: off diff --git a/koch.nim b/koch.nim index 3082dba8f2..afdce30837 100644 --- a/koch.nim +++ b/koch.nim @@ -26,6 +26,7 @@ import import tools / kochdocs const VersionAsString = system.NimVersion +const env_NIM_COMPILE_TO_CPP = "NIM_COMPILE_TO_CPP" const HelpText = """ @@ -56,6 +57,7 @@ Boot options: for bootstrapping Commands for core developers: + runCI runs continuous integration (CI), eg from travis docs [options] generates the full documentation csource -d:release builds the C sources for installation pdf builds the PDF documentation @@ -272,8 +274,9 @@ proc boot(args: string) = var output = "compiler" / "nim".exe var finalDest = "bin" / "nim".exe # default to use the 'c' command: - let defaultCommand = if getEnv("NIM_COMPILE_TO_CPP", "false") == "true": "cpp" else: "c" + let defaultCommand = if getEnv(env_NIM_COMPILE_TO_CPP, "false") == "true": "cpp" else: "c" let bootOptions = if args.len == 0 or args.startsWith("-"): defaultCommand else: "" + echo "boot: defaultCommand: ", defaultCommand, " bootOptions: ", bootOptions let smartNimcache = (if "release" in args: "nimcache/r_" else: "nimcache/d_") & hostOs & "_" & hostCpu @@ -352,8 +355,8 @@ proc winReleaseArch(arch: string) = # Rebuilding koch is necessary because it uses its pointer size to # determine which mingw link to put in the NSIS installer. nimexec "c --cpu:$# koch" % cpu - exec "koch boot -d:release --cpu:$#" % cpu - exec "koch --latest zip -d:release" + kochExec "boot -d:release --cpu:$#" % cpu + kochExec "--latest zip -d:release" overwriteFile r"build\nim-$#.zip" % VersionAsString, r"web\upload\download\nim-$#_x$#.zip" % [VersionAsString, arch] @@ -428,6 +431,42 @@ proc xtemp(cmd: string) = finally: copyExe(d / "bin" / "nim_backup".exe, d / "bin" / "nim".exe) +proc runCI(cmd: string) = + doAssert cmd.len == 0, cmd # avoid silently ignoring + echo "runCI:", cmd + # note(@araq): Do not replace these commands with direct calls (eg boot()) + # as that would weaken our testing efforts. + when defined(posix): # appveyor (on windows) didn't run this + # todo: implement `execWithEnv` + exec("env NIM_COMPILE_TO_CPP=false $1 boot" % kochExe.quoteShell) + kochExec "boot -d:release" + kochExec "nimble" + exec "nim e tests/test_nimscript.nims" + + when false: + for pkg in "zip opengl sdl1 jester@#head niminst".split: + exec "nimble install -y" & pkg + + when defined(windows): + # note: will be over-written below + exec "nim c -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester" + when false: + kochExec "csource" + kochExec "zip" + + # main bottleneck: runs all main tests + exec "nim c -r -d:nimCoroutines testament/tester --pedantic all -d:nimCoroutines" + exec "nim c -r nimdoc/tester" + + nimCompile "nimpretty/nimpretty.nim" + exec "nim c -r nimpretty/tester.nim" + + when defined(posix): + kochExec "docs --git.commit:devel" + kochExec "csource" + kochExec "nimsuggest" + exec "nim c -r nimsuggest/tester" + proc pushCsources() = if not dirExists("../csources/.git"): quit "[Error] no csources git repository found" @@ -536,6 +575,7 @@ when isMainModule: of "distrohelper": geninstall() of "install": install(op.cmdLineRest) of "testinstall": testUnixInstall(op.cmdLineRest) + of "runci": runCI(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest) of "temp": temp(op.cmdLineRest) of "xtemp": xtemp(op.cmdLineRest) diff --git a/tools/kochdocs.nim b/tools/kochdocs.nim index 6741fcf5d8..19b0b3d78a 100644 --- a/tools/kochdocs.nim +++ b/tools/kochdocs.nim @@ -51,6 +51,12 @@ proc execCleanPath*(cmd: string, if execShellCmd(cmd) != 0: quit("FAILURE", errorcode) putEnv("PATH", prevPath) +let kochExe* = os.getAppFilename() + # note: assumes `kochdocs` is only used by koch.nim + +proc kochExec*(cmd: string) = + exec kochExe.quoteShell & " " & cmd + proc nimexec*(cmd: string) = # Consider using `nimCompile` instead exec findNim() & " " & cmd