官术网_书友最值得收藏!

Implementing CI

To set up CI, it is, therefore, necessary to have a Source Code Manager (SCM) that will allow the centralization of the code of all members. This code manager can be of any type: Git, SVN, or Team Foundation Source Control (TFVC). It's also important to have an automatic build manager (CI server) that supports continuous integration such as Jenkins, GitLab CI, TeamCity, Azure Pipelines, GitHub Actions, Travis CI, Circle CI, and so on.

In this book, we will use Git as an SCM, and we will look a little more deeply into its concrete uses.

Each team member will work on the application code daily, iteratively and incrementally (such as in agile and scrum methods). Each task or feature must be partitioned from other developments with the use of branches.

Regularly, even several times a day, members archive or commit their code and preferably with small commits (trunks) that can easily be fixed in the event of an error. This will, therefore, be integrated into the rest of the code of the application with all of the other commits of the other members.

This integration of all the commits is the starting point of the CI process.

This process, executed by the CI server, must be automated and triggered at each commit. The server will retrieve the code and then do the following:

  • Build the application package—compilation, file transformation, and so on.
  • Perform unit tests (with code coverage).
It is also possible to enrich the process with static code and vulnerability analysis, which we will look at in  Chapter 10, Static Code Analysis with SonarQube, which is dedicated to testing.

This CI process must be optimized as soon as possible so that it can run fast and developers can have quick feedback on the integration of their code. For example, code that is archived and does not compile or whose test execution fails can impact and block the entire team.

Sometimes, bad practices can result in the failure of tests in the CI, deactivating the test execution, taking as arguments: it is not serious, it is necessary to deliver quickly, or the code that compiles it is essential.

On the contrary, this practice can have serious consequences when the errors detected by the tests are revealed in production. The time saved during CI will be lost on fixing errors with hotfixes and redeploying them quickly with stress. This is the opposite of DevOps culture with poor application quality for end users and no real feedback, and, instead of developing new features, we spend time correcting errors.

With an optimized and complete CI process, the developer can quickly fix their problem and improve their code or discuss it with the rest of the team and commit their code for a new integration:

This diagram shows the cyclical steps of continuous integration that include the code being pushed into the SCM by the team members and the execution of the build and test by the CI server. And the purpose of this fast process is to provide rapid feedback to members.

We have just seen what continuous integration is, so now let's look at continuous delivery practices.

主站蜘蛛池模板: 炎陵县| 库尔勒市| 濮阳县| 伊金霍洛旗| 子洲县| 镇坪县| 诸暨市| 榆树市| 二连浩特市| 新田县| 沽源县| 建湖县| 全南县| 元江| 农安县| 化州市| 郧西县| 新平| 新乐市| 从江县| 呼玛县| 将乐县| 辽中县| 阳曲县| 兰坪| 拜泉县| 基隆市| 观塘区| 分宜县| 无棣县| 恩平市| 唐山市| 台中市| 阳山县| 明星| 陵川县| 昌平区| 安溪县| 泰来县| 永新县| 聊城市|