Skip to content

Commit

Permalink
Add Tests project
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Mar 27, 2024
1 parent 65b3935 commit 1913e2d
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 2 deletions.
165 changes: 165 additions & 0 deletions Build/.nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/build",
"title": "Build Schema",
"definitions": {
"build": {
"type": "object",
"properties": {
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"Folder": {
"type": "string"
},
"GitHubToken": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"MainName": {
"type": "string"
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"NugetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"NugetApiUrl": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
"PreReleaseFilter": {
"type": "array",
"items": {
"type": "string"
}
},
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
"items": {
"type": "string"
}
},
"ReleaseFolder": {
"type": "string"
},
"ReleaseNameVersion": {
"type": "boolean"
},
"Root": {
"type": "string",
"description": "Root directory during build execution"
},
"SignFile": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"SignPassword": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"Build",
"Clean",
"Compile",
"CopyNupkg",
"GitPreRelease",
"GitRelease",
"Pack",
"PrePack",
"Release",
"Sign",
"Test"
]
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"Build",
"Clean",
"Compile",
"CopyNupkg",
"GitPreRelease",
"GitRelease",
"Pack",
"PrePack",
"Release",
"Sign",
"Test"
]
}
},
"TestBuildStopWhenFailed": {
"type": "boolean"
},
"TestProjectName": {
"type": "string"
},
"TestResults": {
"type": "boolean"
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
}
}
}
}
}
4 changes: 2 additions & 2 deletions Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using ricaun.Nuke;
using ricaun.Nuke.Components;

class Build : NukeBuild, IPublishPack, IPrePack
class Build : NukeBuild, IPublishPack, IPrePack, ICopyNupkg
{
bool IPack.UnlistNuget => true;
public static int Main() => Execute<Build>(x => x.From<IPublishPack>().Build);
}
}
30 changes: 30 additions & 0 deletions Build/ICopyNupkg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.Utilities.Collections;
using ricaun.Nuke.Components;

interface ICopyNupkg : ICompile, ITest
{
Target CopyNupkg => _ => _
.TriggeredBy(Compile)
.Before(Test)
.Executes(() =>
{
var referencesDirectory = Solution.Directory / "references";

if (!referencesDirectory.DirectoryExists())
{
Serilog.Log.Warning($"Skip Not found: {referencesDirectory}");
return;
}

var mainProjectDirectory = GetMainProject().Directory;
var packages = Globbing.GlobFiles(mainProjectDirectory, "**/*.nupkg");

packages.ForEach(file =>
{
Serilog.Log.Warning($"CopyFile: {file.Name} to {referencesDirectory}");
FileSystemTasks.CopyFileToDirectory(file, referencesDirectory, FileExistsPolicy.Overwrite);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;net47;net48;net8.0-windows</TargetFrameworks>
</PropertyGroup>

<Choose>
<When Condition="$(TargetFramework.StartsWith('net46'))">
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net47'))">
<PropertyGroup>
<RevitVersion>2019</RevitVersion>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net48'))">
<PropertyGroup>
<RevitVersion>2021</RevitVersion>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<RevitVersion>2025</RevitVersion>
</PropertyGroup>
</Otherwise>
</Choose>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="RevitVersion.DefineConstants" Version="*-*" />
</ItemGroup>

</Project>
138 changes: 138 additions & 0 deletions RevitVersion.DefineConstants.Tests/Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
using NUnit.Framework;

namespace RevitVersion.DefineConstants.Tests
{
public class Tests
{
#if REVIT2025
[Test]
public void Test2025()
{
Assert.Pass();
}
#endif
#if REVIT2024
[Test]
public void Test2024()
{
Assert.Pass();
}
#endif
#if REVIT2023
[Test]
public void Test2023()
{
Assert.Pass();
}
#endif
#if REVIT2022
[Test]
public void Test2022()
{
Assert.Pass();
}
#endif
#if REVIT2021
[Test]
public void Test2021()
{
Assert.Pass();
}
#endif
#if REVIT2020
[Test]
public void Test2020()
{
Assert.Pass();
}
#endif
#if REVIT2019
[Test]
public void Test2019()
{
Assert.Pass();
}
#endif
#if REVIT2018
[Test]
public void Test2018()
{
Assert.Pass();
}
#endif
#if REVIT2017
[Test]
public void Test2017()
{
Assert.Pass();
}
#endif
}

public class TestsOrGreater
{
#if REVIT2025_OR_GREATER
[Test]
public void Test2025OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2024_OR_GREATER
[Test]
public void Test2024OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2023_OR_GREATER
[Test]
public void Test2023OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2022_OR_GREATER
[Test]
public void Test2022OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2021_OR_GREATER
[Test]
public void Test2021OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2020_OR_GREATER
[Test]
public void Test2020OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2019_OR_GREATER
[Test]
public void Test2019OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2018_OR_GREATER
[Test]
public void Test2018OrGreater()
{
Assert.Pass();
}
#endif
#if REVIT2017_OR_GREATER
[Test]
public void Test2017OrGreater()
{
Assert.Pass();
}
#endif
}
}
Loading

0 comments on commit 1913e2d

Please sign in to comment.