CI/CD
What is CI/CD?
- Continous Integration and Continouse Delivery
- an automated workflow that simplifies testing and deployment
- when a feature is pushed, it triggeres automated testing, then if everything is ok, changes are merged to release branch, and when conditions satisfies, automatically pushed to production
GitHub CI/CD workflow:
- Commit (code)
- Test (application)
- Build (artifact/container image)
- Push (to repository)
- Deploy (Production pulls the artifact from repository)
Workflow templates provided by GitHub
Why is DevOps important?
What is version control?
- a way to stored different versions of the code base, so we can go to any specific version any time we want
- we can also track the historical changes, reverse changes, etc.
What is Git
- open source version control tool
What is git branch?
- a complete and independent code base that can be modified on its own. has it's own commit histories, can be merged with other branches when necessary
What is trunk-based development?
- a single branch for all developers
What is Gitflow?
- a typical workflow with feature branches, release branches, etc
What is CI?
- a software development workflow that developers continuous merges their code changes to a central branch and the central branch triggeres tests. The CI process checks for bugs and compatibility issues by running tests.
Continous Integration, Continous Delivery, Continous Deployment?
- CI: run builds and tests
- CDelivery: an extension of CI, produces deployable binary, package, or container (build image artifact and upload to repository)
- CDeployment: deploys to production
Genefit of CI/CD?
- Automations
- Test driven
- Better version control
- Fast
- Ease of use
Hosted CI and clou CI?
- Wether to maintain the build/test/deployment steps our selves
Security?
- API Keys
- application secrets, database passwords, sometimes server public keys
Some deployment strategies?
- Regular deployment: updates all containers to latest version at once
- Canary Release: update a small portion to latest version (maybe 1%) and monitor for errors
- Blue-green Release: keep two version running at the same time, reroute users to latest version, and if anything happens, reroute them back
- Dark Launches: new features are released without being announced
How does testing fit into CI?
- after merge, run automated tests
Should testing always be automated?
- Yes, as much as possible
- but manual testing are still necessary in certain situations where automation is not possible
Types of tests?
- Unit Tests
- Integration Tests
- End to end tests: simulating user interaction
- Static Tests: examine source code
- Security Tests: scane dependencies for known security issues
- Smoke Tests: fast test and check if application can start and that the infrastructure is ready to accept deployments
What is Test-Driven Development?
- Write tests first
- after feature development, run tests to make sure feature is working properly
What is Behavior-Driven Development?
- designing the thing right
Test Coverage?
- how much of the codebase is covered by tests
How to optimize tests in CI?
- breaking large tests into smaller units
- remove obsolete tests