Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Configuration
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
libraries
Configuration
Commits
021b99de
Commit
021b99de
authored
Jun 19, 2019
by
L. Ellenbeck
Browse files
Options
Downloads
Patches
Plain Diff
Build: upgraded build pipeline coscine/issues#122
parent
0208788d
No related branches found
No related tags found
2 merge requests
!9
Product/109 nuget
,
!8
Merge Topic into Product
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+3
-2
3 additions, 2 deletions
.gitignore
.gitlab-ci.yml
+21
-22
21 additions, 22 deletions
.gitlab-ci.yml
.releaserc
+1
-1
1 addition, 1 deletion
.releaserc
build.cake
+252
-186
252 additions, 186 deletions
build.cake
tools/packages.config
+4
-0
4 additions, 0 deletions
tools/packages.config
with
281 additions
and
211 deletions
.gitignore
+
3
−
2
View file @
021b99de
...
...
@@ -262,5 +262,6 @@ __pycache__/
*.pyc
#cake
tools/
tools/*
!tools/packages.config
dist/
This diff is collapsed.
Click to expand it.
.gitlab-ci.yml
+
21
−
22
View file @
021b99de
stages
:
-
build
-
test
...
...
@@ -10,12 +8,11 @@ stages:
-
release
build
:
before_script
:
-
PowerShell .\build.ps1 -Target Clean
-
PowerShell .\build.ps1 -Target Restore-NuGet-Packages
stage
:
build
script
:
-
PowerShell .\build.ps1 -Target Build
-
PowerShell .\build.ps1 -Target Build -Configuration Debug
variables
:
GIT_STRATEGY
:
clone
except
:
variables
:
-
$GITLAB_USER_ID == $GIT_BOT_USER_ID
...
...
@@ -23,15 +20,16 @@ build:
test
:
stage
:
test
script
:
-
PowerShell .\build.ps1 -Target Resharper
-
PowerShell .\build.ps1 -Target Run-Unit-Tests
-
PowerShell .\build.ps1 -Target LinterAndTest -Configuration Debug
variables
:
GIT_STRATEGY
:
none
dependencies
:
-
build
artifacts
:
reports
:
junit
:
TestResult.xml
junit
:
"
./Artifacts/TestResults.xml"
paths
:
-
"
./Artifacts/*"
except
:
variables
:
-
$GITLAB_USER_ID == $GIT_BOT_USER_ID
...
...
@@ -39,7 +37,7 @@ test:
update-assembly-info
:
stage
:
update-assembly-info
script
:
-
PowerShell .\build.ps1 -Target Update
-
Assembly
-
Info
-
PowerShell .\build.ps1 -Target UpdateAssemblyInfo
variables
:
GIT_STRATEGY
:
none
dependencies
:
...
...
@@ -51,12 +49,10 @@ update-assembly-info:
-
$GITLAB_USER_ID == $GIT_BOT_USER_ID
build-release
:
before_script
:
-
PowerShell .\build.ps1 -Target Clean
-
PowerShell .\build.ps1 -Target Restore-NuGet-Packages
stage
:
build-release
script
:
-
PowerShell .\build.ps1 -Target Build-Release
-
PowerShell .\build.ps1 -Target Build -Configuration Release
-
PowerShell .\build.ps1 -Configuration Release -Target NugetPack
variables
:
GIT_STRATEGY
:
none
dependencies
:
...
...
@@ -84,7 +80,7 @@ docs:
semantic-release
:
stage
:
semantic-release
script
:
-
PowerShell .\build.ps1 -Target Semantic
-
Release
-
PowerShell .\build.ps1 -Target SemanticRelease
variables
:
GIT_STRATEGY
:
none
dependencies
:
...
...
@@ -96,13 +92,16 @@ semantic-release:
-
$GITLAB_USER_ID == $GIT_BOT_USER_ID
release
:
before_script
:
stage
:
release
script
:
-
PowerShell .\build.ps1 -Target Build-Release
-
PowerShell .\build.ps1 -Target Build -Configuration Release
-
PowerShell .\build.ps1 -Configuration Release -Target NugetPack
-
PowerShell .\build.ps1 -Configuration Release -Target NugetPush --nugetApiKey="$NUGET_API_KEY"
variables
:
GIT_STRATEGY
:
n
one
GIT_STRATEGY
:
cl
one
artifacts
:
paths
:
-
dist
-
"
./Artifacts/*"
only
:
-
tags
This diff is collapsed.
Click to expand it.
.releaserc
+
1
−
1
View file @
021b99de
This diff is collapsed.
Click to expand it.
build.cake
+
252
−
186
View file @
021b99de
#tool nuget:?package=NUnit.ConsoleRunner&version=3.9.0
#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.3.4
#tool nuget:?package=vswhere&version=2.6.7
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Npx&version=1.3.0
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Issues&version=0.6.2
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Issues.InspectCode&version=0.6.1
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.FileHelpers&version=3.1.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var nugetApiKey = Argument<string>("nugetApiKey", null);
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
string projectName;
string projectPath;
DirectoryPath buildDir;
FilePath solutionFile;
var projects = GetFiles("./**/*.csproj");
var artifactsDir = Directory("./Artifacts");
string nupkgDir;
var solutionFile = GetFiles("./**/*.sln").First();
var projectName = solutionFile.GetFilenameWithoutExtension().ToString();
var assemblyInfoSubPath = "Properties/AssemblyInfo.cs";
var nugetSource = "https://api.nuget.org/v3/index.json";
// get latest MSBuild version
var vsLatest = VSWhereLatest();
var msBuildPathX64 = (vsLatest == null) ? null : vsLatest.CombineWithFilePath("./MSBuild/Current/Bin/MSBuild.exe");
// Error rules for resharper
// Example: {"InconsistentNaming", "RedundantUsingDirective"};
string[] resharperErrorRules = {};
// Paths to exclude from dupFinder
List<string> dupFinderExcludePatterns = projects.Select( x => $"{x.GetDirectory().ToString()}/{assemblyInfoSubPath}").ToList();
string[] dupFinderExcludeCodeRegionsByNameSubstring = { "DupFinder Exclusion" };
Action<NpxSettings> requiredSemanticVersionPackages = settings =>
settings
.AddPackage("semantic-release")
Action
<NpxSettings> requiredSemanticVersionPackages = settings =>
settings
.AddPackage("semantic-release")
.AddPackage("@semantic-release/commit-analyzer")
.AddPackage("@semantic-release/release-notes-generator")
.AddPackage("@semantic-release/gitlab")
...
...
@@ -36,81 +45,147 @@ Action<NpxSettings> requiredSemanticVersionPackages = settings => settings
.AddPackage("@semantic-release/exec")
.AddPackage("conventional-changelog-eslint");
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(context =>{
nupkgDir = $"{artifactsDir.ToString()}/nupkg";
Information("Running tasks...");
});
Teardown(context =>{
Information("Finished running tasks.");
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Description("Cleans all build and artifacts directories")
.Does(() =>{
var settings = new DeleteDirectorySettings {
Recursive = true,
Force = true
};
var directoriesToDelete = new List<DirectoryPath>();
foreach(var project in projects) {
directoriesToDelete.Add(Directory($"{project.GetDirectory()}/obj"));
directoriesToDelete.Add(Directory($"{project.GetDirectory()}/bin"));
}
Task("Get-Project-Name")
.Does(() =>
{
var solutions = GetFiles("./**/*.sln");
projectName = solutions.First().GetFilenameWithoutExtension().ToString();
Information("Project Name: {0}", projectName);
solutionFile = solutions.First().ToString();
Information("Solution File: {0}", solutionFile.ToString());
projectPath = Context.Environment.WorkingDirectory.ToString().ToString() + "/src";
Information("Project Directory: {0}", projectPath);
directoriesToDelete.Add(artifactsDir);
buildDir = Directory(projectPath + "/" + projectName + "/bin") + Directory(configuration);
Information("Build Directory: {0}", buildDir.ToString());
foreach(var dir in directoriesToDelete) {
if (DirectoryExists(dir)) {
Information($"Cleaning path {dir} ...");
DeleteDirectory(dir, settings);
}
}
});
Task("
Clean
")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory("./dist");
Task("
Restore
")
.Does(() =>{
// Restore all NuGet packages.
Information($"Restoring {solutionFile}...");
NuGetRestore(solutionFile, new NuGetRestoreSettings {
NoCache = true
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
NuGetRestore(solutionFile);
});
Task("Resharper")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
FilePath dupLog = Context.Environment.WorkingDirectory + "/Resharper/dupfinder.xml";
FilePath inspectLog = Context.Environment.WorkingDirectory + "/Resharper/inspectcode.xml";
DupFinder(solutionFile, new DupFinderSettings() {
OutputFile = dupLog.ToString()
Task("DupFinder")
.Description("Find duplicates in the code")
.Does(() =>{
var settings = new DupFinderSettings() {
ShowStats = true,
ShowText = true,
OutputFile = $"{artifactsDir}/dupfinder.xml",
ExcludeCodeRegionsByNameSubstring = dupFinderExcludeCodeRegionsByNameSubstring,
ExcludePattern = dupFinderExcludePatterns.ToArray(),
ThrowExceptionOnFindingDuplicates = true
};
DupFinder(solutionFile, settings);
});
Information("DupFinder Log:{0}{1}", Environment.NewLine, FileReadText(dupLog));
InspectCode(solutionFile, new InspectCodeSettings() {
OutputFile = inspectLog.ToString()
});
Task("InspectCode")
.Description("Inspect the code using Resharper's rule set")
.Does(() =>{
var settings = new InspectCodeSettings() {
SolutionWideAnalysis = true,
OutputFile = $"{artifactsDir}/inspectcode.xml",
ThrowExceptionOnFindingViolations = false
};
InspectCode(solutionFile, settings);
var issues = ReadIssues(
InspectCodeIssuesFromFilePath(inspectLog.ToString()),
Context.Environment.WorkingDirectory);
InspectCodeIssuesFromFilePath($"{artifactsDir}/inspectcode.xml"), Context.Environment.WorkingDirectory);
Information("{0} issues are found.", issues.Count());
Information("InspectCode Log:{0}{1}", Environment.NewLine, FileReadText(inspectLog));
var errorIssues = issues.Where(issue =>resharperErrorRules.Any(issue.Rule.Contains)).ToList();
if(errorIssues.Any())
{
if (errorIssues.Any()) {
var errorMessage = errorIssues.Aggregate(new StringBuilder(), (stringBuilder, issue) =>stringBuilder.AppendFormat("FileName: {0} Line: {1} Message: {2}{3}", issue.AffectedFileRelativePath, issue.Line, issue.Message, Environment.NewLine));
throw new CakeException($"{errorIssues.Count} errors detected: {Environment.NewLine}{errorMessage}.");
}
});
Task("Update-Assembly-Info")
.IsDependentOn("Get-Project-Name")
.Does(() =>
Task("Test")
.Does(() =>{
NUnit3($"./src/**/bin/{configuration}/*.Tests.dll", new NUnit3Settings {
// generate the xml file
NoResults = false,
Results = new NUnit3Result[] {
new NUnit3Result() {
FileName = $"{artifactsDir}/TestResults.xml",
Transform = Context.Environment.WorkingDirectory + "/nunit3-junit.xslt"
}
}
});
});
Task("NugetPush")
.Does(() =>{
var nupkgs = GetFiles($"{nupkgDir}/*.nupkg");
Information("Need to push {0} packages", nupkgs.Count);
foreach(var nupkg in nupkgs) {
Information("Pushing {0}", nupkg);
NuGetPush(nupkg, new NuGetPushSettings {
Source = nugetSource,
ApiKey = nugetApiKey
});
}
});
Task("NugetPack")
.Does(() =>{
foreach(var project in projects) {
var nuspec = $"{project.GetDirectory()}/{project.GetFilenameWithoutExtension()}.nuspec";
if(!project.ToString().EndsWith(".Tests")
&& FileExists(nuspec))
{
Information("Packing {0}...", nuspec);
if(!DirectoryExists(nupkgDir)) {
CreateDirectory(nupkgDir);
}
NuGetPack(project.ToString() ,new NuGetPackSettings
{
OutputDirectory = nupkgDir,
Properties = new Dictionary<string, string> { {"Configuration", "Release"}}
});
}
}
});
Task("UpdateAssemblyInfo")
.Does(() =>{
Information("Running semantic-release in dry run mode to extract next semantic version number");
string[] semanticReleaseOutput;
...
...
@@ -127,115 +202,106 @@ Task("Update-Assembly-Info")
var assemblyVersion = $"{nextSemanticVersionNumber}.0";
CreateAssemblyInfo(projectPath + "/" + projectName + "/Properties/AssemblyInfo.cs", new AssemblyInfoSettings{
Product = projectName,
Title = projectName,
Company = "RWTH Aachen University IT Center",
foreach(var project in projects) {
CreateAssemblyInfo($"{project.GetDirectory()}/{assemblyInfoSubPath}", new AssemblyInfoSettings {
Product = project.GetFilenameWithoutExtension().ToString(),
Title = project.GetFilenameWithoutExtension().ToString(),
Company = "IT Center, RWTH Aachen University",
Version = assemblyVersion,
FileVersion = assemblyVersion,
InformationalVersion = assemblyVersion,
Copyright = "RWTH Aachen University IT Center " + DateTime.Now.Year
Copyright = $"{DateTime.Now.Year} IT Center, RWTH Aachen University",
Description = $"{project.GetFilenameWithoutExtension().ToString()} is a part of the CoScInE group."
});
}
}
});
Task("Build-Release")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
if(IsRunningOnWindows())
{
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() =>{
if (IsRunningOnWindows()) {
var frameworkSettingsWindows = new MSBuildSettings {
Configuration = configuration,
Restore = true
};
frameworkSettingsWindows.ToolPath = msBuildPathX64;
frameworkSettingsWindows.WorkingDirectory = Context.Environment.WorkingDirectory;
if (configuration.Equals("Release")) {
frameworkSettingsWindows.WithProperty("DebugSymbols", "false");
frameworkSettingsWindows.WithProperty("DebugType", "None");
}
// Use MSBuild
MSBuild(solutionFile, settings =>
{
settings.SetConfiguration(configuration);
settings.WithProperty("DebugSymbols", "false");
settings.WithProperty("DebugType", "None");
});
Information($"Building {solutionFile}");
MSBuild(solutionFile, frameworkSettingsWindows);
}
else {
var frameworkSettingsUnix = new XBuildSettings {
Configuration = configuration
};
if (configuration.Equals("Release")) {
frameworkSettingsUnix.WithProperty("DebugSymbols", "false");
frameworkSettingsUnix.WithProperty("DebugType", "None");
}
else
{
// Use XBuild
XBuild(solutionFile, settings =>
{
settings.SetConfiguration(configuration);
settings.WithProperty("DebugSymbols", "false");
settings.WithProperty("DebugType", "None");
});
Information($"Building {solutionFile}");
XBuild(solutionFile, frameworkSettingsUnix);
}
CopyDirectory(buildDir, "./dist");
});
Task("Build")
.IsDependentOn("Get-Project-Name")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild(solutionFile, settings =>
{
settings.SetConfiguration(configuration);
settings.WithProperty("RunCodeAnalysis", "true");
});
if (configuration.Equals("Release")) {
if(!DirectoryExists(artifactsDir)) {
CreateDirectory(artifactsDir);
}
else
{
// Use XBuild
XBuild(solutionFile, settings =>
foreach(var project in projects)
{
if(!project.GetDirectory().ToString().EndsWith(".Tests")
&& !FileExists($"{project.GetDirectory()}/{project.GetFilenameWithoutExtension()}.nuspec"))
{
settings.SetConfiguration(configuration);
settings.WithProperty("RunCodeAnalysis", "true");
});
Information($"Copying {project.GetDirectory()}/bin/{configuration}/* to {artifactsDir}");
CopyDirectory($"{project.GetDirectory()}/bin/{configuration}/", artifactsDir);
}
}
}
});
Task("Run-Unit-Tests")
.Does(() =>
{
NUnit3("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings {
// generate the xml file
NoResults = false,
Results = new NUnit3Result[]{new NUnit3Result(){
FileName = Context.Environment.WorkingDirectory + "/TestResult.xml",
Transform = Context.Environment.WorkingDirectory + "/nunit3-junit.xslt"
}}
});
});
Task("Semantic-Release")
.Does(() =>
{
Task("SemanticRelease")
.Does(() =>{
Npx("semantic-release", requiredSemanticVersionPackages);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Linter")
.Description("Run DupFinder and InspectCode")
.IsDependentOn("DupFinder")
.IsDependentOn("InspectCode");
Task("LinterAndTest")
.Description("Run Linter and Tests")
.IsDependentOn("Linter")
.IsDependentOn("Test");
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore-NuGet-Packages")
.IsDependentOn("Resharper")
.IsDependentOn("Restore")
.IsDependentOn("DupFinder")
.IsDependentOn("InspectCode")
.IsDependentOn("Build")
.IsDependentOn("
Run-Unit-
Test
s
");
.IsDependentOn("Test");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);
///////////////////////////////////////////////////////////////////////////////
// Helpers
///////////////////////////////////////////////////////////////////////////////
string ExtractNextSemanticVersionNumber(string[] semanticReleaseOutput)
{
string ExtractNextSemanticVersionNumber(string[] semanticReleaseOutput) {
var extractRegEx = new System.Text.RegularExpressions.Regex("^.+next release version is (?<SemanticVersionNumber>.*)$");
return semanticReleaseOutput
.Select(line => extractRegEx.Match(line).Groups["SemanticVersionNumber"].Value)
.Where(line => !string.IsNullOrWhiteSpace(line))
.SingleOrDefault();
return semanticReleaseOutput.Select(line =>extractRegEx.Match(line).Groups["SemanticVersionNumber"].Value).Where(line =>!string.IsNullOrWhiteSpace(line)).SingleOrDefault();
}
This diff is collapsed.
Click to expand it.
tools/packages.config
0 → 100644
+
4
−
0
View file @
021b99de
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Cake"
version
=
"0.28.0"
/>
</
packages
>
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
4ac9bfad
·
Jun 19, 2019
mentioned in commit
4ac9bfad
mentioned in commit 4ac9bfadcf03b7252a9d855b92389ec4dba2a9cd
Toggle commit list
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