0
0
Node.jsframework~10 mins

CI/CD pipeline basics in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a basic GitHub Actions workflow that triggers on push.

Node.js
name: Node.js CI
on: [1]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
Drag options to blanks, or click blank then click option'
Arelease
Bschedule
Cpush
Dpull_request
Attempts:
3 left
💡 Hint
Common Mistakes
Using pull_request instead of push triggers workflow on PRs, not pushes.
2fill in blank
medium

Complete the code to add a step that installs Node.js dependencies using npm.

Node.js
    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: npm [1]
Drag options to blanks, or click blank then click option'
Astart
Binstall
Cbuild
Dtest
Attempts:
3 left
💡 Hint
Common Mistakes
Using npm start runs the app instead of installing packages.
3fill in blank
hard

Fix the error in the step that runs tests by completing the command.

Node.js
      - name: Run tests
        run: npm [1]
Drag options to blanks, or click blank then click option'
Atest
Bbuild
Cinstall
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using npm build or npm start does not run tests.
4fill in blank
hard

Fill both blanks to create a job that runs on Ubuntu and caches npm dependencies.

Node.js
jobs:
  build:
    runs-on: [1]
    steps:
      - uses: actions/checkout@v3
      - name: Cache npm dependencies
        uses: actions/cache@v3
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-[2]
Drag options to blanks, or click blank then click option'
Aubuntu-latest
Bwindows-latest
C14
D18
Attempts:
3 left
💡 Hint
Common Mistakes
Using Windows runner when Linux is expected.
Using wrong Node.js version in cache key.
5fill in blank
hard

Fill all three blanks to define a workflow that triggers on pull requests, installs dependencies, and runs tests.

Node.js
name: CI
on: [1]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: npm [2]
      - name: Run tests
        run: npm [3]
Drag options to blanks, or click blank then click option'
Apull_request
Binstall
Ctest
Dpush
Attempts:
3 left
💡 Hint
Common Mistakes
Using push instead of pull_request for trigger.
Mixing up install and test commands.