You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everyone loves Travis CI to automatically run your tests, it just works.
Create an account
Go to https://travis-ci.org/ and click on Sign up button. It will ask you to integrate with Github, give it access without worries.
Enable your repository
Navigate to your Profile Page, find the repository you want to enable and click in that switch button:
Environment variable
One more thing: remember I've said there's a safer way to integrate Code Climate and Travis? Great, we are going to pass the Code Climate's token through an Environment variable.
After you enable your module, click in that settings engine ( ) and you will land in the repository settings page:
Notice the Environment Variables section. Add a new variable with this information:
Obviously, change the token value with your own token and then click Add button.
Travis configuration file
You can tell Travis CI exactly what are you testing and in which versions you want to test it. Also, you can run commands after your tests finished to run (like sending coverage files to Code Climate).
So, create a .travis.yml file in the root of your repository with this content:
We want to run our tests against stable, 5.0, 4.2, 0.12 and 0.10 Node.js versions.
After the tests finishes, install codeclimate-test-reporter binary and then send to it the lcov.info coverage file. This binary will read CODECLIMATE_REPO_TOKEN environment variable to know to which account send the report.
Default test script
To run our tests, Travis CI will run the below command by default:
$ npm test
But we don't have nothing in our test script, since we just created a test-unit and coverage script. In the end, what we want is, when Travis CI runs the default test script, run the coverage script. So add this to your package.json file inside the scripts section:
Everyone loves Travis CI to automatically run your tests, it just works.
Create an account
Go to https://travis-ci.org/ and click on Sign up button. It will ask you to integrate with Github, give it access without worries.
Enable your repository
Navigate to your Profile Page, find the repository you want to enable and click in that switch button:
Environment variable
One more thing: remember I've said there's a safer way to integrate Code Climate and Travis? Great, we are going to pass the Code Climate's token through an Environment variable.
After you enable your module, click in that settings engine ( ) and you will land in the repository settings page:
Notice the Environment Variables section. Add a new variable with this information:
Name:
CODECLIMATE_REPO_TOKEN
Value:
b84c2a82c59ba9f77fbd81c7b78b024a38bf6d5e3527dc4f819e1e1f1410e0b7
Obviously, change the token value with your own token and then click Add button.
Travis configuration file
You can tell Travis CI exactly what are you testing and in which versions you want to test it. Also, you can run commands after your tests finished to run (like sending coverage files to Code Climate).
So, create a
.travis.yml
file in the root of your repository with this content:We are telling Travis CI:
codeclimate-test-reporter
binary and then send to it thelcov.info
coverage file. This binary will readCODECLIMATE_REPO_TOKEN
environment variable to know to which account send the report.Default test script
To run our tests, Travis CI will run the below command by default:
But we don't have nothing in our
test
script, since we just created atest-unit
andcoverage
script. In the end, what we want is, when Travis CI runs the defaulttest
script, run thecoverage
script. So add this to yourpackage.json
file inside thescripts
section:Next step
14. Publish it to Github to test the integrations
The text was updated successfully, but these errors were encountered: