Design and Implementation of a Continuous Integration System
Total Page:16
File Type:pdf, Size:1020Kb
Prakash Acharya DESIGN AND IMPLEMENTATION OF A CONTINUOUS INTEGRATION SYSTEM DESIGN AND IMPLEMENTATION OF A CONTINUOUS INTEGRATION SYSTEM Prakash Acharya Bachelor’s Thesis Spring 2019 Information Technology Oulu University of Applied Sciences ABSTRACT Oulu University of Applied Sciences Information Technology, Internet Services Author: Prakash Acharya Title of the bachelor’s thesis: Design and Implementation of a Continuous Integration System Supervisor: Lasse Haverinen Term and year of completion: Spring 2019 Number of pages: 43 Not having an automated test system in the software development process leaves space for errors to go unnoticed in code review, which can break a codebase if integrated. The aim of the Bachelor’s thesis was to design and implement a Continuous Integration system where tests and build tasks could be automated. The Buildbot framework was used as a Continuous Integration and automation framework. The Ansible playbook was used for automating the deployment of Buildbot configuration. The Buildbot configuration was created in such a way that it allows Buildbot instances to be created easily and in a configurable manner. In addition, automation of the Python static code analysis tool, Prospector, was added to the Continuous Integration system. The result of having a configurable Buildbot system was that the developers could start adding automation tasks and test and verify their change without affecting the production instance. Having an automated static code analysis run on changes brings into attention potential problems and error before they are integrated. Even though the Buildbot system is not taken into use, it was tested in a test environment and it is shown to work. It will be taken into use once the configuration for an integration builder is added. The main benefit of the system is that tests and build tasks can be added and automated in Buildbot. Keywords: Ansible, Buildbot, Continuous Integration, Gitlab 3 PREFACE The thesis work was done for GE Healthcare Finland Oy, Helsinki, during the Spring of 2019. I would like to thank my thesis instructor, Lasse Haverinen, and my language teacher, Kaija Posio, for their feedback on my writing. I would also like to thank my thesis supervisor, Riku Hämäläinen, for his help in clarifying ideas and tasks during the work. Prakash Acharya 02.05.2019, Helsinki 4 CONTENTS ABSTRACT 3 PREFACE 4 CONTENTS 5 1 INTRODUCTION 6 2 SOFTWARE DEVELOPMENT 8 2.1 Waterfall development 8 2.2 Spiral development 10 2.3 Agile development 12 3 CONTINUOUS INTEGRATION 13 3.1 Solutions 13 3.1.1 Buildbot 13 3.1.2 Jenkins 15 3.1.3 Gitlab CI 16 3.2 Continuous Delivery 17 3.3 Continuous Deployment 18 4 SOFTWARE TESTING 20 4.1 Functional testing 20 4.2 Non-functional testing 22 5 CONFIGURATION MANAGEMENT 24 Ansible 24 6 CONTINUOUS INTEGRATION DESIGN 28 6.1 Design choices 29 6.2 Components and design 30 7 IMPLEMENTATION 33 8 CONCLUSION 39 9 ANALYSIS AND FURTHER PLANS 40 REFERENCES 41 5 1 INTRODUCTION Software development is a process encompassing requirements definition, planning, designing, writing code, testing, releasing, and maintenance of a software product. As software projects grow bigger, in terms of both developers and complexity, the development workflow in the team also becomes complex. To reduce the complexity involved in the integration and release cycle of development, the concept of Continuous Integration (CI) and Continuous Delivery (CD) were introduced in the software development process. In Continuous Integration, the process of testing software changes and integration are automated. Continuous Delivery takes this further by automating building and production of software and related artefacts regularly. CI and CD together ensure a regular incremental change to the software product. Testing is an integral part of a software development process. Tests are important to ensure that changes do not introduce bugs, to ensure that changes do not break the existing functionality, and to ensure that the software works as it is required to. Software changes can be tested manually, or they can be automated depending in which phase of the development process they are carried out. Test automation is preferred to manual testing because it helps organizations to save resources and team time. The thesis work was carried out for GE Healthcare Finland Oy, Helsinki. GE Healthcare produces patient monitoring devices. The work was done in a tool development team responsible for development and maintenance of tools and infrastructure used for automating build, integration, and release of software. The thesis project had two objectives. The primary objective was to design and implement a Continuous Integration system for the team. To improve the current workflow, where changes to the tools developed by the team are integrated after code review, the requirement was to have a Continuous Integration system where tests and build tasks could be automated. When designing the CI system, another requirement was to design it 6 in such a way that allows the CI system to be easily reproduced. This requirement originates from the fact that verifying a change in the CI system itself, unlike in the tools which the CI system automates tasks for, requires a replication of the production instance of the CI system and making changes on top of it. This involves changing production environment specific parameters, such as database connections and secrets from the CI configuration. As the CI system is expanded with more automation tasks, identifying the variable components and changing them becomes difficult. In order to make verifying changes to the CI system itself easy, the requirement was to design the CI system to have a way to easily handle environment specific parameters. The other benefit of this approach would be that multiple developers could work on making changes to the CI system at the same time and verifying their changes independently without affecting the production instance of the CI system. The secondary objective was to automate the static code analysis for Python tools in the newly developed Continuous Integration system so that the system would have a value for taking into use. Static code analysis tools analyse source code, without compiling or running them, to detect errors and complexity in the code. Most of the tools developed by the team are Python tools. Automation of the static code analysis on changes would give an immediate feedback to a developer if errors, coding standard violations, complexity or potential problems were detected in the change. Currently, developers manually run a static code analysis before submitting a change for a code review. This objective of the project shifts running of the static code analysis from manual to automated. Having the static code analysis automated also eliminates the possibility of a human error where a developer forgets to run the static code analysis. In addition, it also paves a way for expanding the CI to add more rigorous tests, e.g. unit tests and system tests, and automation tasks based on the needs of the team. 7 2 SOFTWARE DEVELOPMENT Since software development involves people with different skillsets and their interaction for achieving a common goal, it is elementary that they co-operate and have transparency in their work. Different software development process models have been developed with an aim to optimise the process. While some process models, such as the Waterfall model, prescribe certain development steps to be executed in a certain order, other rather broader mindsets, such as the Agile, emphasise values and principles that should drive the development process. The size and requirements of a project play a critical role in determining the suitability of a model for the project. 2.1 Waterfall development The Waterfall development model was one of the first to be introduced in the software development process. According to Hamilton (1999, ch1), the Waterfall model added a formal structure to the overall software development process for the first time and identified key steps, such as requirements definition, system design, coding, and testing. The main feature of this model is linearity: development is carried out in phases and each phase accomplishes a goal. “-- it was created in 1970 by Winston Royce, and addresses all of the standard life cycle phases. It progresses nicely through requirements gathering and analysis, to architectural design, detailed design, coding, debugging, system testing, release, and maintenance. It requires detailed documentation at each stage, along with reviews, archiving of the documents, sign-offs at each process phase, configuration management, and close management of the entire project. It's a model of the plan-driven process.” (Dooley 2011, ch2.) The figure 1 below shows how development is carried out in phases, each working as an input for the next. For instance, a software architectural design phase starts only when all the requirements for the project have been defined. This requires that all the requirements for a software are well-known and 8 exhaustively covered during a requirement gathering phase. The same pattern is seen throughout the process. This model is heavily criticised. FIGURE 1. Unmodified Waterfall model (Wikipedia 2019c. Date of retrieval 24.03.2019) The Waterfall model works well for projects where the requirements for the project are well understood at the beginning of the process. Since it makes a clear distinction between the phases, planning and allocation of resources as well as progress tracking can be more effective. For instance, it works when developing software for a digital clock whose design or requirements are unlikely to change during the development. However, this model does not work for most systems. Having no iteration is one of its major drawbacks. Dooley (2011, ch2) argues that the model is fundamentally based on an assembly-line mentality for developing software. The waterfall diagram shows no way to go back and rework on design if a problem during the implementation is found.