forked from cake-contrib/Cake.Issues.Recipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for running with Cake.Git
- Loading branch information
1 parent
d72ccdd
commit da042b5
Showing
93 changed files
with
1,928 additions
and
98 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
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 |
---|---|---|
@@ -1,23 +1,28 @@ | ||
parameters: | ||
- name: vmImage | ||
type: string | ||
- name: dotNetVersion | ||
type: string | ||
- name: images | ||
type: object | ||
- name: dotNetVersions | ||
type: object | ||
- name: repositoryInfoProviders | ||
type: object | ||
|
||
jobs: | ||
- job: Test_Frosting_${{ replace(replace(parameters.vmImage,'-','_'),'.','_') }}_Net${{ parameters.dotNetVersion }} | ||
displayName: Integration Tests Frosting ${{ parameters.vmImage }} (.NET ${{ parameters.dotNetVersion }}) | ||
dependsOn: Build | ||
pool: | ||
vmImage: '${{ parameters.vmImage }}' | ||
steps: | ||
- template: ../steps/prepare-test.yml | ||
parameters: | ||
dotNetVersion: ${{ parameters.dotNetVersion }} | ||
- bash: | | ||
./build.sh --verbosity=diagnostic | ||
workingDirectory: ./tests/frosting/net${{ parameters.dotNetVersion }}.0 | ||
displayName: 'Run integration tests' | ||
- publish: $(Build.SourcesDirectory)/tests/frosting/net${{ parameters.dotNetVersion }}.0/build/BuildArtifacts/output | ||
artifact: Integration Tests Frosting ${{ parameters.vmImage }} (.NET ${{ parameters.dotNetVersion }}) | ||
displayName: 'Publish generated reports as build artifact' | ||
- ${{ each image in parameters.images }}: | ||
- ${{ each dotnetVersion in parameters.dotNetVersions }}: | ||
- ${{ each repositoryInfoProvider in parameters.repositoryInfoProviders }}: | ||
- job: Test_Frosting_${{ replace(replace(image,'-','_'),'.','_') }}_Net${{ dotNetVersion }}_${{ replace(repositoryInfoProvider,'-','_') }} | ||
displayName: Integration Tests Frosting ${{ image }} (.NET ${{ dotNetVersion }} / ${{ repositoryInfoProvider }}) | ||
dependsOn: Build | ||
pool: | ||
vmImage: '${{ image }}' | ||
steps: | ||
- template: ../steps/prepare-test.yml | ||
parameters: | ||
dotNetVersion: ${{ dotNetVersion }} | ||
- bash: | | ||
./build.sh --verbosity=diagnostic | ||
workingDirectory: ./tests/frosting/net${{ dotNetVersion }}.0-${{ repositoryInfoProvider }} | ||
displayName: 'Run integration tests' | ||
- publish: $(Build.SourcesDirectory)/tests/frosting/net${{ dotNetVersion }}.0-${{ repositoryInfoProvider }}/build/BuildArtifacts/output | ||
artifact: Integration Tests Frosting ${{ image }} (.NET ${{ dotNetVersion }} + ${{ repositoryInfoProvider }}) | ||
displayName: 'Publish generated reports as build artifact' |
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 |
---|---|---|
@@ -1,23 +1,28 @@ | ||
parameters: | ||
- name: vmImage | ||
type: string | ||
- name: dotNetVersion | ||
type: string | ||
- name: images | ||
type: object | ||
- name: dotNetVersions | ||
type: object | ||
- name: repositoryInfoProviders | ||
type: object | ||
|
||
jobs: | ||
- job: Test_Script_Runner_${{ replace(replace(parameters.vmImage,'-','_'),'.','_') }}_Net${{ parameters.dotNetVersion }} | ||
displayName: Integration Tests Script Runner ${{ parameters.vmImage }} (.NET ${{ parameters.dotNetVersion }}) | ||
dependsOn: Build | ||
pool: | ||
vmImage: '${{ parameters.vmImage }}' | ||
steps: | ||
- template: ../steps/prepare-test.yml | ||
parameters: | ||
dotNetVersion: ${{ parameters.dotNetVersion }} | ||
- bash: | | ||
./build.sh --verbosity=diagnostic | ||
workingDirectory: ./tests/script-runner/net${{ parameters.dotNetVersion }}.0 | ||
displayName: 'Run integration tests' | ||
- publish: $(Build.SourcesDirectory)/tests/script-runner/net${{ parameters.dotNetVersion }}.0/BuildArtifacts/output | ||
artifact: Integration Tests Script Runner ${{ parameters.vmImage }} (.NET ${{ parameters.dotNetVersion }}) | ||
displayName: 'Publish generated reports as build artifact' | ||
- ${{ each image in parameters.images }}: | ||
- ${{ each dotnetVersion in parameters.dotNetVersions }}: | ||
- ${{ each repositoryInfoProvider in parameters.repositoryInfoProviders }}: | ||
- job: Test_Script_Runner_${{ replace(replace(image,'-','_'),'.','_') }}_Net${{ dotNetVersion }}_${{ replace(repositoryInfoProvider,'-','_') }} | ||
displayName: Integration Tests Script Runner ${{ image }} (.NET ${{ dotNetVersion }} / ${{ repositoryInfoProvider }}) | ||
dependsOn: Build | ||
pool: | ||
vmImage: '${{ image }}' | ||
steps: | ||
- template: ../steps/prepare-test.yml | ||
parameters: | ||
dotNetVersion: ${{ dotNetVersion }} | ||
- bash: | | ||
./build.sh --verbosity=diagnostic | ||
workingDirectory: ./tests/script-runner/net${{ dotNetVersion }}.0-${{ repositoryInfoProvider }} | ||
displayName: 'Run integration tests' | ||
- publish: $(Build.SourcesDirectory)/tests/script-runner/net${{ dotNetVersion }}.0-${{ repositoryInfoProvider }}/BuildArtifacts/output | ||
artifact: Integration Tests Script Runner ${{ image }} (.NET ${{ dotNetVersion }} + ${{ repositoryInfoProvider }}) | ||
displayName: 'Publish generated reports as build artifact' |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,124 @@ | ||
using System; | ||
using System.Reflection; | ||
using Cake.Common; | ||
using Cake.Common.Diagnostics; | ||
using Cake.Common.Tools.InspectCode; | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Core.IO; | ||
using Cake.Frosting; | ||
|
||
public static class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
return new CakeHost() | ||
.UseContext<BuildContext>() | ||
.UseLifetime<Lifetime>() | ||
.InstallTool(new Uri("nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2023.3.4")) | ||
// Register Cake.Frosting.Issues.Recipe tasks. | ||
.AddAssembly(Assembly.GetAssembly(typeof(IssuesTask))) | ||
.Run(args); | ||
} | ||
} | ||
|
||
public class BuildContext : IssuesContext<BuildParameters, BuildState> | ||
{ | ||
public BuildContext(ICakeContext context) | ||
: base(context) | ||
{ | ||
} | ||
|
||
protected override BuildParameters CreateIssuesParameters() | ||
{ | ||
return new BuildParameters(); | ||
} | ||
|
||
protected override BuildState CreateIssuesState() | ||
{ | ||
return new BuildState(this); | ||
} | ||
} | ||
|
||
public class BuildParameters : IssuesParameters | ||
{ | ||
public DirectoryPath LogDirectoryPath => this.OutputDirectory.Combine("logs"); | ||
|
||
public BuildParameters() | ||
{ | ||
this.OutputDirectory = this.OutputDirectory.Combine("output"); | ||
} | ||
} | ||
|
||
public class BuildState : IssuesState | ||
{ | ||
public FilePath SolutionFilePath { get; } | ||
|
||
public BuildState(BuildContext context) | ||
: base(context, RepositoryInfoProviderType.CakeGit) | ||
{ | ||
this.SolutionFilePath = | ||
this.ProjectRootDirectory | ||
.Combine("src") | ||
.CombineWithFilePath("ClassLibrary1.sln"); | ||
} | ||
} | ||
|
||
public class Lifetime : FrostingLifetime<BuildContext> | ||
{ | ||
public override void Setup(BuildContext context, ISetupContext info) | ||
{ | ||
// Determine Build Identifier | ||
var platform = context.Environment.Platform.Family.ToString(); | ||
var runtime = context.Environment.Runtime.IsCoreClr ? ".NET Core" : ".NET Framework"; | ||
|
||
context.Parameters.BuildIdentifier = $"Cake Frosting {platform} ({runtime})"; | ||
|
||
context.Information("Build identifier: {0}", context.Parameters.BuildIdentifier); | ||
} | ||
|
||
public override void Teardown(BuildContext context, ITeardownContext info) | ||
{ | ||
} | ||
} | ||
|
||
[TaskName("Run-InspectCode")] | ||
public sealed class RunInspectCodeTask : FrostingTask<BuildContext> | ||
{ | ||
public override bool ShouldRun(BuildContext context) | ||
{ | ||
return context.IsRunningOnWindows(); | ||
} | ||
|
||
public override void Run(BuildContext context) | ||
{ | ||
// Run InspectCode. | ||
var inspectCodeLogFilePath = context.Parameters.LogDirectoryPath.CombineWithFilePath("inspectCode.log"); | ||
|
||
var settings = new InspectCodeSettings() { | ||
OutputFile = inspectCodeLogFilePath, | ||
ArgumentCustomization = x => x.Append("--no-build"), | ||
WorkingDirectory = context.State.ProjectRootDirectory | ||
}; | ||
|
||
context.InspectCode( | ||
context.State.SolutionFilePath, | ||
settings); | ||
|
||
// Pass path to InspectCode log file to Cake.Frosting.Issues.Recipe. | ||
context.Parameters.InputFiles.AddInspectCodeLogFilePath(inspectCodeLogFilePath); | ||
} | ||
} | ||
|
||
[TaskName("Lint")] | ||
[IsDependentOn(typeof(RunInspectCodeTask))] | ||
[IsDependeeOf(typeof(ReadIssuesTask))] | ||
public class LintTask : FrostingTask | ||
{ | ||
} | ||
|
||
[TaskName("Default")] | ||
[IsDependentOn(typeof(IssuesTask))] | ||
public class DefaultTask : FrostingTask | ||
{ | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Cake.Frosting" Version="5.0.0" /> | ||
<PackageReference Include="Cake.Frosting.Issues.Recipe" Version="*-*" /> | ||
</ItemGroup> | ||
</Project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,13 @@ | ||
$RECIPE_PACKAGE_PATH = "packages/cake.frosting.issues.recipe" | ||
if (Test-Path $RECIPE_PACKAGE_PATH) | ||
{ | ||
Write-Host "Cleaning up cached version of $RECIPE_PACKAGE_PATH..." | ||
Remove-Item $RECIPE_PACKAGE_PATH -Recurse; | ||
} | ||
else | ||
{ | ||
Write-Host "$RECIPE_PACKAGE_PATH not cached..." | ||
} | ||
|
||
dotnet run --project build/Build.csproj -- $args | ||
exit $LASTEXITCODE; |
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,11 @@ | ||
|
||
$RECIPE_PACKAGE_PATH = "packages/cake.frosting.issues.recipe" | ||
if [ -d "$RECIPE_PACKAGE_PATH" ] | ||
then | ||
echo "Cleaning up cached version of $RECIPE_PACKAGE_PATH..." | ||
rm -Rf $RECIPE_PACKAGE_PATH | ||
else | ||
echo "$RECIPE_PACKAGE_PATH not cached..." | ||
fi | ||
|
||
dotnet run --project ./build/Build.csproj -- "$@" |
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 @@ | ||
### Cake ### | ||
tools/* |
File renamed without changes.
Oops, something went wrong.