Continuous Integration
CI environments can pull a lot of bandwidth. So, how can you follow best practices with your chosen suite of tests without hitting the ceiling of your monthly npm bandwidth limits? With caching! Read on, and we’ll show you how.
We’ve gathered caching how-to’s for some of the most popular CI options on the market today to make it easy and performant to use Font Awesome in your projects.
The Problem
Every time you push code and your test suite runs, it will pull your packages for each test run. If you’re anything like us, you push a lot of commits. The problem is all those commits add up quickly, which means you’ll be hitting your npm bandwidth limit before you know it. You need a caching strategy. Here’s what to do.
The Solution
Set up your packages to be cached in your chosen CI solution. Once you set up caching, it will only pull packages when something in the package (like a version) changes. This cuts down on bandwidth usage significantly and may also speed up run times on your test suite.
Below are links to the docs for some of the most popular CI solutions on the market today:
- CircleCI has written extensive docs on caching with Circle CI.
- GitHub Actions allows you to keep everything in the GitHub ecosystem. They have docs on how to use caching with GitHub Actions.
- Travis CI has a nice set of docs on caching with Travis CI.
- GitLab has some solid docs on setting CI suite caching with GitLab.
- Bamboo from Atlassian has an article on how to set up caching with Bamboo.
- Jenkins doesn’t currently have a built in caching strategy so you’ll need to home bake one.
- Bitbucket Pipelines has docs on caching build dependencies.
Troubleshooting
If you have configured your caching but are still hitting your bandwidth limits, here are some things to look at. These all assume you are using version 6. If you are using version 5, we recommend upgrading to version 6.
- Check your package versions.
@fortawesome/fontawesome-common-types
and@fortawesome/fontawesome-svg-core
should be the same as the version of the other Font Awesome packages you are using. If you see an older version, look for what is using that older version and remove that dependency. - If you are downloading
@fortawesome/fontawesome-pro
we recommend removing it from your project and use the individual style packages in conjunction with@fortawesome/fontawesome-svg-core
instead. The fullfontawesome-pro
package contains a lot of extra stuff you won’t need and just keeps getting bigger as we add styles. We still have it available for compatibility purposes, but you should move away from it in order to keep your builds fast and use less bandwidth. For a list of style packages, see this.