Software development in general is a team work, in this series of articles mentioned software start coding is performed by a team “parallel”, in order to ensure the normal order of the coding tasks completed, first introduced version control tool to complete the code management, in order to ensure the quality of code code analyzer and test is introduced.

Version control tool can guarantee that the code has a major version, but the code analysis and testing are all developer manually done in local (compile and execute the test mode), when the code analysis and testing may not be the local code update to the latest version, so there will be a problem, when multiple developers to submit your code to the repository, In order to solve this problem, continuous integration is proposed. Continuous integration refers to the continuous integration of the code written by multiple developers. This paper introduces continuous integration and Github based continuous integration practices from the following aspects:

  • CI&CD
  • Commonly used continuous integration tools
  • GitHub market Profile
  • Use AppVeyor for continuous integration
  • Use Codecov to display code coverage
  • summary

CI&CD

Continuous integration (CI) refers to the Continuous integration of all developers’ code into the main line of the code base during the development process, and then the main line of code is compiled and tested to check the code, so as to discover the problems caused by the code integration as early as possible. Implement continuous integration mainly include: the main points of the Shared code base, build automation, automation, etc., to ensure the reasonable integration of frequency at the same time, the timing of the general continuous integration is that developers will submit code to the code base, automatically, but if the submitted too frequently, then you should use the form of interval for continuous integration. Continuous delivery (CD) is actually an extension of Continuous integration. It automates the publishing work on the basis of Continuous integration and avoids human operations, thus reducing the publishing time and human errors during publishing.

Commonly used continuous integration tools

Continuous integration after years of development, in different application scenarios, platform/language, such as commercial factors produced many continuous integration tool, refer to (but not limited to these) : en.wikipedia.org/wiki/Compar… The commonly used continuous integration tools include: Jenkins Jenkins is an open source cross-platform continuous integration tool, which provides a GUI interface and a large number of extension plug-ins. Through the GUI interface, continuous integration configuration of the project can be easily and quickly completed. More importantly, Jenkins supports all version control tools. Project address: Jenkins. IO /

TeamCity TeamCity is a continuous integration tool developed by JetBrains. It is licensed both for free and for a fee. The free version of TeamCity has all the features, limited to creating only 100 compiled configurations and running only 3 agents in parallel. The address of the project: www.jetbrains.com/teamcity/

GitLab GitLab is a Git code management tool, using GitLab can easily build a Git remote code hosting platform in the Linux environment, while GitLab also built-in CI/CD function. Project address: about.gitlab.com/

Travis CI Travis CI is a continuous integration hosting platform that provides free support for open source projects, but Travis CI does not support compilation under Windows. Project address: www.travis-ci.org/

AppVeyor AppVeyor is also a continuous integration platform for the hosting, it supports Windows and Linux, and AppVeyor can be customized to the environment: www.appveyor.com/docs/build-… AppVeyor is a very powerful CI tool that provides free support for open source projects. Project address: www.appveyor.com/

VSTS Visual Studio Team Services (VSTS) is Microsoft’s software development management solution. It contains features such as code version management, continuous integration/release, and agility. VSTS is free for teams of less than 5 people. The address of the project: visualstudio.microsoft.com/zh-hans/tea…

Overall continuous integration tool divided into two categories, can be installed in the local and platform hosting, local installation type tool is suitable for the closed source projects have special build server resources, also can use open source project), of course, but hosting platform is more suitable for open source project or no special build server resources, using hosted on platform more worry, These tools need to be selected according to the actual situation.

GitHub market Profile

GitHub is a distributed software management solution. In addition to providing code hosting, GitHub also provides extended applications by way of application market. These applications are mainly used for continuous inheritance, deployment, testing, code review, project management, etc. The following figure shows CI tools in the Github marketplace:

  

Generally speaking, the apps available on the marketplace are free to use for open source projects. Here’s how to integrate open source projects on Github with their marketplace applications.

Use AppVeyor for continuous integration

AppVeyor is a CI tool that supports custom continuous integration environments. Net application support is very strong and free for open source projects, so AppVeyor is. Net Core projects are the first choice for continuous integration. Here’s how to use AppVeyor for continuous foundation: 1. Find AppVeyor in the GitHub marketplace and complete the installation:

  

2. Add items:

  

Select the GitHub repository and complete the authorization:

  

Add needed warehouses:

  

Click “NEW BUILD” to compile once:

  

From the compilation information, you can see that the compilation failed and the corresponding error message is given because of the compilation environment.

3. Environment configuration: select VS2017 as the compiled image:

  

Run the dotnet restore command to restore project dependencies before compiling:

  

4. Start a new compilation:

  

As you can see from the build results, Appveyor not only did the build work, but also searched for the test information and completed the test. Another important point is that the tests in this project are database dependent, which means that the Build environment of Appveyor supports SQL Server data.

Add a Tag to the xUnitTestDemo codebase:

  

Appveyor will then detect the change in the code base, automatically compile the Tag, and deploy the result into Github’s Release:

Release content for automatic deployment:

  

More information about appveryor deployment reference: www.appveyor.com/docs/deploy…

Display the compile status on GitHub. Display the display status on the display page of Appveyor Badges.

  

Copy the MarkDown code to your project’s readme.md file:

  

Effect:

  

7. Export the Appveyor. yml file and complete the configuration through Appveyor. yml: You can configure the configuration on the Appveyor Web UI. You can also configure the configuration in the Appveyor. yml file, which can be used to create or export existing configurations.

  

Place the appveyor.yml file in the code root and change the configuration by modifying it:

  

On the basis of the original configuration, the above figure is modified to compile the code in the way of release, and the generated result directory is specified to compress the result. More appveyor. Yml configuration may refer to: www.appveyor.com/docs/appvey…

Use Codecov to display code coverage

Codecov is also a Github marketplace application that generates code coverage reports. Codecov’s support for C# is based on OpenCover (using OpenCover to detect code coverage reference: Good code is managed — unit testing and code coverage in.NET Core), Codecov is free for Github’s public projects. Here’s how to use Codecov to measure test code coverage: Install Codecov:

  

Note: After Codecov is installed, there will be an Upload Token to Upload code coverage reports to Codecov, but Appveyor’s public repository may not need this:

  

2. Modify the Appveyor.yml file:

  

Add installing OpenCover and Codecov using the Choco Manager, and then adding the code coverage analysis report and upload script to test_Script. Note: After the above changes are pushed to Github, Appveyor will automatically compile and complete all the work including code coverage report generation and upload. When you open the Codecov page, you will see the report information:

  

3. Add the Codecov tag to the readme. md file:

  

 

   

Results:

  

summary

This paper introduces the basic concepts of CI and CD. The former aims to find the code integration errors as early as possible in multi-person development, while the latter aims to avoid human-caused errors and hand over some repetitive things to the program for automatic completion, which can reduce costs and improve accuracy. One of the foundations of DevOps today is automation, CI and CD. In addition, this article describes simple continuous integration on Github using Appvoyer and Codecov tools, which automatically complete a series of build operations when new code is pushed to the Github repository. Appvoyer is a very powerful CI tool and has very good C# support. You can choose from VS versions (including preview versions), multiple databases (including SQL Server under Linux), so tests that rely on databases when running tests can also pass. The next article will introduce how to use Jenkins to set up a local CI server.

Reference: en.wikipedia.org/wiki/Contin… En.wikipedia.org/wiki/Compar… En.wikipedia.org/wiki/Contin… cakebuild.net/ docs.codecov.io/docs www.appveyor.com/docs/

This paper links: www.cnblogs.com/selimsong/p…