Skip to content

Commit 51d9c89

Browse files
authored
Run depencency cruiser in jenkins (#281)
Adds a Jenkins build step to verify that there aren't any dependency cruiser errors, such as using deprecated modules or importing npm modules directly without going through our wrappers.
1 parent 5e68587 commit 51d9c89

File tree

2 files changed

+56
-26
lines changed

2 files changed

+56
-26
lines changed

Jenkinsfile

+17
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ pipeline {
133133
}
134134
}
135135
}
136+
stage('Dependency Cruiser') {
137+
when {
138+
anyOf {
139+
expression { return params.FRONTEND_TESTS }
140+
changeset '**/*.js'
141+
changeset '**/*.jsp'
142+
changeset '**/*.css'
143+
changeset '**/*.json'
144+
}
145+
}
146+
steps {
147+
dir('src/main/webapp/ui') {
148+
echo 'Running dependency cruiser'
149+
sh 'npm run depcruise'
150+
}
151+
}
152+
}
136153
stage('Jest Tests') {
137154
when {
138155
anyOf {

src/main/webapp/ui/.dependency-cruiser.js

+39-26
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
licenseNot: ["MIT", "BSD", "Apache", "Hippocratic", "ISC"],
1212
},
1313
},
14+
1415
{
1516
name: "axios-only",
1617
comment: "Only src/common/axios.js should import axios",
@@ -25,17 +26,35 @@ module.exports = {
2526
},
2627
},
2728

28-
// {
29-
// name: 'no-circular',
30-
// severity: 'warn',
31-
// comment:
32-
// 'This dependency is part of a circular relationship. You might want to revise ' +
33-
// 'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
34-
// from: {},
35-
// to: {
36-
// circular: true
37-
// }
38-
// },
29+
{
30+
name: "react-image-editor is deprecated",
31+
severity: "error",
32+
from: {
33+
pathNot: [
34+
// once the old gallery is removed, we can remove the dependency and stop using `--force` when calling `npm install`
35+
"^src/Gallery",
36+
],
37+
},
38+
to: {
39+
path: "@toast-ui/react-image-editor",
40+
},
41+
},
42+
43+
// this rule is disabled because cycles are generally not an issue, but the rule can be useful when debugging some issues.
44+
/*
45+
{
46+
name: 'no-circular',
47+
severity: 'warn',
48+
comment:
49+
'This dependency is part of a circular relationship. You might want to revise ' +
50+
'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
51+
from: {},
52+
to: {
53+
circular: true
54+
}
55+
},
56+
*/
57+
3958
{
4059
name: "no-orphans",
4160
comment:
@@ -56,9 +75,10 @@ module.exports = {
5675
},
5776
to: {},
5877
},
78+
5979
{
6080
name: "no-unreachable-from-root",
61-
severity: "error",
81+
severity: "warn",
6282
from: {
6383
path: ["src"],
6484
},
@@ -115,6 +135,7 @@ module.exports = {
115135
reachable: false,
116136
},
117137
},
138+
118139
{
119140
name: "no-deprecated-core",
120141
comment:
@@ -148,6 +169,7 @@ module.exports = {
148169
],
149170
},
150171
},
172+
151173
{
152174
name: "not-to-deprecated",
153175
comment:
@@ -159,6 +181,7 @@ module.exports = {
159181
dependencyTypes: ["deprecated"],
160182
},
161183
},
184+
162185
{
163186
name: "no-duplicate-dep-types",
164187
comment:
@@ -175,6 +198,7 @@ module.exports = {
175198
dependencyTypesNot: ["type-only"],
176199
},
177200
},
201+
178202
{
179203
name: "not-to-spec",
180204
comment:
@@ -187,6 +211,7 @@ module.exports = {
187211
path: ".(spec|test).(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee.md)$",
188212
},
189213
},
214+
190215
{
191216
name: "not-to-dev-dep",
192217
severity: "error",
@@ -206,6 +231,7 @@ module.exports = {
206231
pathNot: "@babel",
207232
},
208233
},
234+
209235
{
210236
name: "optional-deps-used",
211237
severity: "info",
@@ -219,6 +245,7 @@ module.exports = {
219245
dependencyTypes: ["npm-optional"],
220246
},
221247
},
248+
222249
{
223250
name: "peer-deps-used",
224251
comment:
@@ -308,20 +335,6 @@ module.exports = {
308335
reachable: true,
309336
},
310337
},
311-
312-
{
313-
name: "react-image-editor is deprecated",
314-
severity: "error",
315-
from: {
316-
pathNot: [
317-
// once the old gallery is removed, we can remove the dependency and stop using `--force` when calling `npm install`
318-
"^src/Gallery",
319-
],
320-
},
321-
to: {
322-
path: "@toast-ui/react-image-editor",
323-
},
324-
},
325338
],
326339
allowed: [],
327340
required: [],

0 commit comments

Comments
 (0)