Continuous Integration (CI)
by Tomas Trescak· CI/CD and DevOps

0 / 730 XP

Presentation Transcript
If you prefer text to video, check out the transcript of the presentation above

Slide 1 ----------- Part 1: Let's discuss how you can make your development cycle safer and more transparent towards your testing team. CI/CD is where the magic happens! Slide 2 ----------- Part 1: Picture this: In our cool blogging app, your colleague adds a “sort by date” feature—awesome, right? But then the app crashes because no one tested it properly. CI/CD is like a superhero that catches these mistakes before they ruin everything! Slide 3 ----------- Part 1: Remember Crowdstrike mess in 2024, when a software error made airports and even hospitals shut down? A good executed CI/CD would prevent this mess. Slide 4 ----------- Part 1: CI/CD stands for Continuous Integration and Continuous Deployment. It’s all about automating the boring stuff—testing and launching your app—so you can focus on creating cool features. Big apps like TikTok or Medium use it to stay bug-free, and you can too! Part 2: Ever shared a project with a friend, and it didn’t work on their computer? CI/CD ensures your code works everywhere, every time—no more excuses! Part 3: Some think, “I can test it myself—it’s faster!” But manual testing gets messy as your app grows. Another myth: “CI/CD is too hard for beginners.” Nope—it’s easier than you think, and we’ll prove it today! Slide 5 ----------- Part 1: Continuous Integration, or CI, is like a team huddle. Everyone brings their code—like a new filter for blog posts—and CI checks it works with the main app. It runs tests automatically to spot problems fast. Part 2: Continuous Deployment, or CD, takes your tested code and puts it live—like publishing your blog app for the world to see—without you lifting a finger. Continuous Delivery is similar but waits for your “go.” Both save time! Part 3: Why does it matter? You get feedback quickly! Did it break? Is it working as expected? Fewer bugs sneak in, and teamwork feels smooth. No more “it works on my machine” headaches! Also, it builds confidence! In our blog app, users see posts and filter by tags; admins add posts. CI/CD tests the filters and deploys new code seamlessly. Part 4: CI/CD also strengthens security in your app and implements crucial principles. We can picture it like a guard tower protecting our app. Part 5: Secure design principle builds security into our app from day one—like ensuring our admin login page isn’t easily hackable. You ensure that security-related tests are in your code base. If we skip this, the whole tower falls! Part 6: Next, we protect the app data. This means keeping secrets safe—like not exposing our admin password in the code. For our app, we’d hide API keys in environment variables so hackers can’t steal user data. Part 7: Then we have Operational Continuity. This ensures our CI/CD pipeline runs smoothly—like deploying new blog posts without downtime. If our pipeline breaks, users can’t see the latest content! Part 8: At the top is Trust Maintenance. It’s about keeping our pipeline trustworthy—like ensuring no one sneaks bad code into our app. For us, this means only trusted team members can approve deployments. Part 9: This hierarchy keeps our blog app safe at every step. Secure Design protects the admin panel, Data Protection hides user info, Operational Continuity keeps posts live, and Trust Maintenance ensures our CI/CD pipeline isn’t tampered with. Security is a team effort! Slide 6 ----------- Part 1: Here’s the CI/CD Infinity Loop—that shows the full lifecycle of your app. Part 2: The right loop is where the action starts. It’s a clockwise cycle: Plan is brainstorming—like deciding to add a ‘filter by tag’ feature. Code is writing it in TypeScript. Build is compiling it into something runnable, like bundling our Next.js app. Test is running automated checks—does the filter work? If not, we will fix it here before crossing over. Part 3: The left loop picks up after tests pass. It’s also clockwise: Release packages the app—like zipping it into a deployable file. Deploy sends it live to a server for users. Operate is the app running—users filtering posts. Monitor watches for crashes or slow performance, feeding info back to Plan via a dotted line, closing the loop! Part 4: For our app, we plan a tag filter, code it, build the NextJS app, and test it (CI). Once it’s solid, we release a package, deploy it to Vercel, operate the live site, and monitor user feedback (CD). The crossover ensures only good code goes live! Slide 7 ----------- Part 1: Let’s use GitHub Actions to set up Continuous Integration for our Next.js blogging app. It’s a robot that runs our tests and builds every time we push code—keeping our app reliable. We’ll break down each part of this workflow file! Part 2: The workflow file is a YAML file that must be stored in the dot github/workflows directory. In our case, we named it ci yml. YAML is a more concise version of XML. Part 3: We name this workflow CI Pipeline. You can have several pipelines in the same codebase and choosing a good name is beneficial. Our name ... sucks. Part 4: Then we need to define triggers, which specify when do we want to run our pipeline. You can run simple pipelines on every push, but deployment pipelines only when code is pushed to the main brach. In this case, push runs this when we update the main branch—like adding a new feature. The "pull_request" also runs it when we propose changes—keeping teamwork safe! Part 5: Then, we can define several jobs; in our case, we define a new job we named build-and-test. Think of jobs as chapters in the robot’s to-do list—one job can have many steps! Part 6: Next, we need to provide the container in which this pipeline runs. If you are not aware of containers, they are like virtual machines that you can run on your computer, with different operation systems. In this case, we chose the Linux system, Ubuntu, from the container ubuntu-latest—it becomes the computer the robot uses, a Linux machine provided by GitHub, fresh and fast! Part 7: Steps provide the step-by-step instructions. Each step is a mini-task—like fetching code or running tests—that builds up to a solid app! Part 8: The "uses" property provides the name of the action you wish to execute. In our case, actions/checkout step uses a pre-made action to fetch our blog app’s code from GitHub. It’s like downloading the latest version so the robot can start working! Part 9: You can also name your action, in this case we named it Setup NodeJS. We use actions/setup=node action to set up Node.js , which Next.js needs to run. The ‘with’ part customises it—think of it as telling the robot, “Use this tool kit!”. In our case, we tell the robot to use NodeJS version 18! Part 10: Next, we install our favourite package manager PNPM, and we specify to use version 10 4 1. Part 11: We can also run command in the target operating system, provided in the run parameter. This command installs all libraries that our blog app depends on. You do it locally, we need to do it in the container! Part 12: Then, we run another command to execute our tests. Part 13: If all steps are executed well, we will build our project. There could be some build or compilation errors. It's always good to build the app to ensure the CD pipeline does not crash! Pretty impressive, huh? It's like providing a robot with a recipe of things you would like to create! Slide 8 ----------- Part 1: Imagine our blog app is live. Users love filtering posts by “travel” or “tech,” and admins add posts daily. But one day, an admin adds a buggy “delete post” feature—yikes! Part 2: Manually testing means the bug slips through. Users click “delete,” and all posts vanish. Panic ensues, and we scramble to fix it after complaints roll in. Part 3: GitHub Actions catches the bug in testing. The pipeline fails, alerting us before deployment. We fix it, re-run the pipeline, and deploy a safe update. Users never notice a thing! Part 4: CI/CD saves time, stress, and our app’s reputation. Automation beats chaos every time! Slide 9 ----------- Part 1: Let’s get you coding! You’re going to clone a real repo, make a change, and see GitHub Actions in action—catching bugs like a pro! Part 2: Fork and grab this pre-made Next.js app repo from GitHub. Part 3: Try something simple—like changing the blog title in pages/index.tsx from “My Awesome Blog” to “My Broken Blog.” Or add a bug, like deleting a semicolon, to break the test! Part 4: Commit your change and push it to your forked repo with git push. This triggers the CI pipeline we set up! Part 5: Head to the “Actions” tab in your GitHub repo. You’ll see the CI Pipeline running—testing and building. If you added a bug, it’ll fail and tell you why. Fix it, push again, and see it pass. Instant feedback! Slide 10 ----------- Part 1: I’ve tinkered with GitHub Actions a ton. Pushing tiny changes to test them online can take forever—commit, push, wait, repeat. Good news: there’s a tool called ACT to run GitHub Actions locally, so you can experiment faster! Part 2: To run Github Actions locally you must install Docker Desktop—it’s like a mini virtual machine that runs the same environment GitHub Actions uses. Download it from docker.com and set it up! Part 3: Then, you need the ACT tool. Please use instructions on their website to install it on your computer. On mac its as simple as running brew install act. Part 4: Then we need to do one adjustment. In Docker Desktop, go to Settings General Virtual Machine Options. Switch the file-sharing implementation to gRPC FUSE. I had to do this to make ACT work smoothly—saves you the headache! Part 5: To run this, run act with j parameter build-and-test in your cloned repo folder or just run "act" to execute all pipelines. This simulates the “build-and-test” job from our CI pipeline locally. You’ll see it fetch code, install NodeJS, run tests—everything, right on your screen! Act tool allows you to tweak the pipeline—like adding linting—without spamming GitHub. It’s faster, and you’ll feel like a CI wizard! Slide 11 ----------- Part 1: You have many other options when it comes to creating CI pipelines. Let's explore a few! Part 2: Jenkins is a popular CI tool that’s been around forever. It’s an open-source platform you install on your own server. For our blog app, Jenkins can run tests and builds just like GitHub Actions, but you’d set up a ‘pipeline’ in a Jenkinsfile—similar to our ci yml. It’s super customisable, so you can add plugins for everything, like Slack notifications when a build fails! Part 3: CircleCI is cloud-based, like GitHub Actions. It’s great for speed—think of it as a racecar for testing our blog app’s tag filters. It uses a config yml file and has a cool dashboard to watch builds. Part 4: Travis CI is another cloud option, often used for open-source projects. It’s simple to set up with a travis yml file, perfect for beginners testing our admin post feature. Part 5: GitLab CI/CD is built into GitLab, a GitHub alternative. It uses a gitlab-ci yml file and can deploy our blog app to a server—great if you’re already using GitLab! Part 6: If we compare how easy is to use Github Actions with alternatives, GitHub Actions wins here—it’s built right into GitHub, so you don’t need a separate setup. Jenkins requires installing on a server, which can be tricky for beginners working on our blog app. Part 7: GitHub Actions takes the prize for cost as it is free for public repos and has a generous free tier for private ones—perfect for students. Jenkins is free but needs a server (which might cost money). CircleCI and Travis CI have free tiers but charge for more usage. Part 8: Jenkins is the king of customization—you can make it do anything with plugins. GitHub Actions is flexible too, with reusable ‘actions,’ but Jenkins has more options for complex setups, like integrating with older systems. Part 9: GitHub Actions has a huge community because it’s part of GitHub—tons of pre-made actions for our blog app. Jenkins has a big community too, but it’s older, so some resources feel dated. Slide 12 ----------- Part 1: CI/CD saves the day. It keeps our blog app safe by testing every change and deploying smoothly. CI checks the code; CD gets it live. Part 2: GitHub Actions rocks. Our robot helper automates testing and building—like a guardian for our app’s quality. Part 3: Automate early, test everything, and use GitHub to stay organised. It’s how pros ship great apps! Part 4: Don’t skip tests thinking “it’s fine”—one typo could crash your app later. Trust CI/CD instead!

