From 283d72ee3edb27dc107c073ff250b7060214988a Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:55:37 +0000 Subject: [PATCH] test Build nimble with `-d:nimNimbleBootstrap` --- .github/workflows/test.yml | 5 ++++ tests/private/clone.nim | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/private/clone.nim diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bdcce655..19ba7804 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,3 +37,8 @@ jobs: # there's no need to add nimblepkg unit tests -- # they are run by tmoduletests.nim - run: ./src/nimble install -y + - name: Build nimble with `-d:nimNimbleBootstrap` + run: | + nim c -d:release -r tests/private/clone.nim + nim c -d:nimNimbleBootstrap -d:release src/nimble.nim + diff --git a/tests/private/clone.nim b/tests/private/clone.nim new file mode 100644 index 00000000..a4716fad --- /dev/null +++ b/tests/private/clone.nim @@ -0,0 +1,49 @@ +import std/[os, uri, strformat] +import std/private/gitutils + +when defined(nimPreviewSlimSystem): + import std/assertions + +proc exec(cmd: string) = + echo "deps.cmd: " & cmd + let status = execShellCmd(cmd) + doAssert status == 0, cmd + +proc execRetry(cmd: string) = + let ok = retryCall(call = block: + let status = execShellCmd(cmd) + let result = status == 0 + if not result: + echo fmt"failed command: '{cmd}', status: {status}" + result) + doAssert ok, cmd + +proc cloneDependency(destDirBase: string, url: string, commit = commitHead, + appendRepoName = true) = + let destDirBase = destDirBase.absolutePath + let p = url.parseUri.path + let name = p.splitFile.name + var destDir = destDirBase + if appendRepoName: destDir = destDir / name + let quotedDestDir = destDir.quoteShell + if not dirExists(destDir): + # note: old code used `destDir / .git` but that wouldn't prevent git clone + # from failing + execRetry fmt"git clone -q {url} {quotedDestDir}" + if isGitRepo(destDir): + let oldDir = getCurrentDir() + setCurrentDir(destDir) + try: + execRetry "git fetch -q" + exec fmt"git checkout -q {commit}" + finally: + setCurrentDir(oldDir) + else: + quit "FAILURE: " & destdir & " already exists but is not a git repo" + +proc command = + const distDir = "dist" + const commit = "3fa15df7d27ecef624ed932d60f63d6a8949618d" + cloneDependency(distDir, "https://github.com/nim-lang/checksums.git", commit) + +command()