A method, apparatus and system for pre-integrating code
By monitoring review events in the code management system and conducting integration testing in advance, the problem of team interference caused by problems detected only after code merging in the existing technology is solved, and code quality and delivery efficiency are improved.
Patent Information
- Application Number
- CN202111210623.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-18
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-10-18
AI Technical Summary
The existing continuous integration system can only detect code problems after the code is merged into the code warehouse, causing the problematic code to cause interference to other developers on the team and affecting the delivery of software products.
By monitoring the review events of the code management system, parsing the preset verification instructions, and conducting integration testing on the code in advance to ensure that the code passes the test before being merged into the code warehouse, problems can be discovered and solved during the review stage and the code quality can be improved.
It reduces the impact of problematic code on other developers in the team, improves team work efficiency, and ensures the delivery quality of code and software products.
Smart Images

Figure CN113946514B
Abstract
Description
Technical Field
[0001] The present application relates to the field of software engineering technology, and in particular to a code pre-integration method, device and system. Background Art
[0002] In software development, continuous integration technology has been widely used. After the developer submits the code, the reviewer reviews the code and then merges the code into the code repository. The continuous integration system regularly detects new code in the code repository, then performs automatic compilation and testing, and records and sends the compilation and testing results to the development team. Continuous integration enables developers to promptly learn about the quality problems of the latest submitted code, such as compilation errors, code style, software bugs (vulnerabilities), etc. Without continuous integration, when a problem occurs, it will be difficult to find the problem point from hundreds of changes. Continuous integration can also help developers find software problems at the first time and correct and improve the software as soon as possible. If new code is added on the basis of the problem code, it will make the software difficult to maintain and correct. Therefore, modern software development relies heavily on continuous integration to monitor and manage software quality through continuous integration.
[0003] However, the current continuous integration system can only periodically detect new code in the code repository and then perform code detection. However, the code merged into the code repository can already be used by other developers in the team. When the continuous integration system detects a problem with the code, the code needs to be returned to the original developer, who will then solve the problem and merge it back into the code repository. During this period, other developers in the team can only wait for the re-merged code. It can be seen that although the current code continuous integration method can detect code problems, it will seriously interfere with other developers in the team, thus affecting the delivery of code and software products. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a code pre-integration method, device and system to obtain code problems before the code is submitted to the code repository, improve the quality of the code used to be merged into the code repository, reduce the impact of problematic code on other developers in the team, improve team work efficiency, and ensure the delivery of code and software products.
[0005] The present invention is achieved in that:
[0006] In a first aspect, an embodiment of the present application provides a code pre-integration method, which is applied to a continuous integration system, the method comprising: monitoring review events of a code management system, and when detecting that the review event includes a preset verification instruction, parsing the preset verification instruction; wherein the preset verification instruction includes a first project to be tested; the code management system is used to obtain a first code to be merged uploaded by a developer, and to obtain the review event submitted by a reviewer based on the first code; to obtain the first code and the first project, and to merge the first code into the first project, and to perform code testing on the merged first project; to send the code test result of the merged first project to the code management system; wherein, when the code test result of the merged first project is a passed test, the code management system is used to submit the first code to a code repository so that the first code is merged with the first project in the code repository.
[0007] In an embodiment of the present application, the continuous integration system monitors the review events of the code management system. When it is detected that the review events include preset verification instructions, the preset verification instructions are parsed, and the code is integrated tested based on the parsed preset verification instructions. In this way, the code completes the integration test during the review stage, that is, before the code is merged into the code repository. It also enables developers to be aware of code problems and solve them in a timely manner before the code is merged into the code repository, thereby improving the quality of the code to be merged into the code repository, reducing the impact of problematic code on other developers in the team, improving team work efficiency, and ensuring the delivery of code and software products.
[0008] In combination with the technical solution provided in the first aspect above, in some possible implementation methods, merging the first code into the first project includes: obtaining a second code that is related to the first project and has not been merged into the first project; wherein the second code is a code to be merged uploaded to the code management system by other developers; and merging the first code and the second code into the first project.
[0009] In an embodiment of the present application, during the merging, the codes related to the first project submitted by other developers will also be merged and tested. In this way, it is possible to know in advance whether there will be problems after combining the codes submitted by different developers, and then solve the code problems of different developers in advance, thereby improving team work efficiency.
[0010] In combination with the technical solution provided in the first aspect above, in some possible implementations, before merging the first code and the second code into the first project, the method further includes: determining that there is no code conflict between the first code and the second code.
[0011] In an embodiment of the present application, before merging codes submitted by different developers, the continuous integration system will first determine whether there are code conflicts between the codes. Only when there are no code conflicts will the codes be merged. When there are code conflicts, the continuous integration system will not perform integration testing. In this way, the detection efficiency can be improved.
[0012] In combination with the technical solution provided in the first aspect above, in some possible implementations, the preset verification instruction also includes a second project to be tested, and the method also includes: obtaining the second project, merging the first code into the second project, and performing code testing on the merged second project; sending the code test result of the merged second project to the code management system; wherein, when the code test result of the merged second project is that the test passes, the code management system is used to submit the first code to the code repository so that the first code is merged with the second project in the code repository.
[0013] In an embodiment of the present application, when the first code submitted by the developer is applicable to different projects at the same time, the continuous integration system can test the different projects at the same time, thereby improving the efficiency of integrated testing.
[0014] In combination with the technical solution provided in the first aspect above, in some possible implementation methods, the preset verification instruction also includes a first module of the first project, and the first project includes multiple modules; merging the first code into the first project and performing code testing on the merged first project include: merging the first code into the first module, and performing code testing on the merged first module; sending the code test results of the merged first project to the code management system include: sending the code test results of the merged first module to the code management system.
[0015] In an embodiment of the present application, when the first code only affects one module in the project, the continuous integration system may merge only the first code into the module during testing, and only test the merged module. In this way, integration testing of the entire project can be avoided, thereby saving time for code integration testing.
[0016] In combination with the technical solution provided in the first aspect above, in some possible implementations, the code test performed on the merged first project includes at least one of compilation test, static code quality check, and automated test.
[0017] In combination with the technical solution provided in the first aspect above, in some possible implementations, the continuous integration system locally stores the code of the first project.
[0018] In an embodiment of the present application, the continuous integration system locally stores the code of the first project. In this way, the continuous integration system can directly grab the project code locally. Compared with grabbing the project code from the code repository, the grabbing time can be reduced and the speed of project code grabbing can be increased.
[0019] In combination with the technical solution provided in the first aspect above, in some possible implementations, when the code test result of the merged first project is that there is a code error, the method also includes: obtaining the developer's email address from the code management system; and sending the code error result to the email address.
[0020] In an embodiment of the present application, when the code test result of the merged first project is that there is an error in the code, the continuous integration system can directly obtain the developer's email address from the code management system to automatically notify the developer in a timely manner.
[0021] In a second aspect, an embodiment of the present application provides a code pre-integration method, which is applied to a code management system, and the method includes: obtaining a first code to be merged uploaded by a developer; obtaining a review event submitted by a reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes a first project to be tested; obtaining a code test result of the merged first project sent by a continuous integration system; wherein the continuous integration system listens to the review event, and when it is detected that the review event includes the preset verification instruction, parses the preset verification instruction, obtains the first code and the first project, merges the first code into the first project, and performs code testing on the merged first project to obtain a code test result; when the code test result is that the test passes, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository.
[0022] In a third aspect, an embodiment of the present application provides a code pre-integration device, which is applied to a continuous integration system, and the device includes: a monitoring module, which is used to monitor the review events of a code management system, and when it is detected that the review event includes a preset verification instruction, the preset verification instruction is parsed; wherein the preset verification instruction includes a first project to be tested; the code management system is used to obtain the first code to be merged uploaded by the developer, and obtain the review event submitted by the reviewer based on the first code; a testing module, which is used to obtain the first code and the first project, merge the first code into the first project, and perform code testing on the merged first project; a sending module, which is used to send the code test result of the merged first project to the code management system; wherein, when the code test result of the merged first project is that the test passes, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository.
[0023] In a fourth aspect, an embodiment of the present application provides a code pre-integration device, which is applied to a code management system, and the device includes: a first acquisition module, used to acquire a first code to be merged uploaded by a developer; a second acquisition module, used to acquire a review event submitted by a reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes a first project to be tested; a third acquisition module, used to acquire a code test result of the merged first project sent by a continuous integration system; wherein the continuous integration system monitors the review event, and when it is detected that the review event includes the preset verification instruction, parses the preset verification instruction, acquires the first code and the first project, merges the first code into the first project, and performs code testing on the merged first project to obtain a code test result; when the code test result is that the test passes, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository.
[0024] In a fifth aspect, an embodiment of the present application provides a code pre-integration system, comprising a continuous integration system, a code management system and a code repository; the code management system is used to obtain a first code to be merged uploaded by a developer, and to obtain a review event submitted by a reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes a first project to be tested; the continuous integration system is used to monitor the review event, and when it is detected that the review event includes a preset verification instruction, parse the preset verification instruction, obtain the first code and the first project, and merge the first code into the first project, perform code testing on the merged first project, and send the code test result of the merged first project to the code management system; the code management system is also used to submit the first code to the code repository when the code test result of the merged first project is a passed test, so as to merge the first code with the first project in the code repository.
[0025] In combination with the technical solution provided in the fifth aspect above, in some possible implementations, there are multiple continuous integration systems.
[0026] In an embodiment of the present application, tasks can be processed in parallel through multiple continuous integration systems, that is, when multiple developers verify the code at the same time, the verification tasks of the multiple developers can be processed simultaneously through multiple continuous integration systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 A system block diagram of a code pre-integration system provided in an embodiment of the present application.
[0029] Figure 2 A flowchart of the steps of the first code pre-integration method provided in an embodiment of the present application.
[0030] Figure 3 A flowchart of the steps of the second code pre-integration method provided in an embodiment of the present application.
[0031] Figure 4 A flowchart of the steps of the third code pre-integration method provided in an embodiment of the present application.
[0032] Icons: 10-code pre-integration system; 100-code management system; 200-continuous integration system; 300-code repository. DETAILED DESCRIPTION
[0033] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0034] See also Figure 1 An embodiment of the present application provides a code pre-integration system 10, including a code management system 100, a continuous integration system 200, and a code repository 300.
[0035] The code management system 100 can facilitate the reviewer to review the code submitted by the developer. In the embodiment of the present application, the code management system 100 is specifically used to obtain the first code to be merged uploaded by the developer and obtain the review event submitted by the reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes the first project to be tested; then obtain the code test result of the merged first project sent by the continuous integration system 200; when the code test result is that the test passes, the code management system is used to submit the first code to the code warehouse 300, so that the first code is merged with the first project in the code warehouse 300.
[0036] The code management system 100 can be constructed through Gerrit. Gerrit is an open source code review software that uses a web interface. Reviewers can review the program code submitted by the developer or the modified program code through the web interface to decide whether to submit, return or continue to modify.
[0037] Of course, the code management system 100 can also be constructed through Github, which is also an open source code hosting platform.
[0038] The above-mentioned code management system 100 can be configured in an electronic device, which can be a terminal or a server. The terminal can be, but not limited to, a personal computer (PC), a smart phone, a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID), etc. The server can be, but not limited to, a network server, a database server, a cloud server, or a server integration composed of multiple sub-servers, etc. Of course, the above-mentioned devices are only used to facilitate the understanding of the embodiments of the present application, and they should not be used as limitations on the embodiments.
[0039] Structurally, an electronic device may include a processor and a memory.
[0040] The processor and the memory are directly or indirectly electrically connected to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines. The processor can execute the computer program after receiving the execution instruction.
[0041] The processor may be an integrated circuit chip with signal processing capability. The processor may also be a general-purpose processor, for example, a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a discrete gate or transistor logic device, or a discrete hardware component, which may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. In addition, the general-purpose processor may be a microprocessor or any conventional processor, etc.
[0042] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), and an electric erasable programmable read-only memory (EEPROM). The memory is used to store a program, and the processor executes the program after receiving an execution instruction.
[0043] Among them, the continuous integration system 200 is a system that can realize automatic compilation and testing of code. In the embodiment of the present application, the continuous integration system 200 is specifically used to monitor the review event of the code management system 100, and when it is detected that the review event includes a preset verification instruction, the preset verification instruction is parsed; wherein the preset verification instruction includes a first project to be tested; obtain the first code and the first project, merge the first code into the first project, and perform code testing on the merged first project; send the code test results of the merged first project to the code management system 100.
[0044] The continuous integration system 200 can be constructed by Jenkins, which is an open source software project and a continuous integration tool developed based on Java (a computer coding language).
[0045] The continuous integration system 200 can be configured in an electronic device. The continuous integration system 200 can be configured in the same electronic device as the code management system 100, or can be configured in a different electronic device. Since the electronic device has been described in the code management system 100, it will not be described here in detail, and the same parts can be referenced to each other.
[0046] In addition, in an embodiment of the present application, there are multiple continuous integration systems 200, and tasks can be processed in parallel through multiple continuous integration systems 200. That is, when multiple developers verify the code at the same time, the verification tasks of multiple developers can be processed simultaneously through multiple continuous integration systems 200.
[0047] Code repository 300 is mainly used to store project codes. Code repository can also be built through Gerrit or Github.
[0048] See also Figure 2 , Figure 2 A flowchart of the steps of the code pre-integration method provided in the embodiment of the present application, which is applied to Figure 1 It should be noted that the code pre-integration method provided in the embodiment of the present application is not based on Figure 2 The order shown below is limited, and the method includes: step S101-step S106.
[0049] Step S101: the code management system obtains the first code to be merged uploaded by the developer.
[0050] When the developer completes the development of the code, the developer submits the first code to the code management system. The first code here can be understood as a change, patch or new function for the first project.
[0051] For example, when the first project is a game, the first code may refer to a code corresponding to a game task that needs to be added in the game. When the first project is an office software, the first code may refer to a code corresponding to a function in the office software.
[0052] Step S102: the code management system obtains a review event submitted by a reviewer based on the first code.
[0053] The review event includes a preset verification instruction, and the preset verification instruction includes a first item to be tested.
[0054] When the code management system obtains the first code to be merged uploaded by the developer, the reviewer can manually review the uploaded code. At this time, the reviewer will submit a review event, which includes the reviewer's score for the code. In the embodiment of the present application, in order to implement the integration test of the code in the review stage, the reviewer needs to write a specific string in the review event, that is, a preset verification instruction, so that the subsequent continuous integration system can detect the preset verification instruction and perform corresponding tests.
[0055] Exemplarily, the reviewer reviews the first code and then submits a review event corresponding to the first code, wherein the preset verification instruction is “verify_projectA”. ProjectA is the first project to be tested.
[0056] Step S103: the continuous integration system monitors the review events of the code management system, and when it is detected that the review events include preset verification instructions, the preset verification instructions are parsed.
[0057] The continuous integration system will always monitor the review events in the code management system. When it detects that the review event includes preset verification instructions, it will parse the instructions. When the preset verification instructions are not detected in the review event, it will continue to monitor the next review event.
[0058] Exemplarily, the continuous integration system is monitoring review event A. When it is detected that review event A includes a preset verification instruction "verify_projectA", the instruction is parsed. Through the analysis, it can be known that project projectA needs to be verified.
[0059] Step S104: the continuous integration system obtains the first code and the first project, merges the first code into the first project, and performs code testing on the merged first project.
[0060] After parsing the preset verification instruction and parsing out the first project that needs to be verified, the continuous integration system obtains the first project and obtains the first code according to the review object of the review event.
[0061] The first code may be directly extracted from a code management system, and the first project may be extracted from a code repository.
[0062] In order to reduce the crawling time and increase the speed of crawling the project code, the continuous integration system can store the code of the first project locally, so that the continuous integration system can directly crawl the project code from the local. Specifically, the continuous integration system can retain the local repo directory and crawl the code through the repo sync -c command.
[0063] After obtaining the first code and the first project, the continuous integration system merges the first code into the first project. It should be noted that the merge here can be understood as the continuous integration system merging the first code and the first project locally, rather than merging the first code into the code repository. And the first project after the local merge will not be used by other developers, and other developers can only use the first project in the code repository that has not been merged with the first code.
[0064] After merging the first code into the first project, the continuous integration system can test the merged first project.
[0065] First, the continuous integration system will compile and test the first merged project. When a compilation error is found, the continuous integration system will stop testing. If the compilation is successful, the continuous integration system can perform static code quality detection. Among them, static code quality detection can include code inspection, static structure analysis, code quality measurement, etc. Static code quality detection can check the consistency of code and design, the compliance of code with standards, readability, correctness of logical expression of code, rationality of code structure, etc.; it can find problems that violate program writing standards, unsafe, unclear and ambiguous parts of the program, and find out the non-portable parts of the program and problems that violate the programming style of the program, including variable inspection, naming and type review, program logic review, program syntax check and program structure check. Whether static code quality detection is performed depends on project requirements. For example, static code quality detection can be applied to checkpatch of kernel (real-time operating system); scan-build of iOS (an operating system); cppcheck of C code. checkpatch, scan-build and cppcheck are a project.
[0066] If the static code quality test fails, the test is stopped. If the static code quality test passes, the continuous integration system can also perform automated testing. It should be noted that automated testing is to write the code into the corresponding hardware device for testing. For example, if the first code is applied to embedded device A, the continuous integration system will burn the first code into embedded device A for testing.
[0067] It should be noted that the above-mentioned testing method is only an example. The code test performed on the merged first project can be any one or more of the above-mentioned testing methods. Of course, it can also be any other testing method adapted according to the code, such as automated checking of code style and quality, automated deployment of iOS programs in the App Store, etc., which are not limited in this application.
[0068] Step S105: The continuous integration system sends the merged code test result of the first project to the code management system.
[0069] After the test is completed, the continuous integration system sends the code test results of the merged first project to the code management system. It should be noted that during the compilation test of the merged first project, if a compilation error is tested, the continuous integration system stops the test (stopping the test means that the test is completed).
[0070] In addition, the code test results fed back by the continuous integration system may also include the code score. If a compilation error is found, points will be deducted in the review event of the first code, such as the scoring item review-1. When the continuous integration system is built through Jenkins, feedback is provided through the SSH channel. If it is found that the static code quality test fails, points will be deducted in the review event of the first code, such as the scoring item review-1. Of course, when the test is completed, corresponding points can also be added. If it is found that the static code quality test passes, points will be added in the review event of the first code, such as the scoring item review+1. If the automated test is completed, points will be added in the review event of the first code, such as the scoring item verify+1. If the automated test is not completed, points will be deducted in the review event of the first code, such as the scoring item verify-1.
[0071] Step S106: When the code test result of the merged first project is that the test passes, the code management system is used to submit the first code to the code repository, so that the first code is merged with the first project in the code repository.
[0072] When the code test result of the merged first project is passed, the reviewer can click Submit, so that the code management system submits the first code to the code repository, so that the first code is merged with the first project in the code repository. Of course, the code management system can also actively submit the first code to the code repository when receiving the code test result of the first project that the test is passed, which is not limited in this application.
[0073] When the code test result of the merged first project fails, the first code needs to be returned to the developer so that the developer can make modifications.
[0074] In summary, in an embodiment of the present application, the continuous integration system monitors the review events of the code management system. When it is detected that the review events include preset verification instructions, the preset verification instructions are parsed, and the code is integrated tested based on the parsed preset verification instructions. In this way, the code completes the integration test during the review stage, that is, before the code is merged into the code repository. Developers can also be aware of code problems and solve them in a timely manner before the code is merged into the code repository, thereby improving the quality of the code to be merged into the code repository, reducing the impact of problematic code on other developers in the team, improving team work efficiency, and ensuring the delivery of code and software products.
[0075] Optionally, step S104 of merging the first code into the first project may also specifically include: obtaining a second code related to the first project and not merged into the first project; wherein the second code is the code to be merged uploaded to the code management system by other developers; and merging the first code and the second code into the first project.
[0076] It should be noted that different developers may submit codes for the same project (such as the first project) at the same time. If each code is integrated with the first project separately, it is impossible to determine whether an error will occur when the codes jointly submitted by different developers are merged into the first project at the same time. Therefore, in the embodiment of the present application, when the first code is merged into the first project, the second code related to the first project and not merged into the first project is also obtained, and then the second code is also merged.
[0077] The second code can be submitted by one developer or multiple developers. For example, developer A can submit the first code for the first project, and developer B and developer C can submit the second code for the first project. At this time, the continuous integration system merges the first code submitted by developer A and the second code submitted by developers B and C into the first project for integration testing.
[0078] It can be seen that the continuous integration system will also merge and test the code related to the first project submitted by other developers during merging. In this way, it can be known in advance whether there will be problems after the code submitted by different developers is combined, and then the code problems of different developers can be solved in advance, thereby improving team work efficiency.
[0079] Optionally, before the above embodiment merges the first code and the second code into the first project, the method further includes: determining that there is no code conflict between the first code and the second code.
[0080] That is, before merging the codes submitted by different developers, the continuous integration system will first determine whether there are code conflicts between the codes. Only when there are no code conflicts will the codes be merged. When there are code conflicts, the continuous integration system will not perform integration testing. This method can improve detection efficiency.
[0081] Optionally, the preset verification instruction may further include a second project to be tested. Accordingly, in step S103, when parsing the preset verification instruction, the continuous integration system will parse out two tasks, namely, verifying the first project and verifying the second project.
[0082] Exemplarily, the continuous integration system is monitoring review event A. When it is detected that review event A includes a preset verification instruction "verify_projectA / verify_projectB", the instruction is parsed. Through the analysis, it can be known that projectA and projectB need to be verified.
[0083] Accordingly, step S104 further includes: the continuous integration system acquires the second project, merges the first code into the second project, and performs code testing on the merged second project; and sends the code testing result of the merged second project to the code management system;
[0084] Correspondingly, step S106 also includes when the code test result of the merged second project is that the test passes, the code management system is used to submit the first code to the code repository, so that the first code is merged with the second project in the code repository.
[0085] It can be seen that in the embodiment of the present application, when the first code submitted by the developer is applicable to different projects at the same time, the continuous integration system can test the different projects at the same time, which can improve the efficiency of integrated testing.
[0086] In addition, in the process of merging the first code into the second project, the continuous integration system can also obtain a third code related to the second project and not merged into the second project; wherein the third code is the code to be merged uploaded to the code management system by other developers; and merge the first code and the third code into the first project. Since this process is also described in the above embodiment, it will not be repeated here.
[0087] Optionally, the preset verification instruction may further include the first module of the first project; the first project includes multiple modules. Accordingly, in step S103, when parsing the preset verification instruction, the continuous integration system will parse out the task of verifying the first module in the first project.
[0088] Exemplarily, the continuous integration system is monitoring review event A. When it is detected that review event A includes a preset verification instruction "verify_projectA / module1", the instruction is parsed. Through the analysis, it can be known that module module1 in project projectA needs to be verified.
[0089] Correspondingly, in step S104, the continuous integration system merges the first code into the first module, and performs code testing on the merged first module;
[0090] In step S105, the continuous integration system sends the merged code test result of the first module to the code management system.
[0091] It can be seen that in an embodiment of the present application, when the first code only affects one module in the project, the continuous integration system can only merge the first code into the module during testing, and only test the merged module. In this way, integration testing of the entire project can be avoided, thereby saving time for code integration testing.
[0092] In addition, it should be noted that the above-mentioned several implementation modes can be combined with each other. For example, the preset verification instruction can include multiple items, each item includes multiple modules, etc., which is not limited in this application.
[0093] Optionally, when the code test result of the merged first project is that there is a code error, the continuous integration system can also directly obtain the developer's email address from the code management system so as to automatically notify the developer immediately. That is, after step S104, the method includes: the continuous integration system obtains the developer's email address from the code management system; and sends the code error result to the email address.
[0094] In addition, the continuous integration system of the embodiment of the present application deletes the code submitted by the previous developer during each integration test, and then rebuilds a clean code environment to ensure high reliability of code verification. The above code pre-integration method can be applied to a wide range of software fields, including embedded software, Internet software, Android / iOS applications, etc.
[0095] See also Figure 3 Based on the same inventive concept, the embodiment of the present application also provides a code pre-integration method, which is applied alone in a continuous integration system. The method specifically includes: Step S201-Step S203.
[0096] Step S201: monitoring the review events of the code management system, and when detecting that the review events include preset verification instructions, parsing the preset verification instructions.
[0097] The preset verification instruction includes a first project to be tested; the code management system is used to obtain the first code to be merged uploaded by the developer, and obtain the review event submitted by the reviewer based on the first code.
[0098] Step S202: Acquire the first code and the first project, merge the first code into the first project, and perform code testing on the merged first project.
[0099] Step S203: Send the merged code test result of the first project to the code management system.
[0100] When the code test result of the merged first project is that the test passes, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository.
[0101] Since the method has been described in the aforementioned embodiments, the same parts can be referred to each other and will not be described in detail here.
[0102] See also Figure 4 Based on the same inventive concept, the embodiment of the present application also provides a code pre-integration method, which is applied to the code management system alone. The method specifically includes: Step S301-Step S303.
[0103] Step S301: Obtain the first code to be merged uploaded by the developer.
[0104] Step S302: Obtain a review event submitted by a reviewer based on the first code.
[0105] The review event includes a preset verification instruction, and the preset verification instruction includes a first item to be tested.
[0106] Step S303: Obtain the code test result of the merged first project sent by the continuous integration system.
[0107] Among them, the continuous integration system monitors the review event, and when it is detected that the review event includes a preset verification instruction, it parses the preset verification instruction, obtains the first code and the first project, merges the first code into the first project, and performs code testing on the merged first project to obtain the code test result; when the code test result is that the test passes, the code management system is used to submit the first code to the code repository to merge the first code with the first project in the code repository.
[0108] Since the method has been described in the aforementioned embodiments, the same parts can be referenced to each other and will not be described in detail here.
[0109] Based on the same inventive concept, the embodiment of the present application further provides a code pre-integration device, which is applied to a continuous integration system, and the device includes:
[0110] A monitoring module is used to monitor the review events of the code management system, and when it is detected that the review event includes a preset verification instruction, the preset verification instruction is parsed; wherein the preset verification instruction includes a first project to be tested; the code management system is used to obtain the first code to be merged uploaded by the developer, and obtain the review event submitted by the reviewer based on the first code.
[0111] A testing module is used to obtain the first code and the first project, merge the first code into the first project, and perform code testing on the merged first project.
[0112] A sending module is used to send the code test result of the merged first project to the code management system; wherein, when the code test result of the merged first project is a passed test, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository.
[0113] Optionally, the testing module is also used to obtain a second code related to the first project and not merged into the first project; wherein the second code is the code to be merged uploaded to the code management system by other developers; and merge the first code and the second code into the first project.
[0114] Optionally, the testing module is further used to determine that no code conflict occurs between the first code and the second code before merging the first code and the second code into the first project.
[0115] Optionally, the preset verification instruction also includes a second project to be tested, and the test module is also used to obtain the second project, merge the first code into the second project, and perform code testing on the merged second project. Correspondingly, the sending module is also used to send the code test result of the merged second project to the code management system; wherein, when the code test result of the merged second project is a passed test, the code management system is used to submit the first code to the code warehouse so that the first code is merged with the second project in the code warehouse.
[0116] Optionally, the preset verification instruction also includes a first module of the first project, and the first project includes multiple modules. The testing module is also used to merge the first code into the first module, and perform code testing on the merged first module. Correspondingly, the sending module is also used to send the code test result of the merged first module to the code management system.
[0117] Optionally, the sending module is further used to obtain the developer's email address from the code management system when the code test result of the merged first project is that a code error exists; and send the code error result to the email address.
[0118] Based on the same inventive concept, the embodiment of the present application further provides a code pre-integration device, which is applied to a code management system, and the device includes:
[0119] The first acquisition module is used to acquire the first code to be merged uploaded by the developer.
[0120] The second acquisition module is used to acquire a review event submitted by a reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes a first item to be tested.
[0121] The third acquisition module is used to obtain the code test result of the merged first project sent by the continuous integration system; wherein, the continuous integration system monitors the review event, and when it is detected that the review event includes the preset verification instruction, parses the preset verification instruction, obtains the first code and the first project, merges the first code into the first project, and performs code testing on the merged first project to obtain the code test result; when the code test result is that the test passes, the code management system is used to submit the first code to the code repository to merge the first code with the first project in the code repository.
[0122] It should be noted that, since technicians in the relevant field can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0123] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the method provided in the above embodiment is executed.
[0124] The storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0125] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0126] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0127] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0128] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0129] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A code pre-integration method, It is characterized in that Applied to a continuous integration system, the method includes: Monitoring the review event of the code management system, and parsing the preset verification instruction when detecting that the review event includes a preset verification instruction; wherein the preset verification instruction includes a first item to be tested and a second item to be tested; the code management system is used to obtain the first code to be merged uploaded by the developer, and obtain the review event submitted by the reviewer based on the first code; Acquire the first code and the first project, merge the first code into the first project, and perform code testing on the merged first project; acquire the second project, merge the first code into the second project, and perform code testing on the merged second project; The code test result of the merged first project is sent to the code management system, and the code test result of the merged second project is sent to the code management system; wherein, when the code test result of the merged first project is a passed test, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository; when the code test result of the merged second project is a passed test, the code management system is used to submit the first code to the code repository so that the first code is merged with the second project in the code repository.
2. The method according to claim 1, It is characterized in that The step of merging the first code into the first project includes: Acquire a second code that is related to the first project and has not been merged into the first project; wherein the second code is a code to be merged uploaded to the code management system by other developers; The first code and the second code are merged into the first project.
3. The method according to claim 2, It is characterized in that Before merging the first code and the second code into the first project, the method further includes: It is determined that no code conflict occurs between the first code and the second code.
4. The method according to claim 1, It is characterized in that The preset verification instruction also includes a first module of the first project, and the first project includes multiple modules; The step of merging the first code into the first project and performing code testing on the merged first project includes: Merging the first code into the first module, and performing code testing on the merged first module; The sending the merged code test result of the first project to the code management system includes: The code test result of the merged first module is sent to the code management system.
5. The method according to claim 1, It is characterized in that The code test performed on the merged first project includes at least one of compilation test, static code quality check, and automated test.
6. The method according to claim 1, It is characterized in that The continuous integration system locally stores the code of the first project.
7. The method according to claim 1, It is characterized in that When the code test result of the merged first project is that a code error exists, the method further includes: Obtain the developer's email address from the code management system; The code error result is sent to the mailbox.
8. A code pre-integration method, It is characterized in that Applied to a code management system, the method comprises: Get the first code to be merged uploaded by the developer; Obtaining a review event submitted by a reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes a first item to be tested and a second item to be tested; Obtain the code test result of the merged first project sent by the continuous integration system, and obtain the code test result of the merged second project sent by the continuous integration system; wherein, the continuous integration system monitors the review event, and when it is detected that the review event includes the preset verification instruction, parses the preset verification instruction, obtains the first code and the first project, merges the first code into the first project, and performs code testing on the merged first project to obtain the code test result, and obtains the second project, merges the first code into the second project, and performs code testing on the merged second project to obtain the code test result; when the code test result is a test pass, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository, and when the code test result of the merged second project is a test pass, the code management system is used to submit the first code to the code repository so that the first code is merged with the second project in the code repository.
9. A code pre-integration device, It is characterized in that Applied to a continuous integration system, the device comprises: A monitoring module is used to monitor the review events of the code management system, and when it is detected that the review event includes a preset verification instruction, parse the preset verification instruction; wherein the preset verification instruction includes a first project to be tested and a second project to be tested; the code management system is used to obtain the first code to be merged uploaded by the developer, and obtain the review event submitted by the reviewer based on the first code; a testing module, configured to obtain the first code and the first project, merge the first code into the first project, and perform code testing on the merged first project; and further configured to obtain the second project, merge the first code into the second project, and perform code testing on the merged second project; A sending module is used to send the code test result of the merged first project to the code management system, and is also used to send the code test result of the merged second project to the code management system; wherein, when the code test result of the merged first project is a test pass, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository; when the code test result of the merged second project is a test pass, the code management system is used to submit the first code to the code repository so that the first code is merged with the second project in the code repository.
10. A code pre-integration device, It is characterized in that Applied to a code management system, the device comprises: A first acquisition module, used to acquire the first code to be merged uploaded by the developer; A second acquisition module is used to acquire a review event submitted by a reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes a first item to be tested and a second item to be tested; The third acquisition module is used to obtain the code test result of the merged first project sent by the continuous integration system; wherein, the continuous integration system listens to the review event, and when it is detected that the review event includes the preset verification instruction, parses the preset verification instruction, obtains the first code and the first project, merges the first code into the first project, and performs code testing on the merged first project to obtain a code test result, and obtains the second project, merges the first code into the second project, and performs code testing on the merged second project to obtain a code test result; when the code test result is a passed test, the code management system is used to submit the first code to the code repository so that the first code is merged with the first project in the code repository, and when the code test result of the merged second project is a passed test, the code management system is used to submit the first code to the code repository so that the first code is merged with the second project in the code repository.
11. A code pre-integration system, It is characterized in that Including continuous integration system, code management system and code repository; The code management system is used to obtain the first code to be merged uploaded by the developer, and obtain the review event submitted by the reviewer based on the first code; wherein the review event includes a preset verification instruction, and the preset verification instruction includes a first item to be tested and a second item to be tested; The continuous integration system is used to monitor the review event, and when detecting that the review event includes a preset verification instruction, parse the preset verification instruction, obtain the first code and the first project, merge the first code into the first project, perform code testing on the merged first project, and send the code test result of the merged first project to the code management system, and obtain the second project, merge the first code into the second project, perform code testing on the merged second project, and send the code test result of the merged second project to the code management system; The code management system is also used to submit the first code to the code repository when the code test result of the merged first project is a passed test, so that the first code is merged with the first project in the code repository; and when the code test result of the merged second project is a passed test, the code management system is used to submit the first code to the code repository, so that the first code is merged with the second project in the code repository.
12. The system according to claim 11, It is characterized in that There are multiple continuous integration systems.
