Get Set Up with GitHub and Travis Continuous Integration
- Describe how continuous integration benefits you and your customers.
- List the tools needed for continuous integration with Salesforce DX.
Continuous integration (CI) is a software development best practice. When using CI, all code that development teams produce is merged into a central repository, where an automated build can validate it. This practice helps development teams detect problems, identify bugs, and fix those problems and bugs before releasing changes to their customers.
CI is like an insurance policy. Would you risk driving around town without car insurance? No way! In today's world of agile development, it's easy to push changes to your users. With a CI system in place, even the smallest change is processed to ensure your system continues to work flawlessly. Early detection and fixes are key for happy software stakeholders (that's a fancy way of saying "your customers").
So now you know that CI can save your company money. Next, we’re going to walk you through the steps to set up CI with Salesforce DX. If you remember from an earlier module, Salesforce DX lets you pick the tools you want to use. This flexibility means that you can use any CI or continuous delivery (CD) service you want. For this module, we decided to take advantage of two cloud-based solutions:
GitHub, a version control system (VCS), for our central repository
Travis CI, which works well with GitHub
If you’ve completed the App Development with Salesforce DX module, you likely already have the tools that you need to complete this module. If you’re unsure, we recommend doing that module first.
Although you can use any VCS, we like using Git with GitHub, which makes it easy for you and your team to work together on projects. In our case, we’re going to have you grab a sample application from GitHub.
Let’s get started!
Now that you have GitHub set up, let’s grab the application used for this project. To do so, fork and clone an existing GitHub repository.
- Open the sfdx-travisci GitHub repo.
- In the repo, click Fork.
- Choose your GitHub account to fork to.
The fork gives you your own copy of the repository.
- From a command window, run:
git clone https://github.com/<GH_username>/sfdx-travisci.git
Replace <GH_username> with your GitHub username. This command grabs everything out of the repository and stores it locally. This repository includes a Salesforce DX project, already configured.
- Change to the Travis CI sample app directory.
Getting started with Travis CI is easy. You’ll use your GitHub credentials to log in.
- Go to the Travis CI website and click Sign Up.
- Click Authorize travis-ci to log in with your GitHub
credentials, then enter your GitHub password.
You’re actually on GitHub.com at this point; Travis CI never sees your login information.
- When you’ve logged in, click your picture to go to profile settings.
- Find the sfdx-travisci repository and turn on Travis CI for your repo.
Sometimes it takes several minutes to sync Travis CI and GitHub, so hang tight if you don’t immediately see your repository.
That’s it. You’ve now set up Travis CI to track your GitHub repository. Later we’ll review the .travis.yml configuration file, which documents the steps for the CI process.
Install the Travis CI command-line interface (CLI). If you’re using macOS, your configuration could require you to run the installation commands preceded by sudo.
To confirm that the installation succeeded, run the travis command in the command window:
If the installation was successful, you see the available Travis CI commands in the output.