Script Valley
CI/CD with GitHub Actions
Building a CI Pipeline/Assessment

Practice & Assessment

Test your understanding of Building a CI Pipeline

Multiple Choice Questions

5
1

Why should you use npm ci instead of npm install in a CI workflow?

2

What determines when an actions/cache entry is invalidated?

3

A secret stored in GitHub Secrets is accidentally echoed in a run step. What appears in the workflow logs?

4

Job B has needs: [job-a] defined. Job A fails. What happens to Job B?

5

What is the default retention period for uploaded artifacts in GitHub Actions?

Coding Challenges

1
1

Build a Node.js CI Pipeline with Caching

Create a Node.js project with at least one Jest test that passes and one package.json test script. Write a GitHub Actions workflow that triggers on pull_request to main. The workflow must: set up Node 20 with npm caching enabled, run npm ci, and run npm test. Verify that: the workflow completes in under 60 seconds on the second run due to cache hit, and the PR shows a green check. Expected output: Jest test output visible in logs with passing tests. Estimated time: 20 minutes.

Easy

Mini Project

1

Full CI Pipeline for a REST API

Take an existing or new Node.js/Express application with at least 3 Jest tests. Build a CI workflow that runs on pull_request to main. The workflow must have three jobs: lint (runs ESLint), test (runs Jest with coverage using npm test -- --coverage), and build (runs npm run build, only after lint and test pass using needs). The test job must use dependency caching. The build job must upload the dist/ folder as an artifact named api-build with a 3-day retention. Store a fake API_KEY as a GitHub Secret and reference it in the test job's env block (the test does not need to use it — just demonstrate secret injection). Trigger the workflow via a pull request and verify all three jobs show green.

Medium