Gitlab
Gitlab is one of the most popular collaboration software suites around. It is not only a CI server, but a source code server, docker registry, issue manager, and much much more. They are our personal favorite for private projects due to their power and flexibility.

Features

  • All in one tool: CI, repository, docker registry, issues/milestones, etc.
  • Same as Travis in concept - CI Runner
  • Docker based
  • CI Runners can be decoupled to a docker swarm
  • Idea of CI pipelines
    • Pipelines composed of jobs executed in stages
    • Jobs can have dependencies, artifacts, services, etc
    • Schedule Pipelines (Cron)
    • Jobs can track environments
  • Great stats + charting

TestBox Integration

In order to work with Gitlab you must create a .gitlab-ci.yml file in the root of your project. Once there are commits in your repository, Gitlab will process this file as your build file. Please refer to the Gitlab Pipelines documentation for further study.
We will leverage the Ortus Solutions CommandBox Docker image in order to provide us with the capability to run any CFML engine and to execute tests. Please note that Gitlab runs in a docker environment.
1
image: ortussolutions/commandbox:alpine
2
3
stages:
4
- build
5
- test
6
- deploy
7
8
build_app:
9
stage: build
10
script:
11
# Install dependencies
12
- box install production=true
13
14
run_tests:
15
stage: test
16
only:
17
- development
18
# when: manual, always, on_success, on_failure
19
script:
20
- box install && box server start
21
- box testbox run
Copied!
The build file above leverages the ortussolutions/commandbox:alpine image, which is a compact and secure image for CommandBox. We then have a few stages (build,test,deploy), but let's focus on the run_tests job.
1
run_tests:
2
stage: test
3
only:
4
- development
5
# when: manual, always, on_success, on_failure
6
script:
7
- box install && box server start
8
- box testbox run
Copied!
We define which branches it should listen to: development, and then we have a script block that defines what to do for this job. Please note that the when action is commented, because we want to execute this job every time there is a commit. In Gitlab we can determine if a job is manual, scheduled, automatic or dependent on other jobs, which is one of the most flexible execution runners around.
In our script we basically install our dependencies for our project using CommandBox and startup a CFML server. We then go ahead and execute our tests via box testbox run.

Box.json

In order for the box testbox run to execute correctly, our box.json (See https://commandbox.ortusbooks.com/content/packages/boxjson/boxjson.html) in our project must be able to connect to our server and know which tests to execute. Below are all the possiblities for the testbox integration object in CommandBox's box.json. (See https://commandbox.ortusbooks.com/content/testbox-integration.html)
1
{
2
"name" : "Package Name",
3
// ForgeBox unique slug
4
"slug" : "",
5
// semantic version of your package
6
"version" : "1.0.0+buildID",
7
// author of this package
8
"author" : "Luis Majano <[email protected]>",
9
// location of where to download the package, overrides ForgeBox location
10
"location" : "URL,Git/svn endpoint,etc",
11
12
// testbox integration
13
testbox :{
14
// The location of the runner
15
runner : [
16
{ "default": "http://localhost:8080/tests/runner.cfm" }
17
],
18
// Which labels to run, empty means all
19
"labels" : "",
20
// Which reporter to use, default is json
21
"reporter" : "",
22
// Which CFC bundles to execute, default is all
23
"bundles" : "",
24
// Which directories to execute
25
"directory" : "tests.specs",
26
// Recurse the directories for CFCs
27
"recurse" : true,
28
// Which bundles to filter on
29
"testBundles" : "",
30
// Which suites to filter on
31
"testSuites" : "",
32
// Which specs to filter on
33
"testSpecs" : "",
34
// Display extra details inlcuding passing and skipped tests.
35
"verbose" : true,
36
// How may milliseconds to wait before polling for changes, defaults to 500 ms
37
"watchDelay" : 500,
38
// Command delimited list of file globbing paths to watch relative to the working directory
39
"watchPaths" : "**.cfc"
40
}
41
}
Copied!

Online Example: cbVue

You can look at our cbVue sample application online: https://gitlab.com/lmajano/cbvue which contains all CI server integrations.
Last modified 2yr ago