Lint your .travis.yml config file

Now, it’s time to test your config file using the Travis Client that we installed earlier by running travis post.

travis post

Warnings for .travis.yml:
[x] in matrix.include section: unexpected key osx_image, dropping
[x] in matrix.include section: unexpected key dist, dropping
[x] in matrix.include section: unexpected key sudo, dropping

Wait, what?  Why am I seeing these warnings?

As of 20171125, this type of build matrix image configuration is recommended per the Travis CI multiple operating system build configurations documentation, but it will generate three false positive unexpected key warnings when linting your .travis.yml config file.  These three warnings can be disregarded and have been reported here.  Any warnings or errors other than these should be addressed.

Commit your .travis.yml config file

When you are ready, run the following commands to:

  1. Stage the ./travis.yml config file to the index
  2. Commit the ./travis.yml config file
  3. And then push it up to the master branch of your GitHub public repo, which will trigger the first Travis CI build for your project!
    • If you prefer to push the change to a branch other than master, then update the branch name accordingly.
git add ./.travis.yml
git commit --message 'Initial commit' ./.travis.yml
git push origin master

Protect your important branches

Now that you have configured and run your first build, update your GitHub repository settings so that any contributions to your project must first pass your build and testing framework as a prerequisite for consideration.  To do so:

  • Go to https://github.com/<user>/<project>/settings/branches/<branch>/
  • Enable Require status checks to pass before merging.
  • Also recommended:
    • Enable Require pull request reviews before merging.
    • Enable Require review from Code Owners.
    • Enable Require branches to be up to date before merging.
GitHub branch protection for master

You made it!

Voila!  You’re done!  There are plenty of other things that you can do here such as configure notifications so that Travis CI automatically posts your build results in a Slack channel, publish your PowerShell module on successful build to the PowerShell gallery, or add a badge to your README.md indicating whether the last build passed or failed, all of which I’ll cover in the next post, but you should have enough now to start testing your PowerShell project on macOS and Ubuntu for free on the powerful & versatile Travis CI platform.

Enjoy!

Improve this page

Comments