Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GraphDeployer
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
backend
scripts
GraphDeployer
Commits
2e7f15c8
Commit
2e7f15c8
authored
10 months ago
by
Petar Hristov
Browse files
Options
Downloads
Plain Diff
Merge branch 'test_ci' into 'master'
New: Color console output See merge request
!33
parents
d36a63d1
ba242c76
No related branches found
No related tags found
1 merge request
!33
New: Color console output
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/GraphDeployer/Deployer.cs
+24
-12
24 additions, 12 deletions
src/GraphDeployer/Deployer.cs
src/GraphDeployer/appsettings.json
+2
-2
2 additions, 2 deletions
src/GraphDeployer/appsettings.json
src/GraphDeployer/nlog.config
+4
-1
4 additions, 1 deletion
src/GraphDeployer/nlog.config
with
30 additions
and
15 deletions
src/GraphDeployer/Deployer.cs
+
24
−
12
View file @
2e7f15c8
...
@@ -19,6 +19,15 @@ public class Deployer
...
@@ -19,6 +19,15 @@ public class Deployer
private
readonly
GraphDeployerConfiguration
_graphDeployerConfiguration
;
private
readonly
GraphDeployerConfiguration
_graphDeployerConfiguration
;
private
readonly
AdminApi
_adminApi
;
private
readonly
AdminApi
_adminApi
;
// Define ANSI escape codes for colors
private
const
string
_esc
=
"\u001b"
;
// ANSI escape character
private
const
string
_r
=
$"
{
_esc
}
[91m"
;
private
const
string
_gb
=
$"
{
_esc
}
[1;92m"
;
private
const
string
_y
=
$"
{
_esc
}
[93m"
;
private
const
string
_bb
=
$"
{
_esc
}
[1;94m"
;
private
const
string
_c
=
$"
{
_esc
}
[96m"
;
private
const
string
_0
=
$"
{
_esc
}
[0m"
;
public
Deployer
(
ILogger
<
Deployer
>
logger
,
IOptionsMonitor
<
GraphDeployerConfiguration
>
graphDeployerConfiguration
)
public
Deployer
(
ILogger
<
Deployer
>
logger
,
IOptionsMonitor
<
GraphDeployerConfiguration
>
graphDeployerConfiguration
)
{
{
_logger
=
logger
;
_logger
=
logger
;
...
@@ -35,7 +44,7 @@ public class Deployer
...
@@ -35,7 +44,7 @@ public class Deployer
// Check if the graph deployer has to skip SSL checks when connecting to the API
// Check if the graph deployer has to skip SSL checks when connecting to the API
if
(
_graphDeployerConfiguration
.
SkipSslCheck
)
if
(
_graphDeployerConfiguration
.
SkipSslCheck
)
{
{
_logger
.
LogInformation
(
"Skipping SSL certificate validation...
"
);
_logger
.
LogInformation
(
"
{y}
Skipping SSL certificate validation...
{res}"
,
_y
,
_0
);
// Skip SSL certificate validation
// Skip SSL certificate validation
apiClientConfig
.
RemoteCertificateValidationCallback
=
(
_
,
_
,
_
,
_
)
=>
true
;
apiClientConfig
.
RemoteCertificateValidationCallback
=
(
_
,
_
,
_
,
_
)
=>
true
;
}
}
...
@@ -62,9 +71,12 @@ public class Deployer
...
@@ -62,9 +71,12 @@ public class Deployer
// Log the current application execution mode
// Log the current application execution mode
if
(
opts
.
DummyMode
)
if
(
opts
.
DummyMode
)
{
{
_logger
.
LogInformation
(
"Running in Dummy Mode. No changes will be made."
);
_logger
.
LogInformation
(
"{y}Running in Dummy Mode. No changes will be made.{r}"
,
_y
,
_0
);
}
if
(
opts
.
Redeploy
)
{
_logger
.
LogInformation
(
"{y}Redeploying all graphs.{r}"
,
_y
,
_0
);
}
}
_logger
.
LogDebug
(
"Redeploy: {redeploy}"
,
opts
.
Redeploy
);
// Override the working folder if specified in the configuration
// Override the working folder if specified in the configuration
if
(!
string
.
IsNullOrWhiteSpace
(
_graphDeployerConfiguration
.
WorkingFolder
))
if
(!
string
.
IsNullOrWhiteSpace
(
_graphDeployerConfiguration
.
WorkingFolder
))
...
@@ -79,7 +91,7 @@ public class Deployer
...
@@ -79,7 +91,7 @@ public class Deployer
// Iterate over the repositories and deploy the graphs
// Iterate over the repositories and deploy the graphs
foreach
(
var
graphRepo
in
_graphDeployerConfiguration
.
GitLab
.
Repositories
)
foreach
(
var
graphRepo
in
_graphDeployerConfiguration
.
GitLab
.
Repositories
)
{
{
_logger
.
LogInformation
(
"Working with {repoName}
"
,
graphRepo
.
Name
);
_logger
.
LogInformation
(
"Working with
{bb}
{repoName}
{res}..."
,
_bb
,
graphRepo
.
Name
,
_0
);
// Clone the repository inside the Working Folder
// Clone the repository inside the Working Folder
var
success
=
CloneRepo
(
graphRepo
.
Url
,
WorkingFolder
,
_graphDeployerConfiguration
.
GitLab
.
Token
,
graphRepo
.
Ref
);
var
success
=
CloneRepo
(
graphRepo
.
Url
,
WorkingFolder
,
_graphDeployerConfiguration
.
GitLab
.
Token
,
graphRepo
.
Ref
);
...
@@ -111,10 +123,10 @@ public class Deployer
...
@@ -111,10 +123,10 @@ public class Deployer
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
_logger
.
LogError
(
"Failed to load and process Turtle file: \"{file}\". Error: {errorMessage}"
,
file
,
e
.
Message
);
_logger
.
LogError
(
"Failed to load and process Turtle file: \"{
r}{
file}
{res}
\". Error: {errorMessage}"
,
_r
,
file
,
_0
,
e
.
Message
);
}
}
});
});
_logger
.
LogDebug
(
"Accumulated {count} graphs for possible deployment."
,
graphAccumulation
.
Count
);
_logger
.
LogDebug
(
"Accumulated
{c}
{count}
{res}
graphs for possible deployment."
,
_c
,
graphAccumulation
.
Count
,
_0
);
// Iterate over the accumulated graphs and deploy them
// Iterate over the accumulated graphs and deploy them
foreach
(
var
kv
in
graphAccumulation
)
foreach
(
var
kv
in
graphAccumulation
)
...
@@ -124,7 +136,7 @@ public class Deployer
...
@@ -124,7 +136,7 @@ public class Deployer
var
graphId
=
kv
.
Key
.
ToString
();
var
graphId
=
kv
.
Key
.
ToString
();
var
currentRun
=
new
Dictionary
<
string
,
string
>();
var
currentRun
=
new
Dictionary
<
string
,
string
>();
_logger
.
LogDebug
(
"Deploying graph: {graphName}
"
,
graphId
);
_logger
.
LogDebug
(
"Deploying graph:
{c}
{graphName}
{res}"
,
_c
,
graphId
,
_0
);
// Get the hash of the currently deployed graph and compare it with the hash of the graph to be deployed
// Get the hash of the currently deployed graph and compare it with the hash of the graph to be deployed
files
.
ForEach
((
path
)
=>
currentRun
.
TryAdd
(
graphId
,
HashUtil
.
GetFileHash
(
path
)));
files
.
ForEach
((
path
)
=>
currentRun
.
TryAdd
(
graphId
,
HashUtil
.
GetFileHash
(
path
)));
...
@@ -134,10 +146,10 @@ public class Deployer
...
@@ -134,10 +146,10 @@ public class Deployer
if
(
hasChanged
)
if
(
hasChanged
)
{
{
_logger
.
LogDebug
(
"The graph has changed"
);
_logger
.
LogDebug
(
"The graph has changed
.
"
);
}
else
}
else
{
{
_logger
.
LogDebug
(
"The graph has not changed"
);
_logger
.
LogDebug
(
"The graph has not changed
.
"
);
}
}
if
(
deployedGraph
is
null
)
if
(
deployedGraph
is
null
)
...
@@ -177,12 +189,12 @@ public class Deployer
...
@@ -177,12 +189,12 @@ public class Deployer
});
});
}
}
_logger
.
LogInformation
(
"Deployed {graphName}
successfully
."
,
graphId
);
_logger
.
LogInformation
(
"Deployed
{c}
{graphName}
{res} {gb}
successfully
{res}."
,
_c
,
graphId
,
_0
,
_gb
,
_0
);
DeployedGraphs
.
Add
(
graphId
);
DeployedGraphs
.
Add
(
graphId
);
}
}
else
else
{
{
_logger
.
LogDebug
(
"Skipped {graphName} as it has not changed."
,
graphId
);
_logger
.
LogDebug
(
"Skipped
{c}
{graphName}
{res}
as it has not changed."
,
_c
,
graphId
,
_0
);
SkippedGraphs
.
Add
(
graphId
);
SkippedGraphs
.
Add
(
graphId
);
continue
;
continue
;
}
}
...
@@ -230,7 +242,7 @@ public class Deployer
...
@@ -230,7 +242,7 @@ public class Deployer
// Retrieve the reference of the repository, either the branch name or the commit hash
// Retrieve the reference of the repository, either the branch name or the commit hash
var
repoRef
=
localRepo
.
Head
.
IsTracking
?
localRepo
.
Head
.
FriendlyName
:
localRepo
.
Head
.
Tip
.
Sha
;
var
repoRef
=
localRepo
.
Head
.
IsTracking
?
localRepo
.
Head
.
FriendlyName
:
localRepo
.
Head
.
Tip
.
Sha
;
_logger
.
LogInformation
(
"Repository successfully cloned and switched on ref \"{
ref
}\"."
,
repoRef
);
_logger
.
LogInformation
(
"Repository successfully cloned and switched on ref \"{
c}{ref}{res
}\"."
,
_c
,
repoRef
,
_0
);
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/GraphDeployer/appsettings.json
+
2
−
2
View file @
2e7f15c8
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
"IsEnabled"
:
true
,
"IsEnabled"
:
true
,
"WorkingFolder"
:
"./Output/"
,
"WorkingFolder"
:
"./Output/"
,
"Logger"
:
{
"Logger"
:
{
"LogLevel"
:
"
Debug
"
,
"LogLevel"
:
"
Information
"
,
"LogHome"
:
"./Logs"
"LogHome"
:
"./Logs"
},
},
"GitLab"
:
{
"GitLab"
:
{
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
"Token"
:
null
,
"Token"
:
null
,
"Repositories"
:
[
"Repositories"
:
[
{
{
"Name"
:
"
Application
Profiles"
,
"Name"
:
"
Metadata
Profiles"
,
"Url"
:
"https://git.rwth-aachen.de/coscine/graphs/applicationprofiles.git"
"Url"
:
"https://git.rwth-aachen.de/coscine/graphs/applicationprofiles.git"
},
},
{
{
...
...
This diff is collapsed.
Click to expand it.
src/GraphDeployer/nlog.config
+
4
−
1
View file @
2e7f15c8
...
@@ -8,8 +8,11 @@
...
@@ -8,8 +8,11 @@
<
variable
name
=
"logHome"
value
=
"${basedir}/Logs"
/>
<
variable
name
=
"logHome"
value
=
"${basedir}/Logs"
/>
<
variable
name
=
"logLevel"
value
=
"Warn"
/>
<
variable
name
=
"logLevel"
value
=
"Warn"
/>
<!--
This
variable
is
used
to
remove
ANSI
escape
codes
from
the
log
message
. -->
<
variable
name
=
"message_raw"
value
=
"${replace:inner=${message}:searchFor=\x1B\[[0-9;]*[A-Za-z]:replaceWith=:regex=true}"
/>
<!--
Possible
aspnet
-
variables
:
https
://
nlog
-
project
.
org
/
config
/?
tab
=
layout
-
renderers
&
search
=
package
:
nlog
.
web
-->
<!--
Possible
aspnet
-
variables
:
https
://
nlog
-
project
.
org
/
config
/?
tab
=
layout
-
renderers
&
search
=
package
:
nlog
.
web
-->
<
variable
name
=
"layout"
value
=
"${longdate} | [${level:uppercase=true}] ${message} ${exception:format=tostring}"
/>
<
variable
name
=
"layout"
value
=
"${longdate} | [${level:uppercase=true}] ${message
_raw
} ${exception:format=tostring}"
/>
<
targets
>
<
targets
>
<!--
Write
logs
to
File
-->
<!--
Write
logs
to
File
-->
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment