Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (84 sloc) 4.71 KB
type layout title excerpt published last_modified_at header toc_icon categories tags meta
post
single
PowerShell Core on Travis CI (part 3 of 3)
How to build, test, and deploy your PowerShell projects on Linux and macOS for free with Travis CI! {::nomarkdown}<br><br>Example available in the <strong>Armor PowerShell</strong> project.<br><br><iframe style="display: inline-block;" src="https://ghbtns.com/github-btn.html?user=tlindsay42&repo=armorpowershell&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe> <iframe style="display: inline-block;" src="https://ghbtns.com/github-btn.html?user=tlindsay42&repo=armorpowershell&type=fork&count=true&size=large" frameborder="0" scrolling="0" width="158px" height="30px"></iframe>{:/nomarkdown}
true
2018-05-20
overlay_image overlay_filter teaser
/assets/images/powershell_github_travis-ci.png
0.5
/assets/images/powershell_github_travis-ci.png
terminal
Automation
Continuous Delivery
Continuous Deployment
Continuous Integration
FOSS
Free
GitHub
Linux
macOS
Microsoft
Open source
OSX
PowerShell
PowerShell Core
Travis CI
Ubuntu
_wpcom_is_markdown _thumbnail_id _rest_api_published _rest_api_client_id _publicize_job_id _publicize_done_external _publicize_done_18611616 _wpas_done_18402702 publicize_twitter_user publicize_google_plus_url _publicize_done_18611618 _wpas_done_18402704 publicize_linkedin_url _publicize_done_18611619 _wpas_done_18402705
1
307
1
-1
11837283676
a:1:{s:7:"twitter";a:1:{i:18402702;s:59:"https://twitter.com/troylindsay42/status/934648058633076736";}}
1
1
troylindsay42
1
1
1
1

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.

{% include figure image_path="/assets/images/github-branch-protection.png" alt="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!