Skip to content

Commit

Permalink
Merge pull request #56 from moosetechnology/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
badetitou authored Sep 16, 2024
2 parents 2957363 + a008241 commit aa0df2f
Show file tree
Hide file tree
Showing 80 changed files with 4,947 additions and 1,274 deletions.
7 changes: 4 additions & 3 deletions .smalltalk.ston
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ SmalltalkCISpec {
SCIMetacelloLoadSpec {
#baseline : 'GitLabHealth',
#directory : 'src',
#load : [ 'default', 'Jira' ],
#platforms : [ #pharo ],
#onConflict : #useIncoming,
#onConflict : #useLoaded,
#onUpgrade : #useIncoming
}
],
#testing: {
#packages : [ 'GitLab*', 'GLPH.*', 'GitHub.*' ],
#packages : [ 'GitLab*', 'GLPH.*', 'GitHub.*', 'GitProject.*' ],
#coverage : {
#packages : [ 'GitLab.*', 'GLPH.*', 'GitHub.*' ],
#packages : [ 'GitLab.*', 'GLPH.*', 'GitHub.*', 'GitProject.*' ],
#format : #lcov
}
}
Expand Down
51 changes: 41 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In the Moose image, in a playground (`Ctrl+O`, `Ctrl+W`), perform:
Metacello new
repository: 'github://moosetechnology/GitProjectHealth:main/src';
baseline: 'GitLabHealth';
onConflict: [ :ex | ex useIncoming ];
onConflict: [ :ex | ex useLoaded ];
onUpgrade: [ :ex | ex useIncoming ];
onDowngrade: [ :ex | ex useLoaded ];
load
Expand Down Expand Up @@ -103,16 +103,51 @@ Here is the metamodel used in this project

![GitProject meta-model png](https://raw.githubusercontent.com/moosetechnology/GitProjectHealth/v1/doc/gitproject.png)

## Connectors

This project comes with connectors to others metamodel to increase its powerfullness.

### Jira Connector

The Jira connector connect this project to the [Pharo Jira API project](https://github.com/Evref-BL/Jira-Pharo-API).
It basically looks for commit and merge request links to Jira Issue.

To install the connector, please perform:

```st
Metacello new
repository: 'github://moosetechnology/GitProjectHealth:main/src';
baseline: 'GitLabHealth';
onConflict: [ :ex | ex useIncoming ];
onUpgrade: [ :ex | ex useIncoming ];
onDowngrade: [ :ex | ex useLoaded ];
load: #( 'default' 'Jira' )
```

> loading default is optional if you already loaded it.
Then, it is possible to connect two models using

```st
GPJCConnector new
gpModel: aGpModel; "or glh model"
jiraModel: aJiraModel;
connect
```

### Famix Connector

> The project exists and some code already exists, but it is not released yet.
> Raise an issue if you want us to investigate more on this
## Contributor

This work has been first developed by the [research department of Berger-Levrault](https://www.research-bl.com/)

## Running metrics with docker

## Running metrics with docker
### Running locally

### running locally
```smalltalk
|glphModel glphApi glhImporter beforeExp duringExp usersWithProjects gme|
Expand Down Expand Up @@ -180,7 +215,6 @@ Smalltalk snapshot: true andQuit: true.
```

### deploying with docker


```bash
git clone https://github.com/moosetechnology/GitProjectHealth.git
Expand All @@ -190,13 +224,10 @@ git checkout GLPH-importer-new-changes
sudo docker build -t code-churn-pharo .
sudo docker run code-churn-pharo &
```
locate and retrieve csv output files:

Locate and retrieve csv output files:

```bash
sudo docker ps
sudo docker exec -it <container-id> find / -type f -name 'IA4Code*.csv' 2>/dev/null
```





72 changes: 61 additions & 11 deletions src/BaselineOfGitLabHealth/BaselineOfGitLabHealth.class.st
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Class {
#name : 'BaselineOfGitLabHealth',
#superclass : 'BaselineOf',
#category : 'BaselineOfGitLabHealth',
#package : 'BaselineOfGitLabHealth'
#name : #BaselineOfGitLabHealth,
#superclass : #BaselineOf,
#category : #BaselineOfGitLabHealth
}

{ #category : 'baselines' }
{ #category : #baselines }
BaselineOfGitLabHealth >> baseline: spec [

<baseline>
spec for: #common do: [
self defineDependencies: spec.
self definePackages: spec.
self defineGroups: spec.
self defineJiraConnector: spec.

spec for: #( #WithoutFamix ) do: [
spec
Expand All @@ -22,29 +22,79 @@ BaselineOfGitLabHealth >> baseline: spec [
spec package: 'GitLabHealth-Model' with: [ spec requires: #( 'Moose' ) ] ] ]
]

{ #category : 'baselines' }
{ #category : #baselines }
BaselineOfGitLabHealth >> customProjectAttributes [
self class environment at: #MooseEntity ifAbsent: [ ^ #(#WithoutFamix) ].

^ #()
]

{ #category : 'baselines' }
{ #category : #baselines }
BaselineOfGitLabHealth >> defineDependencies: spec [

spec
baseline: 'NeoJSON'
with: [ spec repository: 'github://svenvc/NeoJSON/repository' ].
spec
baseline: 'MoreLogger'
with: [ spec repository: 'github://badetitou/MoreLogger:main/src' ]
with: [ spec repository: 'github://badetitou/MoreLogger:main/src' ].
spec
baseline: 'Voyage'
with: [ spec
loads: #('mongo');
repository: 'github://pharo-nosql/voyage/mc' ].
spec
baseline: 'AWS'
with: [
spec repository: 'github://newapplesho/aws-sdk-smalltalk/pharo-repository'
]
]

{ #category : 'baselines' }
{ #category : #baselines }
BaselineOfGitLabHealth >> defineGroups: spec [

spec
group: 'Jira'
with:
#( 'GitProject-JiraConnector' 'GitProject-JiraConnector-Generator' 'GitProject-JiraConnector-Tests' ).
spec
group: 'Core'
with: #( 'GitLabHealth-Model' 'GitLabHealth-Model-Extension'
'GitLabHealth-Model-Extension-Tests'
'GitLabHealth-Model-Generator' 'GitLabHealth-Model-Inspector'
'GitLabHealth-Model-Visualization'
'GitLabHealth-Model-Importer' 'GitLabHealth-Model-Importer-Tests'
'GitHubHealth-Model-Importer-Tests'
'GLPHExtended-Model' 'GLPHExtended-Model-Tests'
'GLPHExtended-Model-Extension' 'GitLabHealth-Model-Analysis'
'GitLabHealth-Visualization' 'GitLabProjectHealth-ExtendModel-Generator'
'GitLabProjectHealth-Model-Importer'
'GitLabProjectHealth-Model-Importer-Tests' ).
spec group: 'default' with: #( 'Core' )
]

{ #category : #baselines }
BaselineOfGitLabHealth >> defineJiraConnector: spec [

spec
package: 'GitProject-JiraConnector-Model'
with: [ spec requires: #( 'JiraPharoAPI' ) ];
package: 'GitProject-JiraConnector' with: [
spec requires: #( 'GitProject-JiraConnector-Model'
'JiraPharoAPI' ) ];
package: 'GitProject-JiraConnector-Generator';
package: 'GitProject-JiraConnector-Tests' with: [
spec requires: #( 'GitProject-JiraConnector'
'JiraPharoAPI' ) ].

"dependency"
spec
baseline: 'JiraPharoAPI'
with: [
spec repository: 'github://Evref-BL/Jira-Pharo-API:main/src' ]
]

{ #category : 'baselines' }
{ #category : #baselines }
BaselineOfGitLabHealth >> definePackages: spec [
"generic"

Expand Down Expand Up @@ -83,7 +133,7 @@ BaselineOfGitLabHealth >> definePackages: spec [
package: 'GLPHExtended-Model-Extension' with: [
spec requires:
#( 'GLPHExtended-Model' 'GitLabHealth-Model' 'GitLabHealth-Model-Extension' ) ];
package: 'GitLabHealth-Model-Analysis';
package: 'GitLabHealth-Model-Analysis' with: [ spec requires: #( 'Voyage' 'AWS' ) ];
package: 'GitLabHealth-Model-Analysis-Tests'
with: [ spec requires: #( 'GitLabHealth-Model-Analysis' ) ];
package: 'GitLabHealth-Visualization';
Expand Down
2 changes: 1 addition & 1 deletion src/BaselineOfGitLabHealth/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : 'BaselineOfGitLabHealth' }
Package { #name : #BaselineOfGitLabHealth }
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"
A ClosedMergeRequestMetricTest is a test class for testing the behavior of ClosedMergeRequestMetric
"
Class {
#name : #ClosedMergeRequestMetricTest,
#superclass : #TestCase,
#category : #'GitLabHealth-Model-Analysis-Tests'
}

{ #category : #tests }
ClosedMergeRequestMetricTest >> testCalculate [

| result glhImporter user closedMergeRequestMetric |
"Given"
user := GLHUser new
username: 'test';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

glhImporter := GLPHImporterMock new.
glhImporter mergeRequests: {
(GLPHEMergeRequest new
author: user;
created_at: '09-05-2024';
merged_at: '09-05-2024';
state: 'closed').
(GLPHEMergeRequest new
author: user;
created_at: '09-05-2024';
merged_at: nil;
state: 'closed') }.


closedMergeRequestMetric := ClosedMergeRequestMetric new
user: user;
glhImporter: glhImporter;
setPeriodSince: '09-04-2024'
until: '09-04-2024';
over: Week.

"When"
result := closedMergeRequestMetric calculate.

"Then"
self assert: result equals: 1
]

{ #category : #tests }
ClosedMergeRequestMetricTest >> testCalculateNoMergeRequests [

| result glhImporter user closedMergeRequestMetric |
"Given"
user := GLHUser new
username: 'test';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

glhImporter := GLPHImporterMock new.

closedMergeRequestMetric := ClosedMergeRequestMetric new
user: user;
glhImporter: glhImporter;
setPeriodSince: '09-04-2024'
until: '09-04-2024';
over: Week.

"When"
result := closedMergeRequestMetric calculate.

"Then"
self assert: result equals: 0
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"
A ClosedTicketsMetricTest is a test class for testing the behavior of ClosedTicketsMetric
"
Class {
#name : #ClosedTicketsMetricTest,
#superclass : #TestCase,
#category : #'GitLabHealth-Model-Analysis-Tests'
}

{ #category : #tests }
ClosedTicketsMetricTest >> testCalculate [

| result glhImporter user closedTicket jiraImporter |
"Given"
user := GLHUser new
username: 'test';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

glhImporter := GLPHImporterMock new.
glhImporter mergeRequests: { (GLPHEMergeRequest new
author: user;
created_at: '09-05-2024';
title: '205 feat do something') }.

jiraImporter := JiraImporterMock new.
jiraImporter issues: { (JPIssue new key: '205') }.


closedTicket := ClosedTicketsMetric new
user: user;
glhImporter: glhImporter;
jiraImporter: jiraImporter;
setPeriodSince: '09-04-2024' until: '09-04-2024';
over: Week.

"When"
result := closedTicket calculate.

"Then"
self assert: result equals: 1
]
Loading

0 comments on commit aa0df2f

Please sign in to comment.