A CI/CD pipeline is a set of automated steps that help developers build, test, and deliver code changes quickly and safely. CI stands for Continuous Integration, and CD stands for Continuous Delivery or Deployment.
Click to reveal answer
beginner
Why use a CI/CD pipeline for an Express app?
Using a CI/CD pipeline for an Express app helps catch errors early, speeds up delivery, and ensures the app is tested and deployed automatically without manual steps.
Click to reveal answer
beginner
Name a common tool used to run tests in an Express app CI pipeline.
Jest or Mocha are common testing tools used to run automated tests in an Express app during the CI process.
Click to reveal answer
intermediate
What is the role of a build step in a CI/CD pipeline for Express apps?
The build step installs dependencies and prepares the app for testing and deployment, ensuring all code and packages are ready to run.
Click to reveal answer
intermediate
How does Continuous Deployment differ from Continuous Delivery in CI/CD?
Continuous Delivery means the app is ready to deploy automatically but requires manual approval to release. Continuous Deployment automatically releases every change that passes tests to production.
Click to reveal answer
What is the first step in a typical CI/CD pipeline for an Express app?
ARun automated tests
BBuild the app and install dependencies
CDeploy to production
DMerge code to main branch
✗ Incorrect
The first step is usually to build the app by installing dependencies and preparing the environment.
Which file commonly defines the scripts for testing and starting an Express app?
ADockerfile
Bapp.js
Cpackage.json
D.gitignore
✗ Incorrect
The package.json file contains scripts like 'test' and 'start' used in CI/CD pipelines.
What tool can be used to automate CI/CD pipelines on GitHub?
AGitHub Actions
BJenkins
CDocker
Dnpm
✗ Incorrect
GitHub Actions is a popular tool integrated with GitHub to automate CI/CD workflows.
In CI/CD, what does the 'test' step verify?
AThat automated tests pass successfully
BThat the app runs without errors
CDeployment configuration
DCode style only
✗ Incorrect
The test step runs automated tests to check that code changes work as expected.
Which environment is usually the last to receive code in a CI/CD pipeline?
ADevelopment
BTesting
CStaging
DProduction
✗ Incorrect
Production is the final environment where the app is live for users.
Describe the main steps of a CI/CD pipeline for an Express app.
Think about what happens from code change to live app.
You got /4 concepts.
Explain why automated testing is important in a CI/CD pipeline for Express apps.
Imagine deploying code without checking if it works.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of a CI/CD pipeline for an Express app?
easy
A. To automate testing and deployment when code changes
B. To write the Express app code manually
C. To create a user interface for the app
D. To store data in a database
Solution
Step 1: Understand CI/CD pipeline role
A CI/CD pipeline automates repetitive tasks like testing and deployment to save time and reduce errors.
Step 2: Identify pipeline purpose for Express app
For an Express app, the pipeline runs tests and deploys the app automatically when code changes.
Final Answer:
To automate testing and deployment when code changes -> Option A
Quick Check:
CI/CD automates testing and deployment [OK]
Hint: CI/CD means automatic test and deploy on code change [OK]
Common Mistakes:
Thinking CI/CD writes code
Confusing deployment with UI design
Assuming CI/CD manages databases
2. Which of the following is the correct syntax to run tests in a GitHub Actions workflow for an Express app?
easy
A. execute: npm test
B. run npm test
C. run: npm test
D. command: npm test
Solution
Step 1: Review GitHub Actions syntax for commands
In GitHub Actions, commands run under a step use the key 'run:' followed by the command string.
Step 2: Identify correct command format for tests
To run tests with npm, the correct syntax is 'run: npm test'. Other options miss the colon or use wrong keys.
Final Answer:
run: npm test -> Option C
Quick Check:
GitHub Actions uses 'run:' before commands [OK]
Hint: GitHub Actions commands start with 'run:' [OK]
Common Mistakes:
Omitting colon after 'run'
Using 'execute' or 'command' instead of 'run'
Writing commands without quotes or colon
3. Given this GitHub Actions step in a CI/CD pipeline for an Express app:
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
What happens if the tests fail?
medium
A. The pipeline stops and deployment does not happen
B. The pipeline ignores test failures and continues deployment
C. The pipeline retries the tests automatically
D. The pipeline skips installation and runs tests again
Solution
Step 1: Understand default GitHub Actions behavior on failure
If a step like 'npm test' fails (returns error), the pipeline stops by default and does not proceed to next steps.
Step 2: Apply this to deployment step
Since deployment usually comes after tests, if tests fail, deployment will not run to avoid deploying broken code.
Final Answer:
The pipeline stops and deployment does not happen -> Option A
Quick Check:
Failed test stops pipeline by default [OK]
Hint: Failed test stops pipeline unless configured otherwise [OK]
Common Mistakes:
Assuming pipeline continues after test failure
Thinking tests auto-retry without setup
Confusing install step with test step
4. You wrote this GitHub Actions workflow snippet for your Express app:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: npm install
- name: Run tests
run npm test
- name: Deploy
run: npm run deploy
What is the error in this snippet?
medium
A. Wrong command 'npm run deploy' for deployment
B. Missing colon after 'run' in the Run tests step
C. Install dependencies step should use 'npm ci' instead of 'npm install'
D. Steps should be inside a job, not directly under steps
Solution
Step 1: Check syntax of each step
In GitHub Actions, each step's command must use 'run:' with a colon. The 'Run tests' step misses the colon after 'run'.
Step 2: Verify other steps
'npm run deploy' is a valid command if defined in package.json scripts. 'npm install' is acceptable.
Final Answer:
Missing colon after 'run' in the Run tests step -> Option B
Quick Check:
GitHub Actions commands need 'run:' with colon [OK]
Hint: Check colons after 'run' in each step [OK]
Common Mistakes:
Forgetting colon after 'run'
Assuming 'npm run deploy' is invalid
Confusing job structure with step syntax
5. You want to add a deployment step to your Express app's GitHub Actions pipeline that only runs when tests pass and on the main branch. Which is the best way to configure this?
hard
A. Put deploy step before tests to speed up pipeline
B. Add 'run: npm deploy' without conditions
C. Use 'if: failure()' to deploy only if tests fail
D. Use 'if: github.ref == "refs/heads/main" && success()' before the deploy step
Solution
Step 1: Understand conditional deployment needs
Deployment should run only on main branch and only if tests succeed to avoid deploying broken code or on wrong branches.
Step 2: Use GitHub Actions condition syntax
The 'if:' condition can check branch with 'github.ref == "refs/heads/main"' and check success with 'success()' function.
Final Answer:
Use 'if: github.ref == "refs/heads/main" && success()' before the deploy step -> Option D
Quick Check:
Conditional deploy uses 'if:' with branch and success check [OK]
Hint: Use 'if:' with branch and success() to control deploy [OK]
Common Mistakes:
Deploying without branch or success check
Deploying before tests run
Using failure() to deploy on test failure
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.