diff --git a/README.md b/README.md index 9206636..2a607f6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ * Configuration is two-part. Pipeline, step, and artifact definition are part of the project configuration (.strawboss.json? yaml?). Environment configuration lives on the strawboss server (supplies DB info, etc.). -* REST API? * Step execution happens within the root directory of a fresh copy of the repo. Commit identifiers (hash/ref/etc.) are supplied when a build is triggered and the fresh copy is checked out at that reference. @@ -114,7 +113,12 @@ object. The top level keys are: * `versionCmd` *(optional)*: a command to be run in a shell (`sh`-compatible) that is expected to print the current version of the project on `stdout`. - *(defaults to `git describe --tags --always`)*. + It is important to note that if you supply a verion command it should provide + a unique result for every commit in the repository. StrawBoss is built around + the assumptions that builds are repeatable and that every buildable point has + a unique version id. This is the reason that StrawBoss does not create uniue + IDs for individual builds. The combination of project name, build step, and + version *is* the build ID. *(defaults to `git describe --tags --always`)*. #### Step Definition @@ -268,7 +272,7 @@ asset. To avoid `git` complications it is stored as a Gzipped TAR file and unpacked to a temporary directory as part of the functional test process. As the functional tests are more time-consuming and intensive, they are -expected to bu run when performing a build. +expected to be run when performing a build. To run the functional tests, use the `functest` nimble task: diff --git a/api.rst b/api.rst index 69e785c..3c2d2a3 100644 --- a/api.rst +++ b/api.rst @@ -6,10 +6,10 @@ - GET /api/project/ -- TODO * GET /api/project//runs -- list summary information for all runs * GET /api/project//runs/active -- list summary information about all currently active runs -- GET /api/project//runs/ -- list detailed information about a specific run ✓ GET /api/project//versions -- list the versions of this project that have been built * GET /api/project//version/ -- return detailed project definition (include steps) at a specific version -- GET /api/project//step/ -- return detailed step information (include runs) +- GET /api/project//step/ -- return detailed step information (include runs for different versions) +- GET /api/project//step//run/ -- list detailed information about a specific run * POST /api/project//step//run/ -- kick off a run diff --git a/src/main/nim/strawboss.nim b/src/main/nim/strawboss.nim index 958afe2..a917a56 100644 --- a/src/main/nim/strawboss.nim +++ b/src/main/nim/strawboss.nim @@ -1,4 +1,4 @@ -import cliutils, docopt, os, sequtils, tempfile, uuids +import cliutils, docopt, os, sequtils, tempfile import strawbosspkg/configuration import strawbosspkg/core @@ -30,9 +30,6 @@ Options -r --reference Build the project at this commit reference. - -i --run-id Use the given UUID as the run ID. If not given, a - new UUID is generated for this run. - -w --workspace Use the given directory as the build workspace. """ @@ -57,7 +54,6 @@ Options try: let req = RunRequest( - id: if args["--run-id"]: parseUUID($args["--run-id"]) else: genUUID(), projectName: $args[""], stepName: $args[""], buildRef: if args["--reference"]: $args["--reference"] else: nil, diff --git a/src/main/nim/strawbosspkg/configuration.nim b/src/main/nim/strawbosspkg/configuration.nim index a39b5c9..3a6ba34 100644 --- a/src/main/nim/strawbosspkg/configuration.nim +++ b/src/main/nim/strawbosspkg/configuration.nim @@ -1,4 +1,4 @@ -import cliutils, logging, json, os, nre, sequtils, strtabs, tables, times, uuids +import cliutils, logging, json, os, nre, sequtils, strtabs, tables, times from langutils import sameContents from typeinfo import toAny @@ -24,7 +24,6 @@ type envVars*: StringTableRef RunRequest* = object - id*: UUID projectName*, stepName*, buildRef*, workspaceDir*: string forceRebuild*: bool @@ -69,7 +68,6 @@ proc `==`*(a, b: StrawBossConfig): bool = proc `==`*(a, b: RunRequest): bool = result = - a.id == b.id and a.projectName == b.projectName and a.stepName == b.stepName and a.buildRef == b.buildRef and @@ -197,7 +195,6 @@ proc loadBuildStatus*(statusFile: string): BuildStatus = proc parseRunRequest*(reqJson: JsonNode): RunRequest = result = RunRequest( - id: parseUUID(reqJson.getOrFail("id", "RunRequest").getStr), projectName: reqJson.getOrFail("projectName", "RunRequest").getStr, stepName: reqJson.getOrFail("stepName", "RunRequest").getStr, buildRef: reqJson.getOrFail("buildRef", "RunRequest").getStr, @@ -223,7 +220,6 @@ proc `%`*(p: ProjectDef): JsonNode = proc `%`*(req: RunRequest): JsonNode = result = %* { - "id": $req.id, "projectName": req.projectName, "stepName": req.stepName, "buildRef": req.buildRef, diff --git a/src/main/nim/strawbosspkg/core.nim b/src/main/nim/strawbosspkg/core.nim index 6ff153b..922b94e 100644 --- a/src/main/nim/strawbosspkg/core.nim +++ b/src/main/nim/strawbosspkg/core.nim @@ -1,6 +1,8 @@ -import cliutils, logging, nre, os, osproc, sequtils, streams, strtabs, strutils, tables, uuids +import cliutils, logging, json, os, osproc, sequtils, streams, + strtabs, strutils, tables -import configuration +import nre except toSeq +import ./configuration from posix import link type @@ -185,10 +187,6 @@ proc initiateRun*(cfg: StrawBossConfig, req: RunRequest, if not existsDir(cfg.artifactsRepo & "/" & projectDef.name & "/run-requests"): createDir(cfg.artifactsRepo & "/" & projectDef.name & "/run-requests") - # Save the run request - writeFile(cfg.artifactsRepo & "/" & projectDef.name & - "/run-requests/" & $req.id & ".json", $req) - # Read in the existing system environment var env = loadEnv() env["GIT_DIR"] = ".git" diff --git a/src/main/nim/strawbosspkg/server.nim b/src/main/nim/strawbosspkg/server.nim index cda8669..d6760b6 100644 --- a/src/main/nim/strawbosspkg/server.nim +++ b/src/main/nim/strawbosspkg/server.nim @@ -1,10 +1,9 @@ import algorithm, asyncdispatch, bcrypt, cliutils, jester, json, jwt, logging, - os, osproc, sequtils, strutils, tempfile, times, unittest, uuids + os, osproc, sequtils, strutils, tempfile, times, unittest import ./configuration, ./core type Worker = object - runId*: UUID process*: Process workingDir*: string @@ -77,11 +76,10 @@ proc spawnWorker(cfg: StrawBossConfig, req: RunRequest): Worker = let dir = mkdtemp() var args = @["run", req.projectName, req.stepName, "-r", req.buildRef, - "-w", dir, "-c", cfg.filePath, "-i", $req.id] + "-w", dir, "-c", cfg.filePath] if req.forceRebuild: args.add("-f") debug "Launching worker: " & cfg.pathToExe & " " & args.join(" ") result = Worker( - runId: req.id, process: startProcess(cfg.pathToExe, ".", args, loadEnv(), {poUsePath}), workingDir: dir) @@ -267,14 +265,6 @@ proc start*(cfg: StrawBossConfig): void = #resp($(%statuses), JSON) resp(Http501, makeJsonResp(Http501), JSON) - get "/project/@projectName/runs/@runId": - ## Details for a specific run - - checkAuth(); if not authed: return true - - # TODO - resp(Http501, makeJsonResp(Http501), JSON) - get "/project/@projectName/step/@stepName": ## Get step details including runs. @@ -297,7 +287,6 @@ proc start*(cfg: StrawBossConfig): void = checkAuth(); if not authed: return true let runRequest = RunRequest( - id: genUUID(), projectName: @"projectName", stepName: @"stepName", buildRef: if @"buildRef" != "": @"buildRef" else: nil, diff --git a/src/test/nim/unit/tconfiguration.nim b/src/test/nim/unit/tconfiguration.nim index c0c42d8..a8803e3 100644 --- a/src/test/nim/unit/tconfiguration.nim +++ b/src/test/nim/unit/tconfiguration.nim @@ -21,7 +21,6 @@ suite "load and save configuration objects": test "parseRunRequest": let rr1 = RunRequest( - id: genUUID(), projectName: testProjDef.name, stepName: "build", buildRef: "master",