1 | version: 2
|
2 |
|
3 | aliases:
|
4 | - &restore-cache
|
5 | restore_cache:
|
6 | key: dependency-cache-{{ checksum "package.json" }}
|
7 | - &install-deps
|
8 | run:
|
9 | name: Install dependencies
|
10 | command: npm ci
|
11 | - &build-packages
|
12 | run:
|
13 | name: Build
|
14 | command: npm run build
|
15 | - &run-unit-tests
|
16 | run:
|
17 | name: Test
|
18 | command: npm run test
|
19 |
|
20 | jobs:
|
21 | build:
|
22 | working_directory: ~/nest
|
23 | docker:
|
24 | - image: cimg/node:20.2
|
25 | steps:
|
26 | - checkout
|
27 | - run:
|
28 | name: Update NPM version
|
29 | command: sudo npm install -g npm@latest
|
30 | - restore_cache:
|
31 | key: dependency-cache-{{ checksum "package.json" }}
|
32 | - run:
|
33 | name: Install dependencies
|
34 | command: npm ci
|
35 | - save_cache:
|
36 | key: dependency-cache-{{ checksum "package.json" }}
|
37 | paths:
|
38 | - ./node_modules
|
39 | - run:
|
40 | name: Build
|
41 | command: npm run build
|
42 |
|
43 | unit_tests:
|
44 | working_directory: ~/nest
|
45 | docker:
|
46 | - image: cimg/node:20.2
|
47 | steps:
|
48 | - checkout
|
49 | - *restore-cache
|
50 | - *install-deps
|
51 | - *build-packages
|
52 | - *run-unit-tests
|
53 |
|
54 | workflows:
|
55 | version: 2
|
56 | build-and-test:
|
57 | jobs:
|
58 | - build
|
59 | - unit_tests:
|
60 | requires:
|
61 | - build
|
62 | |
\ | No newline at end of file |