Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
876ae19d
Commit
876ae19d
authored
Sep 02, 2019
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creates utils for the job log
With the new job log json format we need a parser on the frontend
parent
f4e40c53
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
app/assets/javascripts/jobs/store/utils.js
app/assets/javascripts/jobs/store/utils.js
+40
-0
changelogs/unreleased/66454-utils-parser.yml
changelogs/unreleased/66454-utils-parser.yml
+5
-0
spec/frontend/jobs/store/utils_spec.js
spec/frontend/jobs/store/utils_spec.js
+60
-0
No files found.
app/assets/javascripts/jobs/store/utils.js
0 → 100644
View file @
876ae19d
/**
* Parses the job log content into a structure usable by the template
*
* For collaspible lines (section_header = true):
* - creates a new array to hold the lines that are collpasible,
* - adds a isClosed property to handle toggle
* - adds a isHeader property to handle template logic
* For each line:
* - adds the index as lineNumber
*
* @param {Array} lines
* @returns {Array}
*/
export
default
(
lines
=
[])
=>
lines
.
reduce
((
acc
,
line
,
index
)
=>
{
if
(
line
.
section_header
)
{
acc
.
push
({
isClosed
:
true
,
isHeader
:
true
,
line
:
{
...
line
,
lineNumber
:
index
,
},
lines
:
[],
});
}
else
if
(
acc
.
length
&&
acc
[
acc
.
length
-
1
].
isHeader
)
{
acc
[
acc
.
length
-
1
].
lines
.
push
({
...
line
,
lineNumber
:
index
,
});
}
else
{
acc
.
push
({
...
line
,
lineNumber
:
index
,
});
}
return
acc
;
},
[]);
changelogs/unreleased/66454-utils-parser.yml
0 → 100644
View file @
876ae19d
---
title
:
Creates utility parser for the job log
merge_request
:
32555
author
:
type
:
added
spec/frontend/jobs/store/utils_spec.js
0 → 100644
View file @
876ae19d
import
linesParser
from
'
~/jobs/store/utils
'
;
describe
(
'
linesParser
'
,
()
=>
{
const
mockData
=
[
{
offset
:
1001
,
content
:
[{
text
:
'
on docker-auto-scale-com 8a6210b8
'
}],
},
{
offset
:
1002
,
content
:
[
{
text
:
'
Using Docker executor with image dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.6.3-golang-1.11-git-2.22-chrome-73.0-node-12.x-yarn-1.16-postgresql-9.6-graphicsmagick-1.3.33
'
,
},
],
sections
:
[
'
prepare-executor
'
],
section_header
:
true
,
},
{
offset
:
1003
,
content
:
[{
text
:
'
Starting service postgres:9.6.14 ...
'
}],
sections
:
[
'
prepare-executor
'
],
},
{
offset
:
1004
,
content
:
[{
text
:
'
Pulling docker image postgres:9.6.14 ...
'
,
style
:
'
term-fg-l-green
'
}],
sections
:
[
'
prepare-executor
'
],
},
];
let
result
;
beforeEach
(()
=>
{
result
=
linesParser
(
mockData
);
});
describe
(
'
regular line
'
,
()
=>
{
it
(
'
adds a lineNumber property with correct index
'
,
()
=>
{
expect
(
result
[
0
].
lineNumber
).
toEqual
(
0
);
expect
(
result
[
1
].
line
.
lineNumber
).
toEqual
(
1
);
});
});
describe
(
'
collpasible section
'
,
()
=>
{
it
(
'
adds a `isClosed` property
'
,
()
=>
{
expect
(
result
[
1
].
isClosed
).
toEqual
(
true
);
});
it
(
'
adds a `isHeader` property
'
,
()
=>
{
expect
(
result
[
1
].
isHeader
).
toEqual
(
true
);
});
it
(
'
creates a lines array property with the content of the collpasible section
'
,
()
=>
{
expect
(
result
[
1
].
lines
.
length
).
toEqual
(
2
);
expect
(
result
[
1
].
lines
[
0
].
content
).
toEqual
(
mockData
[
2
].
content
);
expect
(
result
[
1
].
lines
[
1
].
content
).
toEqual
(
mockData
[
3
].
content
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment