I remember when we delivered software on floppy disks, it was quite different back then… In today’s market, we don’t deliver software as a product anymore; we deliver software as a service… We need to change how we do things, one step at a time.
The term Continuous Integration has been very popular in the last years, the way we work has been evolving and distributed teams need an effective way of collaborating while ensuring the quality and fast paced delivery required by software development nowadays. This evolution has triggered the development of tools and practices for continuous integration and delivery.
By adopting CI/CD practices and tools we are able to integrate work more frequently, solve problems quickly, gain better quality on our products, help collaboration on our teams runs smoothly, make sure our team’s code is always building and stop the most bugs from getting to the users.
Fortunately, these practices are not something only the big companies and teams has access to, there are great available free tools to integrate CI and CD processes into our projects.
Here’s how to implement Travis CI and Codecov with your existing Flutter project.
1. Get your repo ready
You’ll need a GitHub repo with your Flutter project loaded up and ready.
2. Setup Travis account
Go to travis-ci.com and sign up if you don’t have an account already. After you accept GitHub authorization you’ll be able to activate Travis and select the repo you’d like to integrate
3. Create .travis.yml file
This file tell Travis CI what to do, here’s a template that should work with Flutter projects, you can start here and modify due to your project needs.
|# Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18|
|– ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version|
|– git clone https://github.com/flutter/flutter.git -b beta|
|– ./flutter/bin/flutter doctor|
|– ./flutter/bin/flutter test –coverage|
|– bash <(curl -s https://codecov.io/bash)|
Add the file to git, commit your changes and push them to the repo, a new build should be triggered automatically.
4. Add Travis Badge
Now you should be able to check the build status of your project in Travis so why not make this info available through your repo by using travis badge.
To do this you should visit your repo on Travis and add the markup to your README file.
Now it’s codecov turn.
1. Run your tests
Make sure your tests are running and coverage reports are generating correclty. You can do this by running in your flutter project
flutter test --coverage
2. Setup Codecov account
Same as travis account, go to codecov.io and sign up if you don’t have an account already. You should accept GitHub authorization and activate Codecov.
3. Set upload step to run on travis
Edit you .travis.yml file to trigger coverage files to codecov automatically
Trigger a new build on Travis and you should start looking at your coverage data automatically
4. Add Codecov Badge
Visit your project’s page on codecov and go to Settings > Badge to get the markdown and add it to your README file.