Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does CI stand for in DevOps?
CI stands for Continuous Integration. It means automatically combining code changes from many developers into a shared main branch frequently.
Click to reveal answer
beginner
What is the main goal of a CD pipeline?
CD stands for Continuous Delivery or Continuous Deployment. Its goal is to automatically prepare and release code changes to production or staging environments safely and quickly.
Click to reveal answer
beginner
Name three common stages in a CI/CD pipeline.
Common stages include: 1) Build - compiling and preparing code, 2) Test - running automated tests, 3) Deploy - releasing code to an environment.
Click to reveal answer
beginner
Why is automated testing important in CI/CD?
Automated tests quickly check if new code breaks anything. This helps catch errors early and keeps the software reliable.
Click to reveal answer
beginner
How does a CI/CD pipeline help a Django project?
It automates building, testing, and deploying Django code. This saves time, reduces mistakes, and delivers updates faster to users.
Click to reveal answer
What is the first step in a typical CI/CD pipeline?
ABuild the code
BDeploy to production
CRun automated tests
DWrite documentation
✗ Incorrect
The pipeline usually starts by building the code to prepare it for testing and deployment.
Which of these is NOT a benefit of CI/CD?
AFaster delivery of features
BManual error-prone deployments
CEarly detection of bugs
DConsistent software releases
✗ Incorrect
CI/CD reduces manual deployments, which are error-prone. So manual error-prone deployments are not a benefit.
In a Django project, what tool might you use to run tests in a CI pipeline?
Anpm install
Bdocker build
Cpytest or Django's test runner
Dgit commit
✗ Incorrect
pytest or Django's built-in test runner are used to run tests in Django projects.
What does Continuous Deployment mean?
AAutomatically releasing every change to production
BManually deploying code after testing
COnly building code without testing
DWriting code continuously
✗ Incorrect
Continuous Deployment means every change that passes tests is automatically released to production.
Which stage ensures code changes do not break existing features?
ACommitting
BBuilding
CDeploying
DTesting
✗ Incorrect
Testing runs automated checks to make sure new code does not break existing features.
Explain the main steps of a CI/CD pipeline and why each is important.
Think about how code moves from writing to running live.
You got /4 concepts.
Describe how using a CI/CD pipeline benefits a Django web application project.
Consider what happens without automation.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a CI/CD pipeline in a Django project?
easy
A. To automate testing and deployment for faster and safer code delivery
B. To manually review code changes before deployment
C. To write Django models automatically
D. To create database backups
Solution
Step 1: Understand CI/CD pipeline purpose
A CI/CD pipeline automates the process of testing and deploying code changes to reduce errors and speed up delivery.
Step 2: Match purpose with options
To automate testing and deployment for faster and safer code delivery correctly states automation of testing and deployment, which is the core of CI/CD pipelines.
Final Answer:
To automate testing and deployment for faster and safer code delivery -> Option A
Quick Check:
CI/CD automates testing and deployment = D [OK]
Hint: CI/CD means automating tests and deploys [OK]
Common Mistakes:
Confusing CI/CD with manual code review
Thinking CI/CD creates Django code automatically
Assuming CI/CD is for backups
2. Which of the following is the correct syntax to define a job named test in a GitLab CI/CD pipeline YAML file?
easy
A. test:
script:
- python manage.py test
B. job test {
run: python manage.py test
}
C. - job: test
steps:
- script: python manage.py test
D. test => {
script: 'python manage.py test'
}
Solution
Step 1: Recall GitLab CI YAML job syntax
GitLab CI jobs are defined as job_name: followed by script: list with commands.
Step 2: Compare options with correct YAML syntax
test:
script:
- python manage.py test matches the correct YAML format for a job named test running the Django test command.
Final Answer:
test:\n script:\n - python manage.py test -> Option A
Quick Check:
GitLab CI job syntax uses job_name: and script: list = A [OK]
Hint: GitLab CI jobs use job_name: and script: list [OK]
Common Mistakes:
Using curly braces or other languages syntax
Missing the dash before script commands
Confusing job syntax with other CI tools
3. Given this GitHub Actions workflow snippet for a Django project:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
run: python manage.py test
What will happen when this workflow runs?
medium
A. The workflow will fail because Python version is not specified
B. The workflow will check out code, set Python 3.12, install dependencies, and run Django tests
C. The workflow will skip installing dependencies
D. The workflow will deploy the Django app automatically
Solution
Step 1: Analyze each step in the workflow
The workflow checks out code, sets up Python 3.12, installs dependencies from requirements.txt, then runs Django tests.
Step 2: Confirm expected behavior
All steps are valid and will run in order, so tests will execute after setup.
Final Answer:
The workflow will check out code, set Python 3.12, install dependencies, and run Django tests -> Option B
Quick Check:
Steps run in order: checkout, setup, install, test = A [OK]
Hint: Read steps top to bottom to predict workflow actions [OK]
Common Mistakes:
Assuming Python version missing causes failure
Thinking dependencies are skipped
Confusing test run with deployment
4. You have this GitLab CI job snippet:
test:
script:
- python manage.py test
only:
- main
- develop
But tests are not running on your feature branch pushes. What is the likely problem?
medium
A. The script command is incorrect
B. The pipeline YAML file is missing
C. The job is limited to run only on main and develop branches
D. The tests are skipped because of syntax error in Python code
Solution
Step 1: Understand the 'only' keyword in GitLab CI
The 'only' keyword restricts job execution to specified branches, here main and develop only.
Step 2: Analyze why feature branches don't run tests
Since feature branches are not listed, the job does not run on them.
Final Answer:
The job is limited to run only on main and develop branches -> Option C
Quick Check:
'only' limits branches = B [OK]
Hint: 'only' controls branches where job runs [OK]
Common Mistakes:
Thinking script command is wrong without checking
Assuming pipeline file is missing
Blaming test code syntax without evidence
5. You want to create a CI/CD pipeline for your Django app that runs tests only if code changes affect models.py or views.py. Which GitLab CI configuration snippet correctly implements this?
hard
A. test:
script:
- python manage.py test
only:
refs:
- main
- develop
B. test:
script:
- python manage.py test
except:
changes:
- models.py
- views.py
C. test:
script:
- python manage.py test
when: manual
D. test:
script:
- python manage.py test
only:
changes:
- models.py
- views.py
Solution
Step 1: Understand 'only: changes' in GitLab CI
This setting runs the job only if specified files change in the commit.
Step 2: Match requirement with options
test:
script:
- python manage.py test
only:
changes:
- models.py
- views.py uses 'only: changes' with models.py and views.py, so tests run only if these files change.