CI(Continuous Integration)
I write about CI once. I thought I could write about github actions simply, but I thought it would be better to deal with the contents in more detail than I thought.
Why CI
Developers work in teams of several developers. Alice and Bob met six months after developing a function they were responsible for without communication with each other. Now, we want to merge each other’s code into the project main branch. Merge does not work. Each other’s code conflicts.
- Alice, Bob: What’s the matter?? *Alice: Well done in my local area.
- Bob: Me too!!
- The two compare each other’s codes.
- Alice: What, I deleted this function, your code has it
- Bob: No!!!! when did you delete it?? I need this function !
- Alice: I deleted it because I don’t need it, why didn’t you ask!!!???
You keep repeating this over and over and you end up merging the code somehow. This situation is called merge hell. Seriously, it happened a long time ago, but in fact, I also experienced the same phenomenon while working on the final project of the 2nd boost camp. What can I do to prevent this? A function is divided into small units and periodically merged into the main branch whenever a function is created.
- Alice (after writing 3 lines): Well, it’s working fine. It should be merged into the main branch .
- Alice: Bob, added a feature. update the code
- Bob: Okay. (And then, Bob pulls the code from the main branch and updates it.)
This way your code is always up to date. (It is also important to manage these versions, which we will discuss in another article.) .Therefore, there are fewer conflicts when merging into the main branch. “If you get sick at once, you won’t be able to recover, so you get hit less and more often.” This is Continuos Integration.
CI automation
Let’s take the situation where Alice creates a new function as an example.
- Alice: (After writing 3 lines) I wrote a new code, so I need to call Mike. Mike, please test this!!
- Mike: Send me the Alice code and I’ll test it. First you need to build the code
- Mike: (After successful build) Well, the build was successful, next time we need to do a unit test.
- Mike : (Unit Test failed) Failed. There is a code conflict, which was recently fixed by Alice and Bob. I’ll have to call them both.
- Mike : (Email ) To, Alice , Bob , and other team members: Alice, Bob’s code conflicts and the test fails.
By automating the repetitive process of building each time like this, you can reduce the time for repetitive tasks. If you set up an automated tool on the server and write a new code, the build-test process is automatically performed. If successful, merge. If this fails or succeeds, you could set up an alert or email to your teammates.
github action
Github provides a service that can automate this CI/CD pipeline. That is, a service called github action.
You can see that there is Actions next to Pull Request.
If you go to Github Actions, you can select the workflow of the action you want.
If a workflow already exists, you can add the workflow you want to add as a New Workflow.
A github action consists of such a workflow.
workflow
This is the highest level concept. It is composed of several jobs. Workflows are saved as yaml
files in .github.workflows
directory.
Event
Define the event that triggers the workflow on the on key. (It is okay to call it a cue that creates a habit.) The events that can be defined here are push and pull_request.
The code isn’t written here, but you can use the schedule option to determine when it will run. These various options are detailed in the github documentatino. It would be good to find out if there is a function you need and apply it.
jobs
A job is a combination of steps executed in a runner. These jobs can be specified to run sequentially or in parallel.
step
Steps are individual tasks executed in a job. Execute an Action or execute a shell command. In step, you can share data with each other.
action
An action is the smallest unit in a workflow. The smallest unit of a workflow. It is a concept that combines several steps to create a job.
Reference
What is Continuous Integration? - YouTube
CI/CD 5분 개념 정리 (현업에서 쓰는 개발 프로세스) - YouTube
BoostCourse AITech CI/CD 에 githubaction을 곁들인 by Socar AI Lead 변성윤
DevOps Engineering Course for Beginners - YouTube
DevOps CI/CD Explained in 100 Seconds - YouTube
[GitHub Actions로 개발 주기 자동화 | ep2-2. GitHub Actions 소개 | 애저듣보잡 - YouTube](https://www.youtube.com/watch?v=9OCy-KNetws) |
Leave a comment