TinyCI 0.4 is out and as you might expect from the version number there are some new features.
- New configuration format
- Command interpolation
More info in the rest of the post…
New configuration format
You now have the option of a terser format for
build: blah test: blah hooks: after_test_success: blah
Will be automatically transformed (internally) to this:
builder: class: ScriptBuilder config: command: blah tester: class: ScriptTester config: command: blah hooker: class: ScriptHooker config: after_test_success: blah
A huge improvement I’m sure you’ll agree, especially since the
Script classes are currently the only ones available anyway.
Note that the new config format is a superset of the old one: configuration in the verbose format continues to work the same.
You can now use ERB syntax to insert values into your build, test and hook commands at runtime. Let’s look at FML’s
.tinyci.yml file as an example:
build: VERSION=<%= commit %> docker-compose build --force-rm test test: VERSION=<%= commit %> docker-compose run --rm test hooks: after_test_success: VERSION=<%= commit %> docker-compose build app after_all: rm -rf <%= export %>#; docker rmi fml:<%= commit %>-test
Here, in the build stage we’re building the test service from the docker compose file. The commit hash is passed in as an environment variable and is used to tag the docker image. For the test stage, we run that same docker image to test the app. In the hooks, we’re building the production version of the image once we know the build passes the tests. After everything’s finished, we delete the test docker image, as well as the exported copy of the app sourcetree.
This way we are left with only working docker images in the local index.
As you might imagine, this hook is executed after everything else. It’s guaranteed to execute whether or not any stage has failed.