I would like to extend our shake-based build system to include running integration tests, however running those tests require firing up some docker containers on which the tests depend and which may or may not be rebuilt as part of the build process.

In short I would need to track "live" processes, and kill/restart them if their underlying image has changed. How could I achieve that with shake?

1 Answers

1
Neil Mitchell On Best Solutions

I'm going to assume we want to run docker image and change when image changes (generalising it for any name isn't hard, but distracts from the important bits).

Imagine the service is always running, never falls over, and is entirely in the control of Shake. We could write:

"runner" %> \out -> do
     need ["image"]
     cmd_ "docker kill"
     cmd_ "docker start image"
     writeFile' out ""

Here we have a rule that produces runner, and as a side effect depends on image and starts/stops docker. Any test using the runner should do need ["runner"] before they start. If they also depend on the contents of the image, they should do need ["runner","image"].

If the images aren't under the control of Shake, and other people are prodding them, you probably want to addOracle to define an oracle that detects the currently running docker images, and depend on that in runner.