Skip to content

Commit 12a7909

Browse files
authored
ci: tweak failure patterns, add GitFailure (#273)
1 parent fa3f4c1 commit 12a7909

12 files changed

+175
-51
lines changed

lib/ci/ci_failure_parser.js

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ const BUILD_FAILURE = 'BUILD_FAILURE';
3131
const JS_TEST_FAILURE = 'JS_TEST_FAILURE';
3232
const CC_TEST_FAILURE = 'CC_TEST_FAILURE';
3333
const JENKINS_FAILURE = 'JENKINS_FAILURE';
34+
const GIT_FAILURE = 'GIT_FAILURE';
3435

3536
const FAILURE_TYPES = {
36-
BUILD_FAILURE, JS_TEST_FAILURE, CC_TEST_FAILURE, JENKINS_FAILURE
37+
BUILD_FAILURE, JS_TEST_FAILURE, CC_TEST_FAILURE,
38+
JENKINS_FAILURE, GIT_FAILURE
3739
};
3840

3941
class CIResult {
@@ -83,14 +85,22 @@ class JenkinsFailure extends CIResult {
8385
}
8486
}
8587

86-
function buildFailureMatcher(patterns, ctx, text) {
88+
// Usually need a fix to the build scripts or in workers
89+
class GitFailure extends CIResult {
90+
constructor(ctx, reason) {
91+
super(ctx, reason);
92+
this.type = GIT_FAILURE;
93+
}
94+
}
95+
96+
function failureMatcher(Failure, patterns, ctx, text) {
8797
for (const pattern of patterns) {
8898
const matches = text.match(pattern.pattern);
8999
if (!matches) {
90100
continue;
91101
}
92-
const reason = pickContext(matches, text, pattern.context);
93-
return [new BuildFailure(ctx, reason)];
102+
const reason = pickContext(matches, text, pattern.context).trim();
103+
return [new Failure(ctx, reason)];
94104
}
95105
return null;
96106
}
@@ -114,52 +124,52 @@ const FAILURE_FILTERS = [{
114124
}
115125
}, {
116126
filter(ctx, text) {
117-
const pattern = /\[ {2}FAILED {2}\].+/g;
118-
const matches = text.match(pattern);
119-
if (!matches) {
120-
return null;
121-
}
122-
const reason = pickContext(matches, text, {
123-
index: 0, contextBefore: 5, contextAfter: 0
124-
});
125-
return [new CCTestFailure(ctx, reason)];
127+
const patterns = [{
128+
pattern: /\[ {2}FAILED {2}\].+/g,
129+
context: { index: 0, contextBefore: 5, contextAfter: 0 }
130+
}];
131+
return failureMatcher(CCTestFailure, patterns, ctx, text);
126132
}
127133
}, {
128134
// VS compilation error
129135
filter(ctx, text) {
130-
const pattern = /error C\d+:/mg;
131-
const matches = text.match(pattern);
132-
if (!matches) {
133-
return null;
134-
}
135-
const reason = pickContext(matches, text, {
136-
index: 0, contextBefore: 0, contextAfter: 5
137-
});
138-
return [new BuildFailure(ctx, reason)];
136+
const patterns = [{
137+
pattern: /error C\d+:/mg,
138+
context: { index: 0, contextBefore: 0, contextAfter: 5 }
139+
}];
140+
return failureMatcher(BuildFailure, patterns, ctx, text);
139141
}
140142
}, {
141143
filter(ctx, text) {
142-
const pattern = /java\.io\.IOException.+/g;
143-
const matches = text.match(pattern);
144-
if (!matches) {
145-
return null;
146-
}
147-
const reason = pickContext(matches, text, {
148-
index: -1, contextBefore: 0, contextAfter: 5
149-
});
150-
return [new JenkinsFailure(ctx, reason)];
144+
const patterns = [{
145+
pattern: /java\.io\.IOException.+/g,
146+
context: { index: -1, contextBefore: 0, contextAfter: 5 }
147+
}, {
148+
pattern: /Build timed out/g,
149+
context: { index: 0, contextBefore: 0, contextAfter: 1 }
150+
}];
151+
return failureMatcher(JenkinsFailure, patterns, ctx, text);
151152
}
152153
}, {
153154
filter(ctx, text) {
154-
const pattern = /hudson\.plugins\.git\.GitException+/g;
155+
const pattern =
156+
/Changes not staged for commit:[\s\S]+no changes added to commit/mg;
155157
const matches = text.match(pattern);
156158
if (!matches) {
157159
return null;
158160
}
159-
const reason = pickContext(matches, text, {
160-
index: 0, contextBefore: 2, contextAfter: 5
161-
}).trim();
162-
return [new JenkinsFailure(ctx, reason)];
161+
return new GitFailure(ctx, matches[0]);
162+
}
163+
}, {
164+
filter(ctx, text) {
165+
const patterns = [{
166+
pattern: /hudson\.plugins\.git\.GitException+/g,
167+
context: { index: 0, contextBefore: 2, contextAfter: 5 }
168+
}, {
169+
pattern: /Cannot rebase: .+/g,
170+
context: { index: 0, contextBefore: 0, contextAfter: 1 }
171+
}];
172+
return failureMatcher(GitFailure, patterns, ctx, text);
163173
}
164174
}, {
165175
filter(ctx, text) {
@@ -172,7 +182,7 @@ const FAILURE_FILTERS = [{
172182
pattern: /Error: .+/g,
173183
context: { index: 0, contextBefore: 0, contextAfter: 5 }
174184
}];
175-
return buildFailureMatcher(patterns, ctx, text);
185+
return failureMatcher(BuildFailure, patterns, ctx, text);
176186
}
177187
}, {
178188
filter(ctx, text) {
@@ -187,6 +197,9 @@ const FAILURE_FILTERS = [{
187197
}, {
188198
filter(ctx, text) {
189199
const patterns = [{
200+
pattern: /bash: line /g,
201+
context: { index: 0, contextBefore: 0, contextAfter: 1 }
202+
}, {
190203
pattern: /FATAL: .+/g,
191204
context: { index: -1, contextBefore: 0, contextAfter: 5 }
192205
}, {
@@ -204,17 +217,8 @@ const FAILURE_FILTERS = [{
204217
}, {
205218
pattern: /warning: failed .+/g,
206219
context: { index: 0, contextBefore: 0, contextAfter: 3 }
207-
}, {
208-
pattern: /Build timed out/g,
209-
context: { index: 0, contextBefore: 0, contextAfter: 1 }
210-
}, {
211-
pattern: /bash: line /g,
212-
context: { index: 0, contextBefore: 0, contextAfter: 1 }
213-
}, {
214-
pattern: /Cannot rebase: You have unstaged changes/g,
215-
context: { index: 0, contextBefore: 0, contextAfter: 1 }
216220
}];
217-
return buildFailureMatcher(patterns, ctx, text);
221+
return failureMatcher(BuildFailure, patterns, ctx, text);
218222
}
219223
}];
220224

@@ -242,7 +246,8 @@ CIFailureParser.FAILURE_CONSTRUCTORS = {
242246
BUILD_FAILURE: BuildFailure,
243247
JENKINS_FAILURE: JenkinsFailure,
244248
JS_TEST_FAILURE: JSTestFailure,
245-
CC_TEST_FAILURE: CCTestFailure
249+
CC_TEST_FAILURE: CCTestFailure,
250+
GIT_FAILURE: GitFailure
246251
};
247252
CIFailureParser.CIResult = CIResult;
248253
module.exports = CIFailureParser;

test/fixtures/jenkins/jenkins-failure-1/expected.json renamed to test/fixtures/jenkins/git-failure-1/expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"source": "https://github.com/nodejs/node/pull/21273/",
44
"upstream": "https://ci.nodejs.org/job/node-test-pull-request/15449/",
5-
"type": "JENKINS_FAILURE",
5+
"type": "GIT_FAILURE",
66
"url": "https://ci.nodejs.org/job/node-test-commit-linuxone/label=rhel72-s390x/2220/console",
77
"reason": "ERROR: Error fetching remote repo 'origin'\nhudson.plugins.git.GitException: Failed to fetch from [email protected]:nodejs/node.git\n\tat hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:889)\n\tat hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1146)\n\tat hudson.plugins.git.GitSCM.checkout(GitSCM.java:1177)\n\tat hudson.scm.SCM.checkout(SCM.java:504)",
88
"highlight": 0,
File renamed without changes.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
19:15:49 Started by upstream project "node-test-commit-linuxone" build number 3915
2+
19:15:49 originally caused by:
3+
19:15:49 Started by upstream project "node-test-commit" build number 20504
4+
19:15:49 originally caused by:
5+
19:15:49 Started by upstream project "node-test-pull-request" build number 16429
6+
19:15:49 originally caused by:
7+
19:15:49 Started by user mscdex
8+
19:15:49 [EnvInject] - Loading node environment variables.
9+
19:15:50 Building remotely on test-linuxonecc-rhel72-s390x-3 (rhel72-s390x v8test2) in workspace /data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x
10+
19:15:50 > git rev-parse --is-inside-work-tree # timeout=10
11+
19:15:50 Fetching changes from the remote Git repository
12+
19:15:50 > git config remote.origin.url [email protected]:nodejs/node.git # timeout=10
13+
19:15:50 Fetching upstream changes from [email protected]:nodejs/node.git
14+
19:15:50 > git --version # timeout=10
15+
19:15:50 using GIT_SSH to set credentials
16+
19:15:50 > git fetch --no-tags --progress [email protected]:nodejs/node.git +refs/heads/*:refs/remotes/origin/* +refs/pull/22273/head:refs/remotes/origin/_jenkins_local_branch # timeout=20
17+
19:15:54 Checking out Revision f6438c66a065bc2a43f24f636e46e688ae0f4eee (refs/remotes/origin/_jenkins_local_branch)
18+
19:15:54 > git config core.sparsecheckout # timeout=10
19+
19:15:54 > git checkout -f f6438c66a065bc2a43f24f636e46e688ae0f4eee
20+
19:15:54 Commit message: "fixup: remove branch entirely instead of asserting"
21+
19:15:54 > git rev-list --no-walk 4757c91dc4e270aed9add3a65d3aa32a7b24a479 # timeout=10
22+
19:15:55 Cleaning workspace
23+
19:15:55 > git rev-parse --verify HEAD # timeout=10
24+
19:15:55 Resetting working tree
25+
19:15:55 > git reset --hard # timeout=10
26+
19:15:55 > git clean -fdx # timeout=10
27+
19:15:56 Exporting environment variable NODEJS_VERSION with Node.js version '11.0.0'
28+
19:15:56 Exporting environment variable NODEJS_MAJOR_VERSION with Node.js major version '11'
29+
19:15:56 Exporting parameter NODEJS_VERSION with Node.js version '11.0.0'
30+
19:15:56 Exporting parameter NODEJS_MAJOR_VERSION with Node.js major version '11'
31+
19:15:56 [rhel72-s390x] $ /bin/sh -xe /tmp/jenkins7325057057705257195.sh
32+
19:15:56 + curl https://raw.githubusercontent.com/nodejs/build/master/jenkins/scripts/node-test-commit-pre.sh
33+
19:15:56 + bash -ex -s before
34+
19:15:56 % Total % Received % Xferd Average Speed Time Time Time Current
35+
19:15:56 Dload Upload Total Spent Left Speed
36+
19:15:57
37+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
38+
100 1165 100 1165 0 0 4034 0 --:--:-- --:--:-- --:--:-- 4045
39+
19:15:57 + git --version
40+
19:15:57 git version 1.8.3.1
41+
19:15:57 + git config --replace-all user.name Dummy
42+
19:15:57 + git config --replace-all user.email [email protected]
43+
19:15:57 + git config user.name
44+
19:15:57 Dummy
45+
19:15:57 + git config user.email
46+
47+
19:15:57 + echo
48+
19:15:57
49+
19:15:57 + echo
50+
19:15:57
51+
19:15:57 + git rebase --abort
52+
19:15:57 No rebase in progress?
53+
19:15:57 + true
54+
19:15:57 + git checkout -f refs/remotes/origin/_jenkins_local_branch
55+
19:15:57 HEAD is now at f6438c6... fixup: remove branch entirely instead of asserting
56+
19:15:57 + git config user.name
57+
19:15:57 Dummy
58+
19:15:57 + git config user.email
59+
60+
19:15:57 + echo
61+
19:15:57
62+
19:15:57 + echo
63+
19:15:57
64+
19:15:57 + git status
65+
19:15:57 # HEAD detached at f6438c6
66+
19:15:57 # Changes not staged for commit:
67+
19:15:57 # (use "git add <file>..." to update what will be committed)
68+
19:15:57 # (use "git checkout -- <file>..." to discard changes in working directory)
69+
19:15:57 #
70+
19:15:57 # modified: deps/v8/third_party/jinja2/LICENSE
71+
19:15:57 #
72+
19:15:57 # Untracked files:
73+
19:15:57 # (use "git add <file>..." to include in what will be committed)
74+
19:15:57 #
75+
19:15:57 # build/
76+
19:15:57 no changes added to commit (use "git add" and/or "git commit -a")
77+
19:15:57 + git rev-parse HEAD
78+
19:15:57 f6438c66a065bc2a43f24f636e46e688ae0f4eee
79+
19:15:57 + git rev-parse 78584b64d88c0567c46e3cf7bae42aa73927df40
80+
19:15:57 78584b64d88c0567c46e3cf7bae42aa73927df40
81+
19:15:57 + '[' -n 78584b64d88c0567c46e3cf7bae42aa73927df40 ']'
82+
19:15:57 + git rebase --committer-date-is-author-date 78584b64d88c0567c46e3cf7bae42aa73927df40
83+
19:15:57 Cannot rebase: You have unstaged changes.
84+
19:15:58 Please commit or stash them.
85+
19:15:58 Build step 'Execute shell' marked build as failure
86+
19:15:58 Recording test results
87+
19:15:58 ERROR: Step ‘Publish JUnit test result report’ failed: No test report files were found. Configuration error?
88+
19:15:58 Sending e-mails to: [email protected] [email protected]
89+
19:16:00 Notifying upstream projects of job completion
90+
19:16:00 Finished: FAILURE
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"url": "https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel72-s390x/3915/console",
3+
"builtOn": "test-linuxonecc-rhel72-s390x-3",
4+
"reason": "Changes not staged for commit:\n19:15:57 # (use \"git add <file>...\" to update what will be committed)\n19:15:57 # (use \"git checkout -- <file>...\" to discard changes in working directory)\n19:15:57 #\n19:15:57 #\tmodified: deps/v8/third_party/jinja2/LICENSE\n19:15:57 #\n19:15:57 # Untracked files:\n19:15:57 # (use \"git add <file>...\" to include in what will be committed)\n19:15:57 #\n19:15:57 #\tbuild/\n19:15:57 no changes added to commit",
5+
"highlight": 0,
6+
"type": "GIT_FAILURE"
7+
}

0 commit comments

Comments
 (0)