Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .smalltalk.ston
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SmalltalkCISpec {
#preLoading : 'script/lock-moose.st',
#loading : [
SCIMetacelloLoadSpec {
#baseline : 'MooseCI',
Expand All @@ -10,4 +11,4 @@ SmalltalkCISpec {
#preTesting : SCICustomScript {
#path : 'script/smalltalkci-verveinej.st'
}
}
}
5 changes: 4 additions & 1 deletion docker/mooseci-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ set -e
GROUP="${1:-default}"

echo "Installing MooseCI ($GROUP group) in the image..."
./pharo --headless Moose13/Moose13.image eval --save "Metacello new baseline: 'MooseCI'; repository: 'github://moosetechnology/MooseCI:master/src'; load: #('$GROUP')."
# Lock the image's own Famix and MooseIDE first: the Moose image registers them but not as
# loaded, so dependencies that ask for them from their development branches would otherwise
# reload part of them and mix two versions (same as script/lock-moose.st for smalltalkCI).
./pharo --headless Moose13/Moose13.image eval --save "Metacello new baseline: 'Famix'; repository: 'github://moosetechnology/Famix:development/src'; lock. Metacello new baseline: 'MooseIDE'; repository: 'github://moosetechnology/MooseIDE:development/src'; lock. Metacello new baseline: 'MooseCI'; repository: 'github://moosetechnology/MooseCI:master/src'; load: #('$GROUP')."
9 changes: 7 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ You can configure the output in `moose-ci.ston`:
After the report, `analyze` lists every file it wrote, relative to the project:

```
Generating report...
Generating visualizations...
Generating report...
Files
.moose-ci/report/report-<TIMESTAMP>.json
.moose-ci/report/report-<TIMESTAMP>.html
.moose-ci/report/visualizations/1-dsm-packages.svg
```

