When creating applications that are becoming ever larger and which more people are working in, we are exposed to making more and more mistakes by manually executing some stages. To speed up the work and to avoid unexpected errors in the application, you can automate some things. That’s why a few days ago I decided to work with Gitlab CI and automated the development process from a commit to check the quality of my code with lint, make unit tests, build, and deploy my application.
In today’s entry, I would like to provide you with a description of what continuous integration is, using the Gitlab CI/CD tool. As an example, I will use the angular project. We will go through the implementation of CI for angular applications, defining a pipeline in gitlab-ci.yml files to build, deploy and test your applications, and assigning jobs to stages. The next step will be to create and register a runner, which will run and execute our stages.
What is CI/CD?
Continuous integration (CI) is a development practice where developers merge their own code with a shared repository several times a day.
Continuous delivery (CD) is a software development practice where code changes are automatically built, tested, and prepared for a release to production.
What is Gitlab CI/CD?
GitLab is a platform for storing and sharing public and private code repositories, but also a platform that provides tools for task management, software versioning, continuous integration and continuous delivery. Since version 8, Gitlab has been enriched and integrated with the possibility of CI/CD.
GitLab CI/CD is a tool for building, testing, implementing and monitoring applications and is integrated with the GitLab code repository.
The advantage of continuous integration is the automation of the integral part of the workflow.
In order to use the tool, we first need to create a new project in Gitlab containing an example application. We can also import our repository from Github.
Then, we need to create a file .gitlab-ci.yml and add it to the root directory of your repository. In our case, it can be a project created with the use of the ng new your-project command.
Gitlab uses the above file to define the project configuration.
Configure Gitlab CI file
In order to present the process of continuous integration, I will use a simple example of an Angular project.