One-Liner Bash-Based Continuous Integration (OLBABACI)

Continuous-IntegrationIt’s all about CI these days: Jenkins, Buildbot, numerous SaaS service embedding these fine FLOSS and hoping for a recurring credit card based subscription,… and for a reason. Continuous Integration allow for quicker feedback, shorter dev iterations, better communication.

The principle is simple: as soon as their is a change in code, configuration, datasets, automatically retest the whole application and send automated output (and diffs from previous runs, dashboard, etc..)

Yet, Jenkins or else CI solution, everything takes time to setup. Here with this same principle of CI but with simple bash-one liner, here on Mac:

brew install fswatch

fswatch | while read a; do echo “========= Executing $a at `date +%Y%m%d-%H%M`”; $a; echo “========= Done $a”; done

Simple and Stupid right? As soon as the file is changed, fswatch (or inotifywait on Linux) will let the loop run and a new run of your code will happen. Soon enough, you’ll see that every development, no matter how small should always gets its CI.

Then you can go a bit further as when you code, you don’t necessarily always look at your terminal where CI is running. So actually you can track the runs with various metrics into a text/CSV file generated through your one-liner:

  • Date of run
  • PID (as it is often sequential)
  • Number of lines in your source code
  • Latest GIT commit hash
  • Number of lines in output
  • Number of lines matching (case insensitive) “error|warning|traceback|exception”
  • Input file name for your program

The sky is the limit (please pronounce with a thick Texan accent).


About phil