Hello!
I’m evaluating different CI solutions for a software that I write and I like Drone for its simplicity and its clear documentation. However, I cannot figure out if what I would like to do could be supported or not.
I have 3 sets of test that I would like to run on a regular basis:
-
Installation tests: check that the software installs correctly on a few selected Linux distro (at least Debian, Ubuntu, CentOS – all of them provide official Docker containers AFAICS)
-
Unit tests (once installation tests are fine, they can be run on a selected distro only, e.g. Ubuntu)
-
Functional tests: given a set of options, try out the software with all combinations. (Possibly blacklisting some combinations.)
Now, 1. and 3. seem to require a “matrix” approach but my reading of the documentation is that I can only have one pipeline and one matrix, so I cannot loop over distros in 1. and over configs in 3. Also, the three sets of tests could be run independently one from the other so they could be split off to different pipelines.
Is there a way to achieve this with Drone? Or have I misunderstood the docs altogether?
Thank you very much for any suggestion or clarification.
Riccardo
You can define steps in the pipeline and execute in parallel, using the group
keyword. This allows you to fan-in and fan-out. Here is a simple example:
pipeline:
#
# fan-out
#
debian:
image: debian
+ group: installation
commands:
- sh installation_tests.sh
centos:
image: debian
+ group: installation
commands:
- sh installation_tests.sh
ubuntu:
image: debian
+ group: installation
commands:
- sh installation_tests.sh
#
# fan-in
#
unit_tests:
image: ubuntu
commands:
- sh unit_tests.sh
Matrix builds are considered a legacy feature that was copied from Travis. The drone yaml has evolved to provide some more powerful alternatives, which we will continue to build upon, eventually deprecating the matrix keyword.
Thank you very much for your quick reply!
A follow-up question: looking at the simple example that you posted, it seems that I would have to copy the steps, modifying only the image:
keyword, for fan-out. That works (in my case) for installation tests (as I would be testing on a handful of Linux distros) but would not work so nicely for functional tests: there’s too many option combinations and, moreover, I would not like to generate all of them “by hand”. Is there a kind of “nested loop” facility in the Drone YAML?
Thanks,
Riccardo
it seems that I would have to copy the steps, modifying only the image: keyword
Yaml has language features that can help reduce boilerplate
http://blog.daemonl.com/2016/02/yaml.html
but would not work so nicely for functional tests: there’s too many option combinations and, moreover, I would not like to generate all of them “by hand”.
There is a proof of concept for using javascript to define the pipeline, however, it is only a proof of concept and is unlikely to land any time soon (probably not until Q3). So this could eventually be an option, but not in the near term.
My recommendation would therefore be to generate the yaml. You could use a simple Go program and the text/template library to automatically build the Yaml file so that you do not have to write by hand.
1 Like
The YAML file needs to be checked in the repo, right? So I would have to generate it in the git pre-commit hook or similar, in order to be sure that it is always up-to-date?
The YAML file needs to be checked in the repo, right? So I would have to generate it in the git pre-commit hook or similar, in order to be sure that it is always up-to-date?
yes, this would be correct