|
| 1 | +# CI/CD |
| 2 | + |
| 3 | +## Software Development Life Cycle (SDLC) [Waterfall vs agile] |
| 4 | + |
| 5 | + - Analysis |
| 6 | + - Design |
| 7 | + - Implementation |
| 8 | + - Quality Assurance |
| 9 | + - Deployment |
| 10 | + - Support & Maintenance |
| 11 | + |
| 12 | +## CI/CD |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + - Plan - doc / issue |
| 17 | + - [git] Code |
| 18 | + - [ci] * Build |
| 19 | + - [ci] * Test |
| 20 | + - [ci] * Release [github release] |
| 21 | + - [cd] Deploy [IaC / apps store] |
| 22 | + - [cd] Operate [controller / gitops / chatops] |
| 23 | + - [cd] Monitor [health check] |
| 24 | + |
| 25 | +## Continuous integration |
| 26 | + |
| 27 | + - version control |
| 28 | + - commit message [check] |
| 29 | + - build |
| 30 | + - automated testing |
| 31 | + - lint |
| 32 | + - unittest |
| 33 | + - integration test |
| 34 | + - end-to-end test |
| 35 | + |
| 36 | +## Continuous delivery / deployment |
| 37 | + |
| 38 | + - Deploy |
| 39 | + - Infrastructure as Code (IaC) / gitops |
| 40 | + - ansible (netdb) https://gitlab.com/19gale.ai/netdb-playbook |
| 41 | + - Operate |
| 42 | + - k8s controller / operator |
| 43 | + - chatops |
| 44 | + - OTA |
| 45 | + - A/B Testing |
| 46 | + - Monitor |
| 47 | + - dashboard / health check |
| 48 | + - gatus |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +## tools |
| 53 | + |
| 54 | +### version control |
| 55 | + |
| 56 | +- git |
| 57 | + |
| 58 | +- github pull request (PR) / gitlab merge request (MR) |
| 59 | + - merge commit |
| 60 | + - squash |
| 61 | + - relation with issue tracker |
| 62 | +- gitflow https://nvie.com/posts/a-successful-git-branching-model/ |
| 63 | + - develop / feature / main / release / hotfixes |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +### CI tools |
| 68 | + |
| 69 | +- git trigger (webhook) |
| 70 | +- worker |
| 71 | + - pipeline |
| 72 | + |
| 73 | +#### ci tools type |
| 74 | +##### job base (jenkins) |
| 75 | +- agent (java based) / worker setup |
| 76 | +- Groovy script |
| 77 | +- https://www.jenkins.io/doc/pipeline/examples/ |
| 78 | +- plugins |
| 79 | + |
| 80 | +##### code pipeline base (gitlab ci/circle ci) |
| 81 | +- .gitlab-ci.yml |
| 82 | +- rules - Use the rules keyword to specify when to run or skip jobs. |
| 83 | +- cache / artifacts - Keep information across jobs and stages persistent in a pipeline with cache and artifacts. These keywords are ways to store dependencies and job output, even when using ephemeral runners for each job. |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +``` |
| 88 | +build-job: |
| 89 | + stage: build |
| 90 | + script: |
| 91 | + - echo "Hello, $GITLAB_USER_LOGIN!" |
| 92 | +
|
| 93 | +test-job1: |
| 94 | + stage: test |
| 95 | + script: |
| 96 | + - echo "This job tests something" |
| 97 | +
|
| 98 | +test-job2: |
| 99 | + stage: test |
| 100 | + script: |
| 101 | + - echo "This job tests something, but takes more time than test-job1." |
| 102 | + - echo "After the echo commands complete, it runs the sleep command for 20 seconds" |
| 103 | + - echo "which simulates a test that runs 20 seconds longer than test-job1" |
| 104 | + - sleep 20 |
| 105 | +
|
| 106 | +deploy-prod: |
| 107 | + stage: deploy |
| 108 | + script: |
| 109 | + - echo "This job deploys something from the $CI_COMMIT_BRANCH branch." |
| 110 | + environment: production |
| 111 | +``` |
| 112 | + |
| 113 | +##### ci market (github action) |
| 114 | + |
| 115 | +- .github/workflows/xx.yml |
| 116 | + |
| 117 | +``` |
| 118 | +name: GitHub Actions Demo |
| 119 | +run-name: ${{ github.actor }} is testing out GitHub Actions π |
| 120 | +on: [push] |
| 121 | +jobs: |
| 122 | + Explore-GitHub-Actions: |
| 123 | + runs-on: ubuntu-latest |
| 124 | + steps: |
| 125 | + - run: echo "π The job was automatically triggered by a ${{ github.event_name }} event." |
| 126 | + - run: echo "π§ This job is now running on a ${{ runner.os }} server hosted by GitHub!" |
| 127 | + - run: echo "π The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." |
| 128 | + - name: Check out repository code |
| 129 | + uses: actions/checkout@v4 |
| 130 | + - run: echo "π‘ The ${{ github.repository }} repository has been cloned to the runner." |
| 131 | + - run: echo "π₯οΈ The workflow is now ready to test your code on the runner." |
| 132 | + - name: List files in the repository |
| 133 | + run: | |
| 134 | + ls ${{ github.workspace }} |
| 135 | + - run: echo "π This job's status is ${{ job.status }}." |
| 136 | +``` |
| 137 | + |
| 138 | +- local github action - act https://github.com/nektos/act |
| 139 | + |
| 140 | +### k8s and gitops |
| 141 | + |
| 142 | + |
| 143 | +- tilt https://docs.tilt.dev/controlloop |
| 144 | +- prod |
| 145 | + - argocd |
| 146 | + - fluxcd |
| 147 | + |
| 148 | + |
0 commit comments