CodeBlanks Logo Icon CodeBlanks

Summary - CI/CD and monitoring

Write a workflow with lint, test and build steps.

Summary - CI/CD and monitoring

In this group you learned CI/CD pipelines, GitHub Actions workflows and performance monitoring.

On every push build and test run automatically; quality thresholds are set with Web Vitals and Lighthouse. Secrets live on the platform, not in the repo.

Now you will write a cached build and test workflow.

Practice Write the Test workflow

Write a test workflow. Use name: Test, on: push. Set up setup-node@v4 with node-version: '20' and cache: 'npm'. Run npm ci && npm test.

Starter code

App.jsx
# Write the Test workflow here

Sample solution

App.jsx
name: Test
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci && npm test

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which of the following is wrong?

  • secrets are not written to the repo
  • cache shortens npm ci time
  • Lighthouse gives an accessibility score
  • Web Vitals runs only on the server Correct answer

Explanation: Web Vitals runs on the client side.

2 Fill in the blank: checkout action

Question
steps:
  - uses: actions/____@v4
Answer
steps:
  - uses: actions/checkout@v4

Explanation: answer: checkout. actions/checkout@v4 pulls the code.

3 Match concepts

Term Meaning
CI Merges changes
cache Saves time
Lighthouse Gives scores
secrets Hidden keys

All lessons in Advanced