Cilia combines staging and testing for continuous integration and QA of web applications. It's supposed to be simple, robust, and fast.
The system makes some assumptions:
- your project is in Git;
- you can set up a DNS wildcard entry to the Cilia server;
- your project can run in Docker Compose with private networking; and
- your project can run behind a virtual host proxy.
You need to set up DNS. Let's say your domain is example.com. Then both
cilia.example.com(the web frontend to Cilia) and*.cilia.example.com(proxying to running apps based on commit hash)
should point to the Cilia server.
You also need to set some environment variables:
CILIA_ROOTshould be a directory containing your project configuration, where Cilia can also store its work data;CILIA_PATHshould point to the installation of Cilia itself; andCILIA_HOSTNAMEshould be (for example)cilia.example.com.
To use the Browserstack.com integration, set BROWSERSTACK_USER and BROWSERSTACK_KEY.
Cilia's project configuration is a file structure at $CILIA_ROOT/projects.
Here is an example of configuring the pet-store project.
$ mkdir -p $CILIA_ROOT/projects/pet-store/branches
We want to test the master and experimental branches.
$ touch $CILIA_ROOT/projects/pet-store/branches/{master,experimental}
We set the Git origin from which Cilia will clone and pull:
$ cat > $CILIA_ROOT/projects/pet-store/origin
git@github.com:petstore/app
We only care about commits that modify the server or client
directories. (Optional.)
$ cat > $CILIA_ROOT/projects/pet-store/commit-filter
server
client
There should also be a .cilia directory in the root of your project
repository.
$ mkdir .cilia
$ cd .cilia
Use the root Compose file.
$ ln -s ../docker-compose.yml docker-compose.yml
Start building automatically when a commit is initialized.
$ echo build > on-commit
Create four named tasks. (Right now, these names are special, but that's a hack.)
$ mkdir -p tasks/{build,up,wait,test}
Configure the number of concurrent tasks per type:
$ echo 2 > tasks/build/concurrency # builds are heavy
$ echo 15 > tasks/up/concurrency # but run plenty of instances
Configure the way tasks lead to one another:
$ echo up > tasks/build/on-succeeded
$ echo wait > tasks/up/on-started
$ echo test > tasks/wait/on-succeeded
Configure which Compose target to run:
$ echo server > tasks/up/service
This is not entirely accurate but it's pretty much what happens. These are implemented as shell scripts for relative easy control of files, processes, pipes, errors, and so on.
- For all repositories:
- If there is a clone directory:
- Run
git pullin the clone directory. - For the most recent commits:
- If the commit is unknown:
- Create the commit directory.
- Create the commit work tree.
- Initialize the task work tree.
- Start task according to commit hook
- If the commit is unknown:
- Run
- Otherwise:
- Clone the repository from the origin.
- If there is a clone directory:
- Wait a few seconds.
- Repeat.
- For all commits:
- If the commit has a task request:
- Perform the task request.
- Run the relevant hook, if present.
- Save the task process ID.
- Await the task process.
- Clear the task process ID.
- Mark the task as finished/cancelled.
- If the commit has a task request:
- Wait a few seconds.
- Repeat.
- For all commits:
- For all tasks:
- If the task seems dead:
- Reset its status.
- If the task seems dead:
- For all tasks:
- Wait a few seconds.
- Repeat.