Skip to content

final clean up #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ jobs:
nim-version: 'stable'
yes: true

- name: Install checksums
run: nimble install -y checksums
- name: Install dependencies
run: nimble install -y

- name: build nimble
run: |
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ jobs:
- name: Install Mercurial on macOS
if: matrix.os == 'macos-latest'
run: brew install mercurial
- name: Install checksums
run: nimble install checksums
- name: Install dependencies
run: nimble install -y
- name: Run nim c -r tester
run: |
cd tests
nim c -r tester
# 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

49 changes: 49 additions & 0 deletions tests/private/clone.nim
Original file line number Diff line number Diff line change
@@ -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()