-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathnorm.nimble
88 lines (59 loc) · 2.13 KB
/
norm.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Package
version = "2.8.5"
author = "Constantine Molchanov"
description = "Nim ORM for SQLite and PostgreSQL."
license = "MIT"
srcDir = "src"
skipDirs = @["tests", "htmldocs"]
# Dependencies
requires "nim >= 1.4.0", "lowdb >= 0.2.1"
when NimMajor >= 2:
taskRequires "setupBook", "nimib >= 0.3.8", "nimibook >= 0.3.1"
taskRequires "benchmark", "benchy >= 0.0.1"
else:
# Task Dependencies
requires "nimib >= 0.3.8"
requires "nimibook >= 0.3.1"
requires "benchy >= 0.0.1"
# Tasks
task test, "Run tests":
exec "testament all"
task setupBook, "Compiles the nimibook CLI-binary used for generating the docs":
exec "nim c -d:release nbook.nim"
before book:
rmDir "docs"
exec "nimble setupBook"
task book, "Generate book":
exec "./nbook --mm:orc --deepcopy:on update"
exec "./nbook --mm:orc --deepcopy:on build"
after book:
cpFile("CNAME", "docs/CNAME")
before docs:
rmDir "docs/apidocs"
task docs, "Generate docs":
exec "nimble doc --outdir:docs/apidocs --project --index:on src/norm"
task benchmark, "Run benchmark":
exec "nim r benchmark/bulkUpdate.nim"
# For local development
import std/[strutils, sequtils, strformat]
let postgresName = "norm-postgres-testcontainer"
putEnv("PGHOST", "localhost") ## Mandatory for all Postgres tests
proc asSudo(params: seq[string]): bool =
return params.anyIt(it == "sudo")
task startContainers, "Starts a postgres container for running tests against":
var command = fmt"""docker run -d -e POSTGRES_PASSWORD="postgres" --name {postgresName} --rm -p 5432:5432 postgres"""
if commandLineParams.asSudo():
command = fmt"sudo {command}"
exec command
task stopContainers, "Stops a postgres container used for norm tests":
var command = fmt"""docker stop {postgresName}"""
if commandLineParams.asSudo():
command = fmt"sudo {command}"
exec command
task allTests, "Run all tests via testament":
exec "testament all"
task singleTest, "Run containerized tests for a specific test file":
let testFiles = commandLineParams.filterIt(it.startsWith("test"))
for file in testFiles:
let command = fmt"nimble c -r {file}"
exec command