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/configuration
import strawbosspkg/core import strawbosspkg/core
import strawbosspkg/server import strawbosspkg/server
import strawbosspkg/version
let SB_VER = "0.5.0"
proc logProcOutput*(outMsg, errMsg: TaintedString, cmd: string) = proc logProcOutput*(outMsg, errMsg: TaintedString, cmd: string) =
let prefix = if cmd.len > 0: cmd & ": " else: "" let prefix = if cmd.len > 0: cmd & ": " else: ""
@ -26,7 +25,7 @@ Options
(strawboss.config.json). (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"] let cfgFile = if args["--config-file"]: $args["--config-file"]
else: "strawboss.config.json" else: "strawboss.config.json"

View File

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

View File

@ -7,7 +7,7 @@ from asyncnet import send
from re import re, find from re import re, find
from timeutils import trimNanoSec from timeutils import trimNanoSec
import ./configuration, ./core import ./configuration, ./core, ./version
type type
Session = object Session = object
@ -161,13 +161,13 @@ proc start*(cfg: StrawBossConfig): void =
var workers: seq[Worker] = @[] var workers: seq[Worker] = @[]
settings: settings:
port = Port(8180) port = Port(cfg.port)
appName = "/api" appName = "/api"
routes: routes:
get "/ping": get "/version":
resp($(%"pong"), JSON) resp($(%("strawboss v" & SB_VERSION)), JSON)
post "/auth-token": post "/auth-token":
var uname, pwd: string 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": "bob@builder.com", "hashedPwd": "$2a$11$lVZ9U4optQMhzPh0E9A7Yu6XndXblUF3gCa.zmEvJy4F.4C4718b." },
{ "name": "sam@sousa.com", "hashedPwd": "testvalue" } { "name": "sam@sousa.com", "hashedPwd": "testvalue" }
], ],
"port": 8180,
"pwdCost": 11, "pwdCost": 11,
"projects": [ "projects": [
{ "name": "dummy-project", { "name": "dummy-project",

View File

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

View File

@ -1,7 +1,7 @@
# Package # Package
bin = @["strawboss"] bin = @["strawboss"]
version = "0.5.0" version = "0.5.1"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "My personal continious integration worker." description = "My personal continious integration worker."
license = "MIT" license = "MIT"
@ -44,3 +44,8 @@ task test, "Runs both the unit and functional test suites.":
echo "\nRunning functional tests." echo "\nRunning functional tests."
echo "-------------------------" echo "-------------------------"
exec "src/test/nim/run_functional_tests" 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", "name": "strawboss",
"containerImage": "nimlang/nim:0.19.0",
"steps": { "steps": {
"compile": { "compile": {
"artifacts": ["strawboss"], "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": { "unittest": {
"depends": ["compile"], "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": [ "cmdInput": [
"cp /usr/build/strawboss/strawboss .", "cp $compile_DIR/strawboss .",
"nimble install --depsOnly", "nimble install --depsOnly",
"nim c -r src/test/nim/run_unit_tests" "nim c -r src/test/nim/run_unit_tests"
] ]
}, },
"functest": { "functest": {
"depends": ["compile"], "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": [ "cmdInput": [
"cp /usr/build/strawboss/strawboss .", "cp $compile_DIR/strawboss .",
"nimble install --depsOnly", "nimble install --depsOnly",
"nim c -r src/test/nim/run_functional_tests" "nim c -r src/test/nim/run_functional_tests"
] ]
@ -26,9 +28,9 @@
"build": { "build": {
"artifacts": ["strawboss-$VERSION.zip"], "artifacts": ["strawboss-$VERSION.zip"],
"depends": ["compile", "unittest", "functest"], "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": [ "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" "zip strawboss-$VERSION.zip strawboss strawboss.config.json example.json src/main/systemd/strawboss.service"
] ]
} }