Description
All the extra information about this section

MOTIVATION Imagine you're building a blogging app with friends. One teammate adds a slick “sort by date” feature—awesome! But suddenly, the whole app breaks. Why? Their code didn’t play nice with the rest. Enter CI/CD, your team’s superhero. CI/CD stands for Continuous Integration and Continuous Deployment (or Delivery). It automates the testing and deployment process, helping your team build confidently, fix issues early, and get updates out fast. Big platforms like TikTok, Medium, and Netflix rely on CI/CD pipelines to ship updates multiple times a day—while keeping things stable. It’s also about collaboration. Ever had a group project where your code worked perfectly—on your machine? CI/CD ensures it works everywhere. And yes, it’s beginner-friendly! You don’t need to be a DevOps wizard to get started—we’ll prove it today. -------------------------------------------------------------------------------- SECTION 1: WHAT IS CI/CD AND WHY IT MATTERS 🧩 WHY IT MATTERS When working as a team, manually combining everyone’s code and deploying it yourself becomes a bottleneck fast. CI/CD automates this pain away. Instead of saying “It broke after your commit!” we can say “CI caught the bug—let’s fix it before it goes live.” Let’s break CI/CD down: * Continuous Integration (CI) means developers regularly merge code into the shared repo. Each merge triggers automated tests that check if everything still works. * Continuous Delivery (CD) ensures that once code is tested, it’s always in a deployable state—though a human may still trigger the release. * Continuous Deployment (also CD) takes it one step further: after passing tests, changes are automatically deployed to production—no human input needed. -------------------------------------------------------------------------------- 🔁 THE CI/CD INFINITY LOOP [https://skillpies.s3.ap-southeast-2.amazonaws.com/courses/full-stack-development-comp3036-2025/sections/foundations-of-ci-cd-in-ci-cd-and-devops/2585.blog.png] This diagram shows CI/CD as an infinity loop, reflecting the continuous nature of modern software delivery. 🔷 CONTINUOUS INTEGRATION 1. Plan – Teams define tasks, bugs, and features through user stories or tickets. 2. Code – Developers build features or fix bugs in isolated branches. 3. Build – Code is compiled or bundled. For React, that’s tools like Webpack or Vite; for JavaScript backends, it might involve Babel or packaging Docker containers. 4. Test – Automated unit and integration tests run to catch issues. Tools like Jest, Vitest, ESLint, and Prettier enforce quality. > 💬 Ask your class: “Who’s had something work on their machine but crash on a > friend’s?” > Expect chuckles. > That’s why automated CI testing exists—to avoid that embarrassment. 🔷 CONTINUOUS DELIVERY & DEPLOYMENT 1. Release – After passing tests, code is bundled and made ready for deployment. 2. Deploy – The release is pushed to staging or production, often via tools like GitHub Actions, Jenkins, or Vercel. 3. Operate – The system is live. DevOps teams monitor uptime and health. 4. Monitor – Logs and analytics help teams understand usage and catch issues fast. -------------------------------------------------------------------------------- REAL-WORLD CI/CD WINS & WOES ✅ SUCCESS STORY: SHOPIFY Shopify deploys thousands of times a day using CI/CD. Every change—from a minor UI tweak to a new checkout flow—goes through automated testing, canary releases (to a small group first), and production rollout with confidence. This velocity is only possible with solid CI/CD. ❌ FAILURE EXAMPLE: KNIGHT CAPITAL GROUP In 2012, Knight Capital deployed code to production without fully testing it through a CI/CD pipeline. A missing config flag caused a trading algorithm to malfunction, losing $440 million in 30 minutes. A proper CI/CD pipeline could have caught this in staging. -------------------------------------------------------------------------------- CI/CD IN FULL-STACK PROJECTS Let’s map this to our blogging app built with React (frontend), Node.js (admin backend), and Next.js (full-stack framework): * CI tests your React UI (e.g., does “filter by tag” work?). * Linting ensures your Node.js code is consistent and error-free. * CD deploys your Next.js site (w.g. Vercel) so users always get the latest posts. Even in small apps, this automation is a lifesaver. -------------------------------------------------------------------------------- SECTION 2: SETTING UP CI WITH GITHUB ACTIONS 🔍 OVERVIEW GitHub Actions is a built-in CI/CD tool. It acts like a mini robot inside GitHub that runs every time you push code—checking for errors, running tests, and more. Key structure: * Workflow File: .github/workflows/ci.yml * Trigger: On push or pull request to main * Steps: Lint, test, build—automated! 🔧 CI/CD KEY CONCEPTS (WITH GITHUB ACTIONS) * Pipelines: The ordered steps—like “lint → test → build → deploy.” * Workflows: The YAML files that define what the pipeline should do. * Triggers: What sets it off—usually a git push or pull request. * Jobs: Groupings of steps like “run all tests.” * Steps: Individual actions like installing dependencies. * Actions: Reusable components built by others (or you!). Automation tools we’ll use: GitHub Actions (today), and later Vercel, CircleCI, and Jenkins. ✨ HANDS-ON EXAMPLE Here’s a minimal pipeline to test our blog’s homepage: Test File (pages/index.test.tsx): import { render, screen } from '@testing-library/react'; import Home from './index'; test('displays blog title', () => { render(<Home />); expect(screen.getByText('My Awesome Blog')).toBeInTheDocument(); }); GitHub Actions YAML (.github/workflows/ci.yml): name: CI Pipeline on: push: branches: [main] pull_request: branches: [main] jobs: build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '18' - name: Install Dependencies run: npm install - name: Run Linting run: npm run lint - name: Run Tests run: npm test - name: Build Project run: npm run build 🧪 TRY IT 1. Clone the repo: https://github.com/WesternSydneyUniversity/comp3036-ci-cd-introduction 2. Add a small change (or a bug). 3. Push it. 4. Watch GitHub Actions catch it immediately! 🧪  TRY IT LOCALLY I (Tomas) have been working with Github actions a lot and found that doing small changes to Github Actions can be really tedious, going through many commits to get it right. Luckily, there is a tool that you can use to run Github Actions locally. You need the following: 1. Local installation of Docker Desktop [https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.docker.com/products/docker-desktop/&ved=2ahUKEwims6H7jceMAxW5yDgGHfMPJFoQFnoECBMQAQ&usg=AOvVaw1d0h_mLhkWV0ppkwLqcV3A] 2. The ACT [https://nektosact.com] tool 3. ⚠️ In the config of Docker desktop “Settings > General > Virtual Machine Options” I had to chang tho gRPC fuse as file sharing implementation:   [https://skillpies.s3.ap-southeast-2.amazonaws.com/courses/full-stack-development-comp3036-2025/sections/foundations-of-ci-cd-in-ci-cd-and-devops/image.png] Happy coding! -------------------------------------------------------------------------------- CONCLUSION: CI/CD TAKEAWAYS * CI/CD makes your app safer, your team faster, and your life easier. * It’s not just for big tech—it’s perfect for student projects, too. * Automate early. Test constantly. Let your tools catch bugs, so your users don’t. > ❗ Pro Tip: Skipping tests to “save time” will cost more time later when things > break. Trust your robot helpers!
Maggie

Discuss with Maggie
Use the power of generative AI to interact with course content

Maggie is a generative AI that can help you understand the course content better. You can ask her questions about the lecture, and she will try to answer them. You can also see the questions asked by other students and her responses.

Discuss with Others
Ask questions, share your thoughts, and discuss with other learners

Join the discussion to ask questions, share your thoughts, and discuss with other learners
Setup
React Fundamentals
10 points
Next.js
10 points
Advanced React
Databases
10 points
React Hooks
Authentication and Authorisation
10 points
APIs
CI/CD and DevOps
Testing React
Advanced Topics