-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(maint) added a real simple Cake file
to build the image and run tests
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"cake.tool": { | ||
"version": "1.1.0", | ||
"commands": [ | ||
"dotnet-cake" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tools/ | ||
.history/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#tool dotnet:?package=GitVersion.Tool&version=5.6.8 | ||
#addin nuget:?package=Cake.Docker&version=1.0.0 | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var target = Argument("target", "Default"); | ||
var imageName = Argument("imageName", "dependabot-cake"); | ||
|
||
// test | ||
var testRepositoryName = Argument("test-RepositoryName", "nils-a/Cake.7zip"); | ||
var testRepositoryBranch = Argument("test-RepositoryBranch", "develop"); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// TASKS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var imageFullTag = ""; | ||
Task("Calculate-Image-Tag") | ||
.Does(() => | ||
{ | ||
var version = GitVersion(); | ||
imageFullTag = $"{imageName}:{version.SemVer}"; | ||
Information($"calculated tag for image: {imageFullTag}"); | ||
}); | ||
|
||
|
||
Task("Build-Image") | ||
.IsDependentOn("Calculate-Image-Tag") | ||
.Does(() => | ||
{ | ||
DockerBuild(new DockerImageBuildSettings | ||
{ | ||
Tag = new[] {imageFullTag}, | ||
}, "src"); | ||
}); | ||
|
||
Task("Run-Test") | ||
.IsDependentOn("Calculate-Image-Tag") | ||
.IsDependentOn("Build-Image") | ||
.Does(() => | ||
{ | ||
if(string.IsNullOrEmpty(EnvironmentVariable("INPUT_TOKEN"))) | ||
{ | ||
throw new ArgumentException("'INPUT_TOKEN' not set. Please set INPUT_TOKEN to your GitHub pat"); | ||
} | ||
|
||
var output = DockerRun(new DockerContainerRunSettings | ||
{ | ||
Env = new string [] | ||
{ | ||
$"GITHUB_REPOSITORY={testRepositoryName}", | ||
$"INPUT_TARGET_BRANCH={testRepositoryBranch}", | ||
$"INPUT_TOKEN", | ||
}, | ||
Rm = true, | ||
}, | ||
imageFullTag, | ||
""); | ||
|
||
Information(output); | ||
}); | ||
|
||
|
||
|
||
Task("Default") | ||
.Does(() => { | ||
Warning("Currently there is no default. Chose a better target!"); | ||
}); | ||
|
||
RunTarget(target); |