How to design a modern CI/CD Pipeline

Поделиться
HTML-код
  • Опубликовано: 17 дек 2024

Комментарии • 110

  • @DevOpsJourney
    @DevOpsJourney  Год назад +13

    View the diagram here: app.eraser.io/workspace/UHFVA30wF6pdEb2sgrWa

    • @hugoalbertobedolla7129
      @hugoalbertobedolla7129 6 месяцев назад

      I can't understand... why you have to build the image before testing? is it not supposed to work opposite: testing your code first, building the image after testing? that's because building the image spends time which, if the code under test fails, becomes a waste, so you end with a tagged image which is unusable.
      Let's distinguish: testing the code isn't equals to test the image: testing the code is simply the fact of proving the code works the way we expect it works, and, for this, the unit test must be implemented in such way that has no dependencies over external resources (i.e. databases, queues, etc) but is only a logical testing which supplies mock entities for isolating the code; testing the image is testing the application within the environment it is expected to work into, so is different to unit test the code, than testing the container from an integration point of view, because, when you test the container, you have to supply environment variables which fill the required definitions for making it work into a desired environment, but it has nothing to do with the code, because, at that point in time, the code must be proven to work.
      That's my point of view so I would love any feedback on this subject.

  • @jawadturk
    @jawadturk 10 месяцев назад +17

    Here's where I think you can design the pipeline in a better way. I think running your tests prior to your build is better. If you build and your tests fails then you wont be able detect it prior to the build. This will increase your change lead time to get committed code to production

    • @AromalKrishnan-oe7ub
      @AromalKrishnan-oe7ub 2 месяца назад +5

      so true . once the liniting process is complete . the unit test shoud start

    • @KrsteToshev
      @KrsteToshev Месяц назад +7

      Although testing the code before building a container would be quicker both in testing the code and in debugging, containerizing the build would make sure your application is running on the correct OS and environment as the deployment server. Both methods have their advantages and disadvantages

  • @sunjnj
    @sunjnj 2 месяца назад +3

    This is a great lecture. I would be honoured to see a hands-on course based on this.

  • @tasanee87
    @tasanee87 Год назад +5

    I found this very helpful, great breakdown of how it works! Awesome visual and looking forward to watching the follow up video.

  • @PrudhviParuchuri
    @PrudhviParuchuri Год назад +2

    well this is how you lay things down. amazing explanation there!

  • @msr_atpeace
    @msr_atpeace Месяц назад

    Really Helpful. Kudos to your work. Simple short and to the points video.

  • @maxp918
    @maxp918 Год назад +15

    I'm a simple front-end dev looking to expand my understanding of the whole software process and I understood everything.
    Which says a lot about your ability to explain things simply and in layman terms.

  • @Sandaruwan-UZI_m2i
    @Sandaruwan-UZI_m2i Месяц назад

    This was what every beginner needs

  • @saeid5914
    @saeid5914 4 месяца назад

    it was awesome man, gave a big picture and helped me to understand the whole pipeline all together

  • @UltraGameCoder
    @UltraGameCoder 4 месяца назад

    Really good visual! Thanks! I will try bringing this up in one of my meetings

  • @biswajit-k
    @biswajit-k 5 месяцев назад

    Thanks a lot. You have greatly simplified, and this is easier to understand. The diagram also helps 👏

  • @hansu7474
    @hansu7474 2 месяца назад +1

    Thanks for the useful video.
    I just have one question here: 3:55
    If you compile the code within the image, doesn't that make your container to be wasting resources? I mean, you need to put all libraries and tools used only for compilation, not for run-time.

    • @DevOpsJourney
      @DevOpsJourney  2 месяца назад

      Great point. You can add a line to remove them at the end of the dockerfile. You can do this via a multistage dockerfile as well which is one of its main use cases. Hope this helps!

  • @NGolda
    @NGolda Год назад +1

    Well done video, looking forward to the followup video.

  • @ahmadkabalo7738
    @ahmadkabalo7738 Год назад +7

    There is somthing I still don't understand, why you put building the container image step before running units test ??
    Shoulde we first test the code and make sure it is working and then if every thing is ok we ship the code and build the docker image ??

    • @bharathrajuk
      @bharathrajuk Год назад

      exactly, and container registry is where we have the container images with tags, right?

    • @Starkypooo
      @Starkypooo Год назад +1

      sometimes you must first compile the UTs (like in C++), however, I don't see why we should keep compiled UTs in the image

    • @keitaatticot612
      @keitaatticot612 Год назад

      I have the same question UTs and coverage after the build . I don’t understand

    • @DevOpsJourney
      @DevOpsJourney  Год назад +1

      It's a preference. You can UT before or after building the image. My preference is to make use of multistage dockerfiles and run my CI tests within the image. When dockerfiles are built correctly it doesn't take long to build an image, and it's something you can bring to any CI environment.
      Here's a good post about it www.reddit.com/r/docker/s/2o8TBzsBtK

    • @dipk.mishra
      @dipk.mishra Год назад

      @@DevOpsJourney, instead of multistage dockerfile can’t we just run unit test first after building the code. Copy the artifacts into Dockerfile and just build docker image?

  • @shaju33
    @shaju33 5 месяцев назад

    wooww..simply explained in a way anybody can understandable . you are a great teacher . Requesting a video of creating declarative yaml pipeline scripts . THANKYOU

  • @bartg8993
    @bartg8993 Месяц назад +1

    Amazing!, and I would like to see practical examples too

  • @AdityaParmar-dr7gu
    @AdityaParmar-dr7gu 2 дня назад

    Greate video men thanks a lot 👍👍👍

  • @mymd2004
    @mymd2004 11 месяцев назад

    you da man buddie...hi from Argentina

  • @severtone263
    @severtone263 Год назад

    Well laid out! It was logical and easy to understand

  • @simon_smale
    @simon_smale Год назад +2

    Isnt branch protection is usually at the SCM level rather than as part of the pipeline? At this point it is too late, the code would be in the branch

    • @TayWm
      @TayWm Месяц назад

      that is what the pull request is for

  • @Dobby_zuul
    @Dobby_zuul 27 дней назад +1

    Run your unit tests before building images / starting container.

  • @seanm9306
    @seanm9306 4 месяца назад

    Very insightful video!

  • @dipk.mishra
    @dipk.mishra Год назад

    Nice video! I did not understand though that after we get container image how do we ensure unit test is running against that image? Is there sone deploy step to Dev env where those unit tests would run?

  • @Aleks-fp1kq
    @Aleks-fp1kq Год назад +2

    Nice video, I have a few questions:
    1. what if there are errors in any stage/sub stage
    2. isn't there a difference between deployment and release
    3. is pre-commit code a bit too intrusive? I would run checks only after pull request is approved.
    4. in general, what kind of dev process does CI/CD pipeline follow? Scum or?? Because making the pipeline is writing code but somehow I don't see it fitting well with Scrum.
    5. do we unit test the pipeline itself?

    • @DevOpsJourney
      @DevOpsJourney  Год назад +3

      1. You should set the build to fail. You should also build in some notifications to notify your developers. Slack/Email are most commonly used.
      2. Release stage is making your container image/software available on a registry. Deployment stages are after the release stage, and actually get the software to run on your servers
      3. Some people don't like it, but it's made to save your Devs time. It follows the "fail fast" moto of pipelines. If there are linting/formatting errors, we want that to fail as soon as possible, not during a PR check or during a pipeline run (which comes later).
      4. Depends on the company, it doesn't really matter. It's usually something you build and always improve on.
      5. Some do, but many don't. I usually just run the pipeline after any changes and make sure it still passes. I would probably do something more if people keep breaking the pipeline with changes they make to it.

    • @p.a8750
      @p.a8750 Год назад +1

      @Aleks-fp1kq I would 100% include precommit. It is the first gate for the code to go through. It will eliminate countless PR request updates that say 'fixed linting / formatting'. Also, if you include a precommit hook that checks for secrets like gitleaks or yelp, you are preventing any sensitive information ever being committed in the first place.

    • @simon_smale
      @simon_smale Год назад

      Pre commit is really useful to prevent the red mark of shame. I try to put them in every project I dev on so that you fail as early as possible.

  • @botyironcastle
    @botyironcastle 5 месяцев назад +3

    why not unit test in the source stage ?

    • @maxiphobos
      @maxiphobos Месяц назад

      Agree. What is the reason to spend build time before, which is paid, to understand that unit tests have failed? 😅 I suggest author to try to understand how it works before providing any thoughts.

    • @chudchadanstud
      @chudchadanstud 25 дней назад

      can't run UTs without building code

  • @MikeZadik
    @MikeZadik 11 месяцев назад +4

    This feels very specific to a development tech stack, without actually specifying it. (Unittests in container, upload to aws)

  • @midnaite
    @midnaite Год назад

    Great job man, thank you so much :)

  • @dorinm4653
    @dorinm4653 4 месяца назад

    I would shift Unit Tests and coverage check to branch protection step

  • @Daniel_Mahlangu
    @Daniel_Mahlangu 9 месяцев назад

    Does the compile stage include a website code. I dont understand why and how one would complie css and html and JS scripts

    • @DevOpsJourney
      @DevOpsJourney  9 месяцев назад

      Since they do not require compiling, you would copy those files into the docker image you are building in the build stage

  • @florimmaxhuni4718
    @florimmaxhuni4718 Год назад +2

    Should Unit test be before Container image ?

    • @florimmaxhuni4718
      @florimmaxhuni4718 Год назад

      I guess it depend how you run unit test in container or not but if we run in container that may take more time then just running unit-test directly when you build and also you dont need to download container image if unit test fails

    • @T.P.87
      @T.P.87 Год назад

      @@florimmaxhuni4718 Depends on in which format you ship the application and how you test. The norm would currently be to ship release images which include the runtime and the compiled/transpiled binary for execution and not much else. For isolation/parallelization purposes on the build server it also makes sense to run every step of CI pipeline in predefined containers. The 'CI pipeline' image definition would be part of the project repository and could include everything you need for testing, debugging, development (can be used locally by devs). The 'release' image which you want to push into the registry and which is then used as the startable application in production could be way leaner, because no testing framework is needed.

    • @florimmaxhuni4718
      @florimmaxhuni4718 Год назад

      We still ship release images that include compiled/transpiled binary but when build is succussed and all the test pass otherwise if test fails thats not a releasable I assume for dev or other environments thats why I think it may take a lot of time specially when creating PR-s. (I guess you have methods that help to use cache but still).
      By the way Im talking about some languages that I work and github actions has great support for them (one command to build or run test/integration--test)@@T.P.87

  • @hjoseph777
    @hjoseph777 2 месяца назад

    which tool are using to build your CI/CD pipeline jenkings for vscode , Gitlab, azure devops ?

    • @DevOpsJourney
      @DevOpsJourney  2 месяца назад +1

      @@hjoseph777 usually Jenkins or GitHub actions. They all could be used to get similar results

  • @phuongnamnguyen5226
    @phuongnamnguyen5226 4 месяца назад

    Can you please design a CI/CD pipeline for Embedded System like programming a Microcontroller (STM32, EFR32, etc). It's depended on the hardware, so I don't have any idea how to have a CI/CD on the source code.
    Thanks for the great video!!!

  • @SORINACHIRILA
    @SORINACHIRILA Год назад

    Thank You, this is a great explanation.

  • @FRIGTARD123
    @FRIGTARD123 6 месяцев назад

    Wouldn't the pre commit checks that enforce 'linting' - aka syntax errors in your context- be unnecessary if the code compiles and builds successfully on their local machine? I understand the need to lint prs after they've been pushed to make sure they compile in the pipeline environment but not the pre commit linting check

    • @avatar098
      @avatar098 6 месяцев назад

      Linting is more for quality of life during code reviews. Sometimes there are unnecessary formatting stuff that pollutes the PR.
      Sometimes (and you’d be surprised) devs will push without actually building their code locally. It’s annoying.

  • @Nodgelol1
    @Nodgelol1 27 дней назад

    thanks for clarification! I thought it is like "test, build, deploy" instead of "build, test, deploy". 🤐

  • @saisandep
    @saisandep Месяц назад

    I prefer doing unit tests before creating container image and even before build. why would I use space and start a container if the unit tests fail.

    • @DevOpsJourney
      @DevOpsJourney  Месяц назад

      @@saisandep yes that works but I did explain my reasoning on why I sometimes prefer to build the container first

  • @carisseandjeff
    @carisseandjeff Год назад

    nice vid. looking forward in gitops part. I'm new to Argo and hoping it will give more clarity and different approach. example using mono repo vs multi repo, git vs helm sync and etc

  • @bharathrajuk
    @bharathrajuk Год назад

    container registry is where we have the container images with tags, right?

    • @Starkypooo
      @Starkypooo Год назад

      yes, this is the place to which you push or from which you pull container images

  • @vadymesch2267
    @vadymesch2267 10 месяцев назад +1

    Unit test after creating Container Image? Are you sure about it? Maybe you mean e2e tests?

    • @DevOpsJourney
      @DevOpsJourney  10 месяцев назад

      It's a preference. You can UT before or after building the image. My preference is to make use of multistage dockerfiles and run my CI tests within the image. When dockerfiles are built correctly it doesn't take long to build an image, and it's something you can bring to any CI environment.
      Here's a good post about it www.reddit.com/r/docker/s/2o8TBzsBtK

  • @Inaya334
    @Inaya334 8 месяцев назад

    Great video can you do another one for DevSecOps. Thank you so much

  • @kalvakolusubhash4010
    @kalvakolusubhash4010 Год назад

    Nice explanation 😊

  • @ColdStoneBoy
    @ColdStoneBoy Год назад

    Great video!

  • @praketasaxena
    @praketasaxena 5 месяцев назад

    how would you change this for a python code . because you would not be building any artifacts ! the unit test can still remain

  • @Zmey5656
    @Zmey5656 6 месяцев назад

    Your video is very useful for me. I will subscribe to your channel. Thank you

  • @kalvakolusubhash4010
    @kalvakolusubhash4010 Год назад

    By the way tell about the app/website you are using for this video 😊

    • @DevOpsJourney
      @DevOpsJourney  Год назад

      eraser.io. I got a link to the diagram in the description

  • @andyb012345
    @andyb012345 4 месяца назад

    Your container image contains the tools, sdks and libraries to test and get code coverage? That sounds like a lot of bloat.
    Edit: Then you do integration tests outside of the container? This makes no sense, how do you get an aggregated code coverage, do you copy the coverage report files from the container image back to the CI system to aggregate the unit + integration test coverage? Do you only code coverage your unit tests?

  • @oLunatiko
    @oLunatiko 6 месяцев назад +1

    There are good unit test and bad unit tests. But if you choose to not add testing to your application, you’re waiting for a disaster to happen and you will find out once everything goes haywire.

  • @solarsiztem
    @solarsiztem 4 месяца назад

    perfect!

  • @MagDag_
    @MagDag_ 9 месяцев назад

    Great!

  • @rafael.aloizio1769
    @rafael.aloizio1769 2 месяца назад

    Why would you want to build it before running tests? It sound an ineficient way of doing it

  • @genshen4703
    @genshen4703 6 месяцев назад

    cool. simple. fast.

  • @AngelCruijff
    @AngelCruijff Месяц назад

    I just want to point out that if it's an actual microservice, it shouldn't have dependencies on other microservices. Just saying

  • @rofgar
    @rofgar Месяц назад

    What is the point of building a container image, if the unit tests fail? Seems like a waste of time.
    Compile Code -> Run Unit Tests -> Build Container Image and keep it smaller by not including Unit test reports, Code coverage reports and Test Classes

  • @HaydonRyan
    @HaydonRyan Месяц назад

    Never forget security…..

  • @Gurttastic
    @Gurttastic Месяц назад

    Pre-commits are not a good way to strongarm devs into practices that is not really doing anything other than an nuisance, sometimes you wanna branch incomplete branches and this prevents that method. It causes more harm than good, you should rather instead implement these linting tests before compiling/building.

    • @DevOpsJourney
      @DevOpsJourney  Месяц назад

      @@Gurttastic disagree. Precommit follows the fail fast methodology. Your developer's will be a lot happier that they get instant feedback on problems with their code rather than having to wait until a build failure

    • @mohammadahmedalikhan5130
      @mohammadahmedalikhan5130 Месяц назад

      True​@@DevOpsJourney

  • @ZTGallagher
    @ZTGallagher Год назад +55

    Not my circus, not my clowns, but my two cents is that unit tests need to be heavily de-prioritized. They make code more difficult to refactor, and they lead to people writing super bad tests just to get coverage. They waste a lot of time testing things that might not even really need it. Unit tests can be good but should be reserved for cases where a function/method has a very complex purpose and you want to verify it's doing as it should.

    • @Aleks-fp1kq
      @Aleks-fp1kq Год назад +25

      This is because the test you have seen\used are written badly.

    • @ZTGallagher
      @ZTGallagher Год назад +5

      ​@@Aleks-fp1kq If you don't think too many unit tests is a net negative you've either not refactored often enough, or not worked in an environment where sloc and code coverage were used as performance metrics. Prioritizing unit tests where they're unnecessary complicates development and adds pointless busy work.

    • @Aleks-fp1kq
      @Aleks-fp1kq Год назад +12

      @@ZTGallagher why would anyone write "too many unit test"? you mean multiple tests that test the same thing? How coverage be a performance metric?

    • @ZTGallagher
      @ZTGallagher Год назад +6

      @@Aleks-fp1kq 100% code coverage is not just impossible, it's a hindrance. So many functions simply do not need unit tests. They're too small, straightforward, or simple. They don't need it. You can cover more of the system with good integration tests that get you the same reliability. But people will write unit tests arbitrarily, and often bad hacky ones, because it's less important to have good code or develop efficiently, and more important to say "yeah we have high code coverage". Prioritizing code coverage means prioritizing volume, not quality. A system is better with just well-written integration tests. Unit tests aren't bad. They're simply extremely over-valued.

    • @Aleks-fp1kq
      @Aleks-fp1kq Год назад +5

      @@ZTGallagher I agree, and as I said in my first reply, you have used/encountered bad tests/practices. there is no such things as prioritizing unit tests. you need unit tests if you are doing TDD (bottom-up\top-down). you write the unit tests to test your SUT, you don't write more than that. While doing that we follow patterns such as equivalence partitions, triangulation and principles ....

  • @DzintarsDev
    @DzintarsDev 11 месяцев назад

    The title word "modern” got me there, but left me disapointed.

  • @jeffrdrama7984
    @jeffrdrama7984 Месяц назад

    Ha, the whole right hand side of this is impossible for my company. Literally no fucking testing at all. I hate it

  • @guinea_horn
    @guinea_horn 6 месяцев назад

    I've never heard an accent like this which replaces I's with A's. Santax. Gathub.

  • @hoangfromvietnam
    @hoangfromvietnam 4 дня назад

    you need to explain it more clearly by giving an actual example/ implementation and not just pure theory.

    • @DevOpsJourney
      @DevOpsJourney  4 дня назад

      @@hoangfromvietnam I have multiple videos on this

  • @WA-hornet007
    @WA-hornet007 5 месяцев назад

    What's modern about it? This is how CICD in a generic sense works where you have checks n balances for your complete CI process then for he CD.

  • @sirtobey1337
    @sirtobey1337 4 месяца назад +2

    Pre-Commit hooks and mandatory test coverage are plain bad advice

  • @stxnw
    @stxnw Год назад

    Downvoted because Continuous Deployment is part of CI/CD, yet you still separated them into 2 videos for the money.