Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
dscar-jshint: moneyforward/dscar-jshint@1.2.0
Use dscar-jshint
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Analyze code statically using JSHint and then evaluate the result
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
analyze | Specify analysis steps | No | [sequence of length 1] see source | steps |
circle_compare_url-path | Specify the path of `CIRCLE_COMPARE_URL.txt` if you are using `iynere/compare-url` orb | No | '' | string |
executor | Specify the image used to execute analysis | No | default | executor |
parallelism | If parallelism is set to N > 1, then N independent executors will be set up and each will run the steps of that job in parallel. | No | 1 | integer |
resource_class | Amount of CPU and RAM allocated to each container in a job. | No | small | string |
test-results-path | Specify the value of the path parameter in the store_test_results step if you need to change it | No | /tmp/test-results | string |
vcs-api-token | Specify the environment variable name where the VCS (Version Control System) API token is set. | No | GITHUB_TOKEN | env_var_name |
Calculate the difference of JSHint results between HEAD branch and BASE branch and then evaluate the result
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
analyze | Specify analysis steps | No | [sequence of length 1] see source | steps |
circle_compare_url-path | Specify the path of `CIRCLE_COMPARE_URL.txt` if you are using `iynere/compare-url` orb | No | '' | string |
executor | Specify the image used to execute analysis | No | default | executor |
parallelism | If parallelism is set to N > 1, then N independent executors will be set up and each will run the steps of that job in parallel. | No | 1 | integer |
resource_class | Amount of CPU and RAM allocated to each container in a job. | No | small | string |
test-results-path | Specify the value of the path parameter in the store_test_results step if you need to change it | No | /tmp/test-results | string |
vcs-api-token | Specify the environment variable name where the VCS (Version Control System) API token is set. | No | GITHUB_TOKEN | env_var_name |
Analyze code statically using JSHint
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
analysis-results-path | Specify the path to save the analysis results if you need to change it (default: /tmp/dscar/analysis-results) | No | '' | string |
error-pattern | Specify the pattern if you want to detect analyzing errors from the standard error | No | .* | string |
max-procs | Specify the maximum number of processes to run at the same time | No | 1 | integer |
no-analysis-output-timeout | Elapsed time the command can run without output. The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s” | No | 10m | string |
patterns-to-exclude | Specify patterns to exclude by regular expression (Multiple patterns can be specified by separating them with line feed) | No | ^\./\.git/.* | string |
patterns-to-include | Specify patterns to include by regular expression (Multiple patterns can be specified by separating them with line feed) | No | .*\.js$ | string |
prepare | Specify the required steps before analysis if necessary | No | [sequence of length 1] see source | steps |
redirecting-output | Specify "/dev/null" if you do not want to display the analysis results on the standard output | No | /dev/null | enum |
starting-points | Specify the path of starting to search for files to analyze (Multiple paths can be specified by separating them with line feed) | No | . | string |
Default JSHint execution environment
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
analysis-results-path | Specify the path to save the analysis results if you need to change it | No | /tmp/dscar/analysis-results | string |
docker-image | Specify the image used to execute JSHint | No | circleci/node | string |
git-base_revision | Please set << pipeline.git-base_revision >> | No | '0000000000000000000000000000000000000000' | string |
git-revision | Please set << pipeline.git-revision >> | Yes | - | string |
project-git_url | Please set << pipeline.project.git_url >> | Yes | - | string |
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
commands:
analyze:
description: Analyze code statically using JSHint
parameters:
analysis-results-path:
default: ""
description: 'Specify the path to save the analysis results if you need to
change it (default: /tmp/dscar/analysis-results)'
type: string
error-pattern:
default: .*
description: Specify the pattern if you want to detect analyzing errors from
the standard error
type: string
max-procs:
default: 1
description: Specify the maximum number of processes to run at the same time
type: integer
no-analysis-output-timeout:
default: 10m
description: Elapsed time the command can run without output. The string is
a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
patterns-to-exclude:
default: ^\./\.git/.*
description: Specify patterns to exclude by regular expression (Multiple patterns
can be specified by separating them with line feed)
type: string
patterns-to-include:
default: .*\.js$
description: Specify patterns to include by regular expression (Multiple patterns
can be specified by separating them with line feed)
type: string
prepare:
default:
- install-analyzer
description: Specify the required steps before analysis if necessary
type: steps
redirecting-output:
default: /dev/null
description: Specify "/dev/null" if you do not want to display the analysis
results on the standard output
enum:
- /dev/stdout
- /dev/stderr
- /dev/null
type: enum
starting-points:
default: .
description: Specify the path of starting to search for files to analyze (Multiple
paths can be specified by separating them with line feed)
type: string
steps:
- dscar/analyze:
analysis-command: npx
analysis-name: JSHint
analysis-results-path: << parameters.analysis-results-path >>
error-pattern: << parameters.error-pattern >>
no-output-timeout: << parameters.no-analysis-output-timeout >>
patterns-to-exclude: << parameters.patterns-to-exclude >>
patterns-to-include: << parameters.patterns-to-include >>
prepare:
- steps: << parameters.prepare >>
- run:
command: |
set -x
REPORTER_PATH=$(mktemp)
echo 'exports.reporter = (results) => console.log(JSON.stringify(results));' > "${REPORTER_PATH}"
declare -ax ANALYSIS_ARGUMENTS=( jshint --reporter "${REPORTER_PATH}" )
echo "$(declare -p ANALYSIS_ARGUMENTS)" >> $BASH_ENV
FILTER="$(
cat \<<-"EOT" | tr -s ' \n' ' '
flatten | map(@html "<file name=\"\(.file)\">
<error
message=\"\(.error.reason)\" line=\"\(.error.line)\" column=\"\(.error.character)\"
severity=\"\(if (.error.code | startswith("I")) then "info" elif (.error.code | startswith("W")) then "warning" else "error" end)\"
source=\"jshint.\(.error.code)\" />
</file>") | "<checkstyle>\(join(""))</checkstyle>"
EOT
)"
declare -ax TRANSFORMATION_ARGUMENTS=( -srM "$FILTER" )
echo "$(declare -p TRANSFORMATION_ARGUMENTS)" >> $BASH_ENV
name: export ANALYSIS_ARGUMENTS TRANSFORMATION_ARGUMENTS
redirecting-output: << parameters.redirecting-output >>
should-find: "true"
starting-points: << parameters.starting-points >>
step-name: Analyze code statically using JSHint
transformation-command: jq
install-analyzer:
description: Install JSHint
steps:
- run: sudo npm install --global jshint
description: Delta JSHint reports
display:
home_url: https://corp.moneyforward.com/
source_url: https://github.com/moneyforward/dscar-jshint
executors:
default:
description: Default JSHint execution environment
docker:
- image: << parameters.docker-image >>
environment:
CIRCLE_COMPARE_URL: << parameters.project-git_url >>/compare/<< parameters.git-base_revision
>>..<< parameters.git-revision >>
DSCAR_ANALYSIS_RESULTS_PATH: << parameters.analysis-results-path >>
parameters:
analysis-results-path:
default: /tmp/dscar/analysis-results
description: Specify the path to save the analysis results if you need to
change it
type: string
docker-image:
default: circleci/node
description: Specify the image used to execute JSHint
type: string
git-base_revision:
default: "0000000000000000000000000000000000000000"
description: Please set << pipeline.git-base_revision >>
type: string
git-revision:
description: Please set << pipeline.git-revision >>
type: string
project-git_url:
description: Please set << pipeline.project.git_url >>
type: string
jobs:
analyze:
description: Analyze code statically using JSHint and then evaluate the result
executor: << parameters.executor >>
parallelism: << parameters.parallelism >>
parameters:
analyze:
default:
- analyze
description: Specify analysis steps
type: steps
circle_compare_url-path:
default: ""
description: Specify the path of `CIRCLE_COMPARE_URL.txt` if you are using
`iynere/compare-url` orb
type: string
executor:
default: default
description: Specify the image used to execute analysis
type: executor
parallelism:
default: 1
description: If parallelism is set to N > 1, then N independent executors
will be set up and each will run the steps of that job in parallel.
type: integer
resource_class:
default: small
description: Amount of CPU and RAM allocated to each container in a job.
type: string
test-results-path:
default: /tmp/test-results
description: Specify the value of the path parameter in the store_test_results
step if you need to change it
type: string
vcs-api-token:
default: GITHUB_TOKEN
description: Specify the environment variable name where the VCS (Version
Control System) API token is set.
type: env_var_name
resource_class: << parameters.resource_class >>
steps:
- dscar/analyze-and-evaluate:
analyze: << parameters.analyze >>
circle_compare_url-path: << parameters.circle_compare_url-path >>
test-results-path: << parameters.test-results-path >>
vcs-api-token: << parameters.vcs-api-token >>
execute:
description: Calculate the difference of JSHint results between HEAD branch and
BASE branch and then evaluate the result
executor: << parameters.executor >>
parallelism: << parameters.parallelism >>
parameters:
analyze:
default:
- analyze
description: Specify analysis steps
type: steps
circle_compare_url-path:
default: ""
description: Specify the path of `CIRCLE_COMPARE_URL.txt` if you are using
`iynere/compare-url` orb
type: string
executor:
default: default
description: Specify the image used to execute analysis
type: executor
parallelism:
default: 1
description: If parallelism is set to N > 1, then N independent executors
will be set up and each will run the steps of that job in parallel.
type: integer
resource_class:
default: small
description: Amount of CPU and RAM allocated to each container in a job.
type: string
test-results-path:
default: /tmp/test-results
description: Specify the value of the path parameter in the store_test_results
step if you need to change it
type: string
vcs-api-token:
default: GITHUB_TOKEN
description: Specify the environment variable name where the VCS (Version
Control System) API token is set.
type: env_var_name
resource_class: << parameters.resource_class >>
steps:
- dscar/execute-and-evaluate:
analyze: << parameters.analyze >>
circle_compare_url-path: << parameters.circle_compare_url-path >>
test-results-path: << parameters.test-results-path >>
vcs-api-token: << parameters.vcs-api-token >>
orbs:
dscar: moneyforward/dscar@1.2
version: 2.1