-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
156 lines (145 loc) · 4.76 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
orbs:
# The Node.js orb contains a set of prepackaged CircleCI configuration you can utilize
# Orbs reduce the amount of configuration required for common tasks.
# See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/node
node: circleci/[email protected]
snyk: snyk/[email protected]
defaults: &defaults
working_directory: ~/repo/tmp
docker:
- image: cimg/node:16.10
jobs:
download-deps:
<<: *defaults
steps:
- run:
name: Download cc-test-reporter
command: |
mkdir -p repo/tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./repo/tmp/cc-test-reporter
chmod +x ./repo/tmp/cc-test-reporter
- persist_to_workspace:
root: ./repo/tmp
paths:
- cc-test-reporter
- run:
name: List Files
command: ls -la
setup-environment:
<<: *defaults
steps:
# Checkout the code as the first step.
- checkout:
path: ~/repo/tmp
- attach_workspace:
at: ~/repo/tmp
# Next, the node orb's install-packages step will install the dependencies from a package.json.
# The orb install-packages step will also automatically cache them for faster future runs.
- node/install-packages:
# If you are using yarn, change the line below from "npm" to "yarn"
pkg-manager: npm
# Below is the definition of your job to build and test your app, you can rename and customize it as you want.
test:
<<: *defaults
# Then run your tests!
# CircleCI will report the results back to your VCS provider.
steps:
- checkout:
path: ~/repo/tmp
- attach_workspace:
at: ~/repo/tmp
# Next, the node orb's install-packages step will install the dependencies from a package.json.
# The orb install-packages step will also automatically cache them for faster future runs.
- node/install-packages:
# If you are using yarn, change the line below from "npm" to "yarn"
pkg-manager: npm
- run:
name: list file
command: ls -la && echo $PWD
- attach_workspace:
at: ~/repo/tmp
- run:
name: Run tests
command: |
npm test
./tmp/cc-test-reporter format-coverage -t lcov -o tmp/codeclimate.npm.json coverage/frontend/lcov.info
upload-coverage:
<<: *defaults
environment:
CC_TEST_REPORTER_ID: $CC_API_KEY
steps:
- attach_workspace:
at: ~/repo/tmp
- run:
name: Upload coverage results to Code Climate
command : |
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.npm.json
scan-vulnerabilities:
<<: *defaults
environment:
SNYK_TOKEN: $SNYK_API_KEY
steps:
- snyk/scan:
token-variable: SNYK_TOKEN
fail-on-issues: true
command: test
target-file: ~/repo/tmp/dist/toaste-notifier.js
monitor-on-build: true
protect: false
severity-threshold: medium
os: linux
build:
<<: *defaults
steps:
- run:
name: Package build
command: npm run build
publish:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo/tmp
- run:
name: Auth with NPM
command: echo "//registry.npmjs.org/:_authToken=$NPM_API_KEY" > ~/repo/tmp/.npmrc
- run:
name: Publish Package
command: npm publish
workflows:
# Below is the definition of your workflow.
# Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.
# CircleCI will run this workflow on every commit.
# For more details on extending your workflow, see the configuration docs: https://circleci.com/docs/2.0/configuration-reference/#workflows
build-test:
jobs:
- download-deps:
context: NPM
- setup-environment:
context: NPM
requires:
- download-deps
- test:
context: NPM
requires:
- setup-environment
- upload-coverage:
context: NPM
requires:
- test
- build:
context: NPM
requires:
- test
- scan-vulnerabilities:
context: NPM
requires:
- build
- publish:
context: NPM
requires:
- scan-vulnerabilities
# For running simple node tests, you could optionally use the node/test job from the orb to replicate and replace the job above in fewer lines.
# - node/test