3 Commits
0.5.0 ... 0.5.1

8 changed files with 32 additions and 18 deletions

View File

@ -3,8 +3,7 @@ import cliutils, docopt, os, sequtils, strutils, tempfile, uuids
import strawbosspkg/configuration
import strawbosspkg/core
import strawbosspkg/server
let SB_VER = "0.5.0"
import strawbosspkg/version
proc logProcOutput*(outMsg, errMsg: TaintedString, cmd: string) =
let prefix = if cmd.len > 0: cmd & ": " else: ""
@ -26,7 +25,7 @@ Options
(strawboss.config.json).
"""
let args = docopt(doc, version = "strawboss v" & SB_VER)
let args = docopt(doc, version = "strawboss v" & SB_VERSION)
let cfgFile = if args["--config-file"]: $args["--config-file"]
else: "strawboss.config.json"

View File

@ -58,6 +58,7 @@ type
debug*: bool
logLevel*: Level
pathToExe*: string
port*: int
projects*: seq[ProjectDef]
pwdCost*: int8
users*: seq[UserRef]
@ -83,6 +84,7 @@ proc `==`*(a, b: StrawBossConfig): bool =
a.buildDataDir == b.buildDataDir and
a.authSecret == b.authSecret and
a.pwdCost == b.pwdCost and
a.port == b.port and
a.maintenancePeriod == b.maintenancePeriod and
a.logLevel == b.logLevel and
sameContents(a.users, b.users) and
@ -144,6 +146,7 @@ proc parseStrawBossConfig*(jsonCfg: JsonNode): StrawBossConfig =
buildDataDir: jsonCfg.getIfExists("buildDataDir").getStr("build-data"),
authSecret: jsonCfg.getOrFail("authSecret", "strawboss config").getStr,
debug: jsonCfg.getIfExists("debug").getBool(false),
port: int(jsonCfg.getIfExists("port").getInt(8180)),
pwdCost: int8(jsonCfg.getOrFail("pwdCost", "strawboss config").getInt),
projects: jsonCfg.getIfExists("projects").getElems.mapIt(parseProjectDef(it)),
maintenancePeriod: int(jsonCfg.getIfExists("maintenancePeriod").getInt(10000)),
@ -296,6 +299,7 @@ proc `%`*(cfg: StrawBossConfig): JsonNode =
"buildDataDir": cfg.buildDataDir,
"authSecret": cfg.authSecret,
"debug": cfg.debug,
"port": cfg.port,
"projects": %cfg.projects,
"pwdCost": cfg.pwdCost,
"maintenancePeriod": cfg.maintenancePeriod,

View File

@ -7,7 +7,7 @@ from asyncnet import send
from re import re, find
from timeutils import trimNanoSec
import ./configuration, ./core
import ./configuration, ./core, ./version
type
Session = object
@ -161,13 +161,13 @@ proc start*(cfg: StrawBossConfig): void =
var workers: seq[Worker] = @[]
settings:
port = Port(8180)
port = Port(cfg.port)
appName = "/api"
routes:
get "/ping":
resp($(%"pong"), JSON)
get "/version":
resp($(%("strawboss v" & SB_VERSION)), JSON)
post "/auth-token":
var uname, pwd: string

View File

@ -0,0 +1,2 @@
const SB_VERSION* = "0.5.1"

View File

@ -6,6 +6,7 @@
{ "name": "bob@builder.com", "hashedPwd": "$2a$11$lVZ9U4optQMhzPh0E9A7Yu6XndXblUF3gCa.zmEvJy4F.4C4718b." },
{ "name": "sam@sousa.com", "hashedPwd": "testvalue" }
],
"port": 8180,
"pwdCost": 11,
"projects": [
{ "name": "dummy-project",

View File

@ -6,6 +6,7 @@ from langutils import sameContents
import ../testutil
import ../../../main/nim/strawbosspkg/configuration
import ../../../main/nim/strawbosspkg/server
import ../../../main/nim/strawbosspkg/version
let apiBase = "http://localhost:8180/api"
let cfgFilePath = "src/test/json/strawboss.config.json"
@ -40,11 +41,11 @@ suite "strawboss server":
let tok = toJWT(cfg, session)
check fromJWT(cfg, tok) == session
test "ping":
let resp = http.get(apiBase & "/ping")
test "version":
let resp = http.get(apiBase & "/version")
check:
resp.status.startsWith("200")
resp.body == "\"pong\""
resp.body == "\"strawboss v" & SB_VERSION & "\""
test "fail auth":
let resp = http.post(apiBase & "/auth-token",

View File

@ -1,7 +1,7 @@
# Package
bin = @["strawboss"]
version = "0.5.0"
version = "0.5.1"
author = "Jonathan Bernard"
description = "My personal continious integration worker."
license = "MIT"
@ -44,3 +44,8 @@ task test, "Runs both the unit and functional test suites.":
echo "\nRunning functional tests."
echo "-------------------------"
exec "src/test/nim/run_functional_tests"
task dist, "Creates distributable package.":
exec "nimble build"
mkdir "dist"
exec "cp strawboss strawboss.config.json dist/."

View File

@ -1,24 +1,26 @@
{
"name": "strawboss",
"containerImage": "nimlang/nim:0.19.0",
"steps": {
"compile": {
"artifacts": ["strawboss"],
"stepCmd": "docker run -v `pwd`:/usr/src/strawboss -w /usr/src/strawboss jdbernard/nim:0.17.2 nimble install"
"containerImage": "nimlang/nim:0.19.0",
"stepCmd": "nimble build"
},
"unittest": {
"depends": ["compile"],
"stepCmd": "docker run -v `pwd`:/usr/src/strawboss -v $compile_DIR:/usr/build/strawboss -w /usr/src/strawboss -i jdbernard/nim:0.17.2 /bin/bash",
"stepCmd": "/bin/bash",
"cmdInput": [
"cp /usr/build/strawboss/strawboss .",
"cp $compile_DIR/strawboss .",
"nimble install --depsOnly",
"nim c -r src/test/nim/run_unit_tests"
]
},
"functest": {
"depends": ["compile"],
"stepCmd": "docker run -v `pwd`:/usr/src/strawboss -v $compile_DIR:/usr/build/strawboss -w /usr/src/strawboss -i jdbernard/nim:0.17.2 /bin/bash",
"stepCmd": "/bin/bash",
"cmdInput": [
"cp /usr/build/strawboss/strawboss .",
"cp $compile_DIR/strawboss .",
"nimble install --depsOnly",
"nim c -r src/test/nim/run_functional_tests"
]
@ -26,9 +28,9 @@
"build": {
"artifacts": ["strawboss-$VERSION.zip"],
"depends": ["compile", "unittest", "functest"],
"stepCmd": "docker run -v `pwd`:/usr/src/strawboss -v $compile_DIR:/usr/build/strawboss -w /usr/src/strawboss -i jdbernard/nim:0.17.2 /bin/bash",
"stepCmd": "/bin/bash",
"cmdInput": [
"cp /usr/build/strawboss/strawboss .",
"cp $compile_DIR/strawboss .",
"zip strawboss-$VERSION.zip strawboss strawboss.config.json example.json src/main/systemd/strawboss.service"
]
}