`Generating visualizations...` is only printed when the config has [visualizations](#visualizations).
`Generating visualizations...` is only printed when the config has [visualizations](#visualizations). They are generated first, so that the reports can include them.

## Rules

Expand Down Expand Up @@ -154,6 +154,11 @@ These are the settings of the MooseIDE browsers.

The SVG files are written to `<outputPath>/visualizations/<N>-<view>-<of>.svg`, where `<N>` is the position of the entry in the list, for example `.moose-ci/report/visualizations/1-dsm-packages.svg`.

The reports include them too:

- the JSON report lists them under `visualizations`, each with a `title` (for example `DSM of classes in .*\.ui\..*`) and its `file`, relative to the report folder;
- the HTML report shows them between the summary and the issues, with a link to open each one at full size. The SVGs are embedded in the page, so the HTML report is still a single file.

An entry whose view cannot show the selected entities is skipped, with a message in the console. If `#in` matches nothing, the SVG is written but empty: check the regex against the mooseNames.

> **Architectural map:** only the selected entities that have no parent among the selected entities are drawn, and their children are folded. If you select all packages, the map shows a single node: the top package. Select the packages *inside* it instead, for example `#in : 'example\\..+'`.
Expand Down
9 changes: 8 additions & 1 deletion docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

## Installation

Load Moose-CI in a Moose image with Metacello. The `default` group installs the core of Moose-CI with Java support:
Load Moose-CI in a Moose image with Metacello. First lock the Famix and MooseIDE of the image: the Moose image registers them but not as loaded, and some dependencies ask for them from their `development` branches, so they would be partly reloaded and two versions would be mixed.

```smalltalk
Metacello new baseline: 'Famix'; repository: 'github://moosetechnology/Famix:development/src'; lock.
Metacello new baseline: 'MooseIDE'; repository: 'github://moosetechnology/MooseIDE:development/src'; lock.
```

Then load the `default` group, which installs the core of Moose-CI with Java support:

```smalltalk
Metacello new
Expand Down
1 change: 1 addition & 0 deletions ressources/html-report/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The page shown by the HTML report. Open `index.html` directly in a browser to pr
- `summary.js`: header and measures
- `facets.js`: severity and rule filters
- `issues.js`: issue list, grouped by category and rule
- `visualizations.js`: the exported visualizations (SVGs embedded in the report data), hidden when there are none
- `theme.js`: light and dark toggle
- `main.js`: entry point
- `sample-report.js`: sample data for development only. It is not part of the generated report.
Expand Down
6 changes: 6 additions & 0 deletions ressources/html-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<dl class="measures" id="measures"></dl>
</section>

<section class="visualizations" id="visualizations" aria-label="Visualizations" hidden>
<h2 class="category-title">Visualizations</h2>
<div class="visualization-list" id="visualization-list"></div>
</section>

<section class="issues" aria-label="Issues">
<aside class="facets" id="facets"></aside>
<div class="issue-list">
Expand All @@ -44,6 +49,7 @@
<script src="js/summary.js"></script>
<script src="js/facets.js"></script>
<script src="js/issues.js"></script>
<script src="js/visualizations.js"></script>
<script src="js/theme.js"></script>
<script src="js/main.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions ressources/html-report/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
return;
}
R.renderSummary();
R.renderVisualizations();
R.render();
})(window.MooseCIReport = window.MooseCIReport || {});
42 changes: 42 additions & 0 deletions ressources/html-report/js/visualizations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Visualizations exported by MooseCI (DSM, architectural map...), shown between the summary and the issues.
// The SVG is displayed through an <img>, so nothing in it runs or styles the page.
(function (R) {
'use strict';

function svgUrl(svg) {
return URL.createObjectURL(new Blob([svg], { type: 'image/svg+xml' }));
}

function renderVisualization(visualization) {
var url = svgUrl(visualization.svg);
var figure = R.el('figure', 'visualization');

var caption = R.el('figcaption', 'visualization-caption');
caption.appendChild(R.el('span', 'visualization-title', visualization.title));
var open = R.el('a', 'visualization-open', 'Open full size');
open.href = url;
open.target = '_blank';
open.rel = 'noopener';
caption.appendChild(open);
figure.appendChild(caption);

var image = R.el('img', 'visualization-image');
image.src = url;
image.alt = visualization.title;
figure.appendChild(image);
return figure;
}

R.renderVisualizations = function () {
var visualizations = (R.state.report.visualizations || []).filter(function (visualization) {
return visualization.svg;
});
var section = document.getElementById('visualizations');
var list = document.getElementById('visualization-list');
R.clear(list);
section.hidden = visualizations.length === 0;
visualizations.forEach(function (visualization) {
list.appendChild(renderVisualization(visualization));
});
};
})(window.MooseCIReport = window.MooseCIReport || {});
47 changes: 47 additions & 0 deletions ressources/html-report/report.css
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,50 @@ input {
font-size: 13px;
font-weight: 400;
}

/* Visualizations */

.visualizations {
margin-bottom: 24px;
}

.visualization-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
gap: 16px;
}

.visualization {
margin: 0;
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
}

.visualization-caption {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
padding: 8px 12px;
border-bottom: 1px solid var(--border);
}

.visualization-title {
font-weight: 600;
overflow-wrap: anywhere;
}

.visualization-open {
flex-shrink: 0;
color: var(--accent);
font-size: 12px;
}

.visualization-image {
display: block;
width: 100%;
max-height: 480px;
object-fit: contain;
}
12 changes: 12 additions & 0 deletions ressources/html-report/sample-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,17 @@ window.MooseCIReport.sampleReport = {
}
]
}
],
"visualizations": [
{
"title": "DSM of packages",
"file": "visualizations/1-dsm-packages.svg",
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"240\" height=\"160\" viewBox=\"0 0 240 160\"><rect width=\"240\" height=\"160\" fill=\"#1f2433\"/><g font-family=\"sans-serif\" font-size=\"11\" fill=\"#fff\"><text x=\"10\" y=\"70\">ui</text><text x=\"10\" y=\"100\">domain</text><text x=\"10\" y=\"130\">infra</text></g><g stroke=\"#555\"><rect x=\"70\" y=\"55\" width=\"30\" height=\"30\" fill=\"#2e3a55\"/><rect x=\"100\" y=\"55\" width=\"30\" height=\"30\" fill=\"#f0736a\"/><rect x=\"130\" y=\"55\" width=\"30\" height=\"30\" fill=\"#2e3a55\"/><rect x=\"70\" y=\"85\" width=\"30\" height=\"30\" fill=\"#2e3a55\"/><rect x=\"100\" y=\"85\" width=\"30\" height=\"30\" fill=\"#2e3a55\"/><rect x=\"130\" y=\"85\" width=\"30\" height=\"30\" fill=\"#6ea8eb\"/><rect x=\"70\" y=\"115\" width=\"30\" height=\"30\" fill=\"#2e3a55\"/><rect x=\"100\" y=\"115\" width=\"30\" height=\"30\" fill=\"#2e3a55\"/><rect x=\"130\" y=\"115\" width=\"30\" height=\"30\" fill=\"#2e3a55\"/></g></svg>"
},
{
"title": "Architectural map of packages in example\\..+",
"file": "visualizations/2-architecturalMap-packages.svg",
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"300\" height=\"140\" viewBox=\"0 0 300 140\"><rect width=\"300\" height=\"140\" fill=\"#1f2433\"/><g fill=\"#2e3a55\" stroke=\"#fff\" stroke-dasharray=\"6 4\"><rect x=\"120\" y=\"10\" width=\"60\" height=\"30\"/><rect x=\"30\" y=\"95\" width=\"90\" height=\"30\"/><rect x=\"180\" y=\"95\" width=\"80\" height=\"30\"/></g><g stroke=\"#fff\"><line x1=\"140\" y1=\"40\" x2=\"80\" y2=\"95\"/><line x1=\"160\" y1=\"40\" x2=\"220\" y2=\"95\"/></g><g font-family=\"sans-serif\" font-size=\"14\" fill=\"#fff\"><text x=\"140\" y=\"30\">ui</text><text x=\"50\" y=\"115\">domain</text><text x=\"205\" y=\"115\">infra</text></g></svg>"
}
]
};
6 changes: 6 additions & 0 deletions script/lock-moose.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
" Keeps the Famix and MooseIDE of the Moose image when MooseCI is loaded.
A Moose image registers them but not as loaded, so a dependency that asks for them
(DependencyConstraint asks for MooseIDE and Famix from their development branches)
would reload part of them and mix two versions. Locked, they are not loaded again. "
Metacello new baseline: 'Famix'; repository: 'github://moosetechnology/Famix:development/src'; lock.
Metacello new baseline: 'MooseIDE'; repository: 'github://moosetechnology/MooseIDE:development/src'; lock.
14 changes: 9 additions & 5 deletions src/MooseCI-CLI/MooseCIRunner.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,23 @@ MooseCIRunner >> writeOutput [

{ #category : 'writing' }
MooseCIRunner >> writeOutputOn: aStream [
"The visualizations are generated before the report files: the HTML report shows them"

| reporter files |
| reporter visualizations files |
reporter := mooseCICore analysisReport.
MCIConsoleReportWriter new
report: reporter;
writeOn: aStream.

self writeStep: 'Generating report...' on: aStream.
files := reporter writeFiles asOrderedCollection.

visualizations := #( ).
(mooseCICore config visualizations ifNil: [ #( ) ]) ifNotEmpty: [
self writeStep: 'Generating visualizations...' on: aStream.
files addAll: (mooseCICore writeVisualizationsIn: reporter outputDirectory / 'visualizations') ].
visualizations := mooseCICore exportVisualizationsIn: reporter outputDirectory / 'visualizations'.
reporter visualizations: visualizations ].

self writeStep: 'Generating report...' on: aStream.
files := reporter writeFiles asOrderedCollection.
files addAll: (visualizations collect: [ :each | each value ]).

self writeFileList: files on: aStream
]
Expand Down
35 changes: 21 additions & 14 deletions src/MooseCI-Core/MooseCICore.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ MooseCICore >> detectProjectLanguage: aDirectoryOrFileReference [
config projectLanguage: (MooseCILanguageDetector detect: aDirectoryOrFileReference) primary
]

{ #category : 'writing' }
MooseCICore >> exportVisualizationsIn: aDirectory [
"Answer each exported visualization -> its SVG file: a visualization whose view cannot show its entities is skipped"

| exported |
exported := OrderedCollection new.
(config visualizations ifNil: [ #( ) ]) withIndexDo: [ :entry :index |
| visualization file |
visualization := MCIVisualization fromDictionary: entry.
file := aDirectory / (index printString , '-' , visualization fileName).

(visualization canShowIn: self model)
ifTrue: [
visualization exportOn: self model to: file.
exported add: visualization -> file ]
ifFalse: [ ('Visualization ' , index printString , ' skipped: the view cannot show these entities') traceCr ] ].
^ exported
]

{ #category : 'initialization' }
MooseCICore >> initialize [
metrics := OrderedDictionary new
Expand Down Expand Up @@ -147,19 +166,7 @@ MooseCICore >> violations: anObject [

{ #category : 'writing' }
MooseCICore >> writeVisualizationsIn: aDirectory [
"Answer the written files: a visualization whose view cannot show its entities is skipped"
"Answer the written files"

| files |
files := OrderedCollection new.
(config visualizations ifNil: [ #( ) ]) withIndexDo: [ :entry :index |
| visualization file |
visualization := MCIVisualization fromDictionary: entry.
file := aDirectory / (index printString , '-' , visualization fileName).

(visualization canShowIn: self model)
ifTrue: [
visualization exportOn: self model to: file.
files add: file ]
ifFalse: [ ('Visualization ' , index printString , ' skipped: the view cannot show these entities') traceCr ] ].
^ files
^ (self exportVisualizationsIn: aDirectory) collect: [ :each | each value ]
]
16 changes: 15 additions & 1 deletion src/MooseCI-Report/MCIAnalysisReport.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Class {
#instVars : [
'metrics',
'violations',
'config'
'config',
'visualizations'
],
#category : 'MooseCI-Report',
#package : 'MooseCI-Report'
Expand Down Expand Up @@ -71,6 +72,19 @@ MCIAnalysisReport >> violations: anObject [
violations := anObject
]

{ #category : 'accessing' }
MCIAnalysisReport >> visualizations [
"Each exported MCIVisualization -> its SVG file"

^ visualizations ifNil: [ #( ) ]
]

{ #category : 'accessing' }
MCIAnalysisReport >> visualizations: someVisualizationFileAssociations [

visualizations := someVisualizationFileAssociations
]

{ #category : 'writing' }
MCIAnalysisReport >> writeConsole [

Expand Down
15 changes: 10 additions & 5 deletions src/MooseCI-Report/MCIHTMLReportWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,17 @@ MCIHTMLReportWriter >> inlinedTemplateNamed: aPath closingTag: aTag [
^ contents
]

{ #category : 'private' }
{ #category : 'accessing' }
MCIHTMLReportWriter >> reportJson [

^ MCIJSONReportWriter new
report: self report;
jsonString
"The JSON report, plus the content of each SVG: the HTML report stays a single file"

| object |
object := (MCIJSONReportWriter new
report: self report;
yourself) jsonObject.
object at: 'visualizations' ifPresent: [ :someObjects |
someObjects with: self report visualizations do: [ :json :visualization | json at: 'svg' put: visualization value contents ] ].
^ STONJSON toStringPretty: object
]

{ #category : 'accessing' }
Expand Down
Loading
Loading