Conditional job based on day of the week?

Hi Everyone,

I’m setting up tests for a large library. The library has about 750 unique testable modules. I want to spread testing over a week so about 110 modules are tested each day. Most tests average 2 minutes or less.

I don’t know how to specify a conditional job based on day of the week. The documentation for conditional jobs is here, and the documentation for conditions is here. I’m looking for something like:

- name: Monday tests, GCC, Ubuntu Trusty
  dist: trusty
  compiler: gcc
  if: env(TRAVIS_EVENT_DAY) = Monday
- name: Monday tests, Clang, Ubuntu Trusty
  dist: trusty
  compiler: clang
  if: env(TRAVIS_EVENT_DAY) = Monday

Is there a way to setup a conditional job using day of the week?

Or is there a better way to do this?


The Posix date command may be able to help. date '+%u' returns the number for the day of the week. The number is locale agnostic, so 1 = Monday in EN and 1 = Lunes in ES.

So maybe something like:

- name: Monday tests, GCC, Ubuntu Trusty
  dist: trusty
  compiler: gcc
  if: `date '+%u'` = 1