We have already dealt with the tests, so we will discover how you run them properly now. In this lesson, we'll discuss continuous integration and learn how to test.
What is continuous integration
It is a personal responsibility to run tests locally. Good developers use tests continuously during development and run them before pushing using the git push
command. But this is not enough because there are always human errors. Even though they run locally, tests should be run automatically on continuous integration servers.
Continuous integration is a development practice that consists of frequent and automated assembly of an application to identify problems quickly. Programmers usually perform integration on commits to the repository and monitor them using a specialized server or a continuous integration service. It loads the code, assembles it if necessary, and then runs various checks.
What do we launch, and how? The programmer determines this in advance. First, we run the tests and the linter, which check the design of the code. In addition, we can run utilities to analyze security, the relevance of dependencies, and much more. We can depict continuous integration in this diagram:
Let us take a closer look at the terminology and the process itself:
- To launch a build for each commit
- To assemble the application, install dependencies, run tests, and all other checks during the build
- To get a successful test if the build completes without errors
- To get a notification if the build fails
- To look at the report, correct the errors, make another commit, and the process begins again
There are two ways to implement continuous integration.
The first way is to install Jenkins or its equivalent on your server. This option requires a lot of manual work, including server support. This solution is suitable for companies that:
- Make very complex applications
- Want their code to be secure
- Make so many projects that their server is cheaper than a third-party solution
The second way is to use the continuous integration service. There are dozens, if not hundreds, of such services. There are plenty to choose from. As a rule, most of them are free for open-source projects.
One of the popular solutions is Github Actions, a built-in Github service:
GitHub Actions provides continuous integration and can do much more than that. Hexlet uses Actions in all its open and closed projects (example of such a project).
For convenience, the service gives a badge — a picture inserted into the README file in your project. The badge shows the current project status, including whether the last build was successful. Clicking on it, you can go to the page with the latest builds.
Are there any more questions? Ask them in the Discussion section.
The Hexlet support team or other students will answer you.
For full access to the course you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.