DeepsourceDeepSource
Help CenterCode Coverage & TestingIntegrating DeepSource with CI Systems for Code Testing

Integrating DeepSource with CI Systems for Code Testing

Last updated March 5, 2024

Introduction

Continuous Integration (CI) systems play a crucial role in modern software development practices, automating the testing and building of code with every change made to the codebase. Integrating DeepSource with your CI system enhances this process by adding automated code quality and security analysis, ensuring that every commit not only passes your tests but also meets high standards of code health. This guide will walk you through the steps to integrate DeepSource with popular CI systems, enabling you to automate code review and analysis as part of your CI pipeline.

Step-by-Step Guide to Integration

  1. Prepare Your DeepSource and CI Accounts
  • Ensure you have active accounts for both DeepSource and your chosen CI system (e.g., CircleCI, Travis CI, GitHub Actions, Jenkins). Your project should already be set up on DeepSource. If not, refer to our guide on "Integrating DeepSource with Your Code Repository."
  1. Access Your Project Settings on DeepSource
  • Log in to DeepSource and navigate to the dashboard of the project you wish to integrate with your CI system. Go to the "Settings" tab to find integration options.
  1. Locate the CI Integration Documentation
  • DeepSource provides specific documentation for integrating with various CI systems. Look for the "Integrations" section or a similar area within the project settings or DeepSource documentation to find instructions tailored to your CI system.
  1. Generate a DeepSource API Token
  • For most CI systems, you'll need to generate an API token from DeepSource to allow the CI system to communicate with DeepSource securely. Go to your account settings on DeepSource, find the API tokens section, and generate a new token. Keep this token secure and do not share it publicly.
  1. Configure Your CI Pipeline
  2. Set Up Environment Variables
  • Store the DeepSource API token as an environment variable in your CI system. This keeps the token secure and allows your CI pipeline to use it without hardcoding it into your configuration files. Refer to your CI system's documentation for instructions on setting environment variables.
  1. Test the Integration
  • Commit a change to your repository that triggers the CI pipeline. Verify that the new steps for DeepSource analysis are executed as part of the CI process. Check the output logs to ensure that the analysis completes successfully and that results are reported as expected.
  1. Review Analysis Results
  • After the CI pipeline runs, go to your project dashboard on DeepSource to review the analysis results. DeepSource will display any code quality issues or security vulnerabilities detected during the analysis, allowing you to address them promptly.
  1. Iterate and Optimize
  • Based on the initial results and your team's workflow, you may need to adjust the integration settings. This could involve changing when the DeepSource analysis runs, tweaking analysis configurations, or refining your CI pipeline to better suit your needs.

Conclusion

Integrating DeepSource with your CI system streamlines the process of maintaining high code quality and security standards. By automating code analysis within your CI pipeline, you ensure that every change is scrutinized for potential issues, leading to a more robust and reliable codebase. Follow these steps to set up the integration and enjoy the benefits of automated code review as part of your continuous integration process.

Was this article helpful?