Skip to content

Commit

Permalink
Merge branch 'main' into GLPH-importer-new-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou authored Jun 14, 2024
2 parents ac34dd5 + 10a839f commit efdf48a
Show file tree
Hide file tree
Showing 25 changed files with 969 additions and 135 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci-moose11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
smalltalk: [ Moose64-11]
name: ${{ matrix.smalltalk }}
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: ${{ matrix.smalltalk }}

- run: smalltalkci -s ${{ matrix.smalltalk }}
shell: bash
timeout-minutes: 15

- name: Build meta-model planuml image
run: |
$SMALLTALK_CI_VM $SMALLTALK_CI_IMAGE st ./ci/generatePUML.st
- name: Generate PNG UML Diagrams
uses: Timmy/plantuml-action@v1
with:
args: -v -tpng gitproject.puml

- name: Move artifact
run: |
mkdir doc-uml
mv *.png doc-uml
- name: Init new repo in dist folder and commit generated files
run: |
cd doc-uml/
git init
git add -A
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m 'update doc'
# Careful, this can kill your project
- name: Force push to destination branch
uses: ad-m/[email protected]
with:
# Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
# Destination branch to push changes
branch: v1/doc
# We have to push from the folder where files were generated.
# Same were the new repo was initialized in the previous step
directory: ./doc-uml
14 changes: 0 additions & 14 deletions .gitlab-ci.yml

This file was deleted.

71 changes: 1 addition & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,76 +97,7 @@ canvas svgExporter

Here is the metamodel used in this project

```mermaid
classDiagram
class Group {
avatar_url
name
id
web_url
description
visibility
}
class Repository
class Branch {
name
}
class FileDirectory {
name
}
class Pipeline {
status
}
class FileBlob {
name
}
class File {
name
}
class Project {
creator_id
avatar_url
name
id
readme_url
web_url
archived
description
}
class User {
created_at
pronouns
twitter
linkedin
avatar_url
name
id
work_information
bot
job_title
public_email
following
web_url
bio
website_url
skype
username
state
followers
organization
location
}
File <|-- FileDirectory
File <|-- FileBlob
Group *-- Group : group
Repository *-- Branch : repository
Project *-- Pipeline : project
Branch *-- File : branch
FileDirectory *-- File : directoryOwner
Repository -- Project : repository
Group *-- Project : group
User -- Project : creator
```
![GitProject meta-model png](https://raw.githubusercontent.com/moosetechnology/GitProjectHealth/v1/doc/gitproject.png)



Expand Down
14 changes: 14 additions & 0 deletions ci/generatePUML.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
documentor := FamixUMLDocumentor new.
documentor
model: GLHModel;
beWithStubs;
excludeClasses: { GLHModel. TEntityMetaLevelDependency. Object . GLHEntity . GLHTEntityCreator };
generate.

'gitproject.puml' asFileReference writeStreamDo: [ :stream |
FamixUMLPlantUMLBackend new
outputStream: stream;
export: documentor umlEntities.
].

Smalltalk snapshot: false andQuit: true
18 changes: 9 additions & 9 deletions src/GitHubHealth-Model-Importer/GHModelImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,20 @@ GHModelImporter >> parsePipelinesResult: pipelineOverview [

| reader |
reader := NeoJSONReader on: pipelineOverview readStream.
reader for: GHAPIPipelineOverview do: [ :mapping |
reader for: GHAPIPipelineOverview do: [ :mapping |
mapping mapInstVar: #total_count to: #total_count.
(mapping mapInstVar: #workflow_runs) valueSchema: #ArrayOfPipelines ].
reader
for: #ArrayOfPipelines
customDo: [ :customMappting |
customDo: [ :customMappting |
customMappting listOfElementSchema: GLHPipeline ].
reader
for: GLHPipeline
do: [ :mapping |
mapping
mapInstVar: #status to: #conclusion ;
mapProperty: #run_started_at getter: [ :object | #ignore ] setter: [ :object : value | object runDate: (DateAndTime fromString: value) ]
].
reader for: GLHPipeline do: [ :mapping |
mapping
mapInstVar: #status to: #conclusion;
mapProperty: #run_started_at
getter: [ :object | #ignore ]
setter: [ :object :value |
object runDate: (DateAndTime fromString: value) ] ].
^ reader nextAs: GHAPIPipelineOverview
]

Expand Down
11 changes: 10 additions & 1 deletion src/GitLabHealth-Model-Extension/GLHCommit.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,14 @@ GLHCommit >> name [
{ #category : #'*GitLabHealth-Model-Extension' }
GLHCommit >> parent_ids [

^ parent_ids
^ parent_ids
]

{ #category : #'*GitLabHealth-Model-Extension' }
GLHCommit >> displayStringOn: aStream [

aStream
<< self short_id;
<< ' ';
<< self message
]
31 changes: 27 additions & 4 deletions src/GitLabHealth-Model-Generator/GLHMetamodelGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Class {
'fileDirectory',
'commit',
'commitStats',
'diff'
'diff',
'job'
],
#category : #'GitLabHealth-Model-Generator'
}
Expand Down Expand Up @@ -89,7 +90,9 @@ GLHMetamodelGenerator >> defineClasses [
commit := builder
newClassNamed: #Commit
comment: 'a commit attached to a repository'.
diff := builder newClassNamed: #Diff comment: 'The diff of a commit'
diff := builder newClassNamed: #Diff comment: 'The diff of a commit'.

job := builder newClassNamed: #Job comment: 'A CI Job'
]

{ #category : #definition }
Expand All @@ -104,7 +107,9 @@ GLHMetamodelGenerator >> defineHierarchy [
project --|> #TNamedEntity.
user --|> #TNamedEntity.
commit --|> #TNamedEntity.
diff --|> #TNamedEntity
diff --|> #TNamedEntity.
job --|> #TNamedEntity

]

{ #category : #definition }
Expand Down Expand Up @@ -134,12 +139,16 @@ GLHMetamodelGenerator >> defineProperties [
'#success or #failure'.
(pipeline property: #runDate type: #Object) comment:
'Date this pipeline was run'.
(pipeline property: #id type: #String) comment:
'The id of the pipeline'.


self userProperties.
self branchProperties.
self fileProperties.
self commitProperties.
self diffProperties
self diffProperties.
self jobProperties
]

{ #category : #definition }
Expand All @@ -161,6 +170,10 @@ GLHMetamodelGenerator >> defineRelations [
(commit property: #diffs) <>-* (diff property: #commit).
(user property: #commits) <>-* (commit property: #commitCreator).
(commit property: #parentCommits) *-* (commit property: #childCommits)
(commit property: #jobs) <>-* (job property: #commit).
(pipeline property: #jobs) <>-* (job property: #pipeline).
(user property: #jobs) <>-* (job property: #user)

]

{ #category : #definition }
Expand Down Expand Up @@ -192,6 +205,16 @@ GLHMetamodelGenerator >> fileProperties [
file property: #name type: #String
]

{ #category : #definition }
GLHMetamodelGenerator >> jobProperties [

job property: #id type: #Number.
job property: #allow_failure type: #Boolean.
job property: #web_url type: #String.
job property: #duration type: #Object.
job property: #allow_failure type: #Boolean
]

{ #category : #definition }
GLHMetamodelGenerator >> userProperties [
user property: #id type: #Number.
Expand Down
47 changes: 46 additions & 1 deletion src/GitLabHealth-Model-Importer/GLHApi.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GLHApi >> client: anObject [
]

{ #category : #'api - commits' }
GLHApi >> commit: commitSHA ofProject: aProjectId [
GLHApi >> commit: commitSHA ofProject: aProjectId withStat: stats [

self client path: (String streamContents: [ :str |
str
Expand All @@ -56,9 +56,29 @@ GLHApi >> commit: commitSHA ofProject: aProjectId [
<< commitSHA asString;
<< '' ]).


stats ifNotNil: [ self client queryAt: #stats put: stats ].

^ self client get
]

{ #category : #'api - commits' }
GLHApi >> commit: commitSHA ofProject: aProjectId [

self client path: (String streamContents: [ :str |
str
<< self baseAPIUrl;
<< '/projects/';
<< aProjectId asString;
<< '/repository/commits/';
<< commitSHA asString;
<< '' ]).

^ self client get
]



{ #category : #'api - commits' }
GLHApi >> commitDiff: commitSHA ofProject: aProjectId unidiff: unidiff [

Expand Down Expand Up @@ -200,6 +220,23 @@ GLHApi >> editProject: aProjectID usingDictionary: aDictionaryOfNewParam [
^ self client put
]

{ #category : #'api - repository files' }
GLHApi >> getFileBlameForProject: aProjectId andFilePath: aFilePath inRef: aRef fromLine: rangeStart toLine: rangeEnd [
"filePath is converted here. So give a path such as ""path/to/file.md"""

"https://docs.gitlab.com/ee/api/repository_files.html#get-file-blame-from-repository"

self client url:
self baseAPIUrl , '/projects/' , aProjectId printString
, '/repository/files/' , (aFilePath withoutPrefix: '/') urlEncoded
, '/blame'.
self client queryAt: #ref put: aRef.
self client queryAt: #'range[start]' put: rangeStart.
self client queryAt: #'range[end]' put: rangeEnd.

^ self client get
]

{ #category : #api }
GLHApi >> group: aGroupID [

Expand All @@ -214,6 +251,14 @@ GLHApi >> initialize [
yourself)
]

{ #category : #'api - jobs' }
GLHApi >> jobsOfProject: aProjectID ofPipelines: aPipelineID [

^ self client get:
self baseAPIUrl , '/projects/' , aProjectID printString
, '/pipelines/' , aPipelineID printString , '/jobs'
]

{ #category : #api }
GLHApi >> pipelinesOfProject: aProjectID [
^ self client get: self baseAPIUrl , '/projects/' , aProjectID printString, '/pipelines'
Expand Down
Loading

0 comments on commit efdf48a

Please sign in to comment.