Skip to content

Latest commit

 

History

History
147 lines (107 loc) · 5.07 KB

File metadata and controls

147 lines (107 loc) · 5.07 KB

01 – Continuous Integration (CI)

Focuses on building code, versioning, branching strategies, and ensuring every commit is validated properly.

Table of Contents

  1. Clean Build Environments
  2. Git & Branch Policies
  3. Testing from Dev/Personal Branches (Version Bump Avoidance)
  4. Code Validation in CI
  5. Git Flow vs OneFlow
  6. Unit / Integration / E2E Tests
  7. Scenario: Slow Build Times
  8. Scenario: Double-Build Problem in Docker CI Pipeline
  9. Scenario: Docker Build Time Optimization in CI/CD

1) Clean Build Environments

Question (Scenario):
Your builds sometimes fail because leftover files from previous runs cause unexpected results. How would you make sure each build runs in a clean, consistent environment?

Hints / Key Points
  • Containerized or ephemeral build agents ensure no leftover files or dependencies.
  • Reproducible environment: each run starts fresh.
  • Avoid “works on my machine” issues by isolating dependencies.

2) Git & Branch Policies

Question:
When setting up a new Git repository for a service, how do you make sure collaboration and merging are done in a controlled, high-quality way?

Hints / Key Points
  • Require pull requests to merge into main.
  • Use branch protections: code reviews, mandatory checks, or tests.
  • Adopt a branching strategy (Git Flow, OneFlow, or trunk-based).

3) Testing from Dev/Personal Branches (Version Bump Avoidance)

Question:
You want developers to build and test code on a personal branch without bumping the official app version. How do you do that?

Hints / Key Points
  • Only bump the version if building from main (after merging).
  • Use ephemeral tags (like dev-<commit-hash>) for personal branches.
  • This prevents cluttering your production semver with test builds.

4) Code Validation in CI

Question:
What kind of checks do you usually include in a CI pipeline to keep code quality high?

Hints / Key Points
  • Linting and static analysis for code style and potential security flaws.
  • Unit tests to verify logic.
  • Optional checks: integration tests, code coverage, or style checks.

5) Git Flow vs OneFlow

Question:
Explain the main differences between Git Flow and OneFlow, and give an example of when you might pick one over the other.

Hints / Key Points
  • Git Flow:
    • Has a develop branch and separate release/ branches.
    • Good for scheduled releases or big features that need isolation.
  • OneFlow:
    • Fewer branches; merges features straight into main.
    • Easier for continuous delivery or smaller teams who release often.

6) Unit / Integration / E2E Tests

Question (Scenario):
A new developer asks how different types of tests fit into the CI pipeline. Can you explain the roles of unit, integration, and end-to-end tests?

Hints / Key Points
  • Unit tests: Check individual pieces of code in isolation.
  • Integration tests: Validate how services or components interact (e.g., API to DB).
  • E2E tests: Full user flow from start to finish, mirroring real production usage.

7) Scenario: Slow Build Times

Question (Scenario):
The CI builds are getting slower and slower, which annoys developers. What could you do to speed things up?

Hints / Key Points
  • Caching dependencies so you don’t rebuild or re-download everything on each run.
  • Splitting large monolithic builds into smaller jobs or microservices.
  • Using multi-stage Docker builds or ephemeral agents to reduce overhead.

8) Scenario: Double-Build Problem in Docker CI Pipeline

Question:
You notice your CI pipeline builds a Docker image twice—once for security scanning (e.g., Trivy) and again for deployment. This doubles build time and resource usage.

How would you troubleshoot and resolve this?

Hints / Key Points
  • Identify where each build step is triggered; check pipeline definitions or separate workflows.
  • Consolidate scanning and deployment into one pipeline stage, or reuse the built image artifact.
  • Push a single built image to a temporary registry, run scans on that image, then deploy if it’s clean.

9) Scenario: Docker Build Time Optimization in CI/CD

Question (Scenario):
Your Docker builds in CI/CD are taking longer than expected, especially for a .NET or Java app with large dependencies.

What can you do to improve the build time?

Hints / Key Points
  • Optimize your Dockerfile structure: place static dependency installation steps at the top for caching.
  • Use multi-stage builds to keep final images small.
  • Possibly store a “build cache” or layer cache between runs so you don’t rebuild everything from scratch each time.