Travis now has a beta feature, Cron Jobs, which let you schedule builds on a daily, weekly, or monthly basis. To enable Cron, simply email travis support. I got a reply saying that Cron was enabled on my account in less than 24 hours of sending the request.

I use AWS Lambda for quite a few projects. The AWS SDK for JavaScript comes bundled in the Lambda environment, so there’s no need to include it when uploading a built Lambda function (zip file). However, the latest version of the SDK and the version available on Lambda are slightly out of sync. I needed a way to keep the latest version of the SDK in the devDependencies of my projects without having to keep checking the documentation and updating the pinned version for each project. Enter aws-sdk-js-on-lambda. This repo keeps itself up to date with Travis’ cron builds.

How it works

npm pretest makes a get request to the Execution Environment page from the AWS documentation, uses a regular expression to parse out the SDK version, and outputs that to a file npm test simply compares the version on the documentation page (read in from the file in the previous step) to the version in package.json. If they’re the same, it passes, if not it fails. In the event of a test failure, the after_failure (from .travis.yml) script is fired. This is where it gets interesting. after_failure is configured to execute update.sh. This script checks out the develop branch, upgrades the local package with yarn, then pushes back to GitHub. Of course, a push triggers another build. This time, it should pass. After a success, after_success is triggered. In this case, it’s configured to call merge.sh, this checks if the build came from the develop branch, and merges develop into master, which in-turn, triggers another build. This time, master should pass with no problems.

I opted to use two different branches to avoid an infinite loop of pushing to and triggering builds from the same branch. If, for whatever reason, the build on develop fails, no further actions will be performed.

Here’s a process diagram to help explain: