Free Continuous Integration for open-source Swift Packages
Apple has released it’s own package manager called ‘Swift Package Manager‘ to share and distribute Swift packages. It’s a good idea to add free Continuous Integration to our open-source Swift Packages so that we made sure nothing is broken with code changes. Fortunately, TravisCI gives you free services for the all open-source project on Github. In this short post, we will see how to add TravisCI support for the demo package Greeter which is available on Github.
It would be handy if you already have GitHub account and Swift Package then we can signup to TravisCI services using Github credentials. TravisCI will guide you about the process of enabling the CI service for your project. It’s three step process as mentioned in the picture below
Basically, It’s straight forward process, we need to sync GitHub account which will display all our repositories. then you need to add .travis.yml file at the root of the project. and push the build with git push
Add TravisCI Config
- swift build
- swift test
Travis has different build environments, we have to choose latest Xcode 8.3 image with all the necessary software components installed. It means we have already swift installed on the Travis server, we then need to run scripts to build our package and test our package. We have done that in the .travis.yml file above.
Now that, we have added support for TravisCI, we need to enable project on Travis and it will ‘build’ and ‘test’ our project after every commit or new Pull request. The example Travis project for our Greeter example can be found here
There are so many options available to customise the .travis.yml file. You can read more about the configuration option here
It’s so simple as that, hope you will add TravisCI services to your Swift Packages as well.