Skip to content

Commit

Permalink
Merge pull request #11 from SimCubeLtd/develop
Browse files Browse the repository at this point in the history
Swap out to simpler cake build script and integrate minver
  • Loading branch information
prom3theu5 authored Nov 10, 2022
2 parents 1371ffe + edb3364 commit a4ac98b
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 78 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Main CI-CD

env:
SIMCUBE_NUGET_SERVER: https://api.nuget.org/v3/index.json
SIMCUBE_NUGET_API_KEY: ${{ secrets.PUBLIC_NUGET_TOKEN }}
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

on:
push:
tags:
- "*"

workflow_dispatch:

jobs:
build-test-pull-request:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'

- name: Build, Test and Pack
run: |
dotnet tool restore
dotnet cake --pack true
- name: Push to nuget
working-directory: artifacts/
run: dotnet nuget push *.nupkg -s $SIMCUBE_NUGET_SERVER -k $SIMCUBE_NUGET_API_KEY
37 changes: 0 additions & 37 deletions .github/workflows/master.yml

This file was deleted.

37 changes: 7 additions & 30 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
name: Pull Requests

env:
SIMCUBE_SONARQUBE_PROJECT_KEY: "CakeBuildah"
SIMCUBE_SOLUTION_FILE_PATH: "Cake.Buildah.sln"
SIMCUBE_BUILD_NAME: "Cake.Buildah"
SIMCUBE_DOTNET_TOOL_PATH: "/home/runner/.dotnet/tools"
SIMCUBE_SOLUTION_ROOT: ${{ github.workspace }}
SIMCUBE_MANUAL_VERSION: 1.0.${{ github.run_number }}.0
SIMCUBE_MANUAL_BRANCH_NAME: ${{ github.ref_name }}
SIMCUBE_PULL_REQUEST_NUMBER: ${{ github.event.number }}
SIMCUBE_PULL_REQUEST_SOURCE_BRANCH: ${{ github.head_ref }}
SIMCUBE_PULL_REQUEST_TARGET_BRANCH: ${{ github.base_ref }}
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
Expand All @@ -19,32 +9,19 @@ on:
- pull_request

jobs:
build-test-and-analyse-pull-request:
build-test-pull-request:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- if: "! github.event.pull_request.head.repo.fork "
name: "Building from Main Repository. Analysis is Supported."
uses: SimCubeLtd/buildtool-action@main
env:
SIMCUBE_SONARQUBE_URL: ${{ secrets.SONAR_HOST }}
SIMCUBE_SONARQUBE_API_KEY: ${{ secrets.SONAR_API_KEY }}
SIMCUBE_SONARQUBE_ENABLED: "true"
SIMCUBE_ENABLE_QUALITY_GATE: "true"
- uses: actions/setup-dotnet@v3
with:
installRequired: 'true'
checkout: 'true'
setupDotNet: 'true'

- if: " github.event.pull_request.head.repo.fork "
name: "Building from Fork. Analysis is not supported"
uses: SimCubeLtd/buildtool-action@main
with:
installRequired: 'true'
checkout: 'true'
setupDotNet: 'true'
dotnet-version: '7.0.x'

- name: Build, Test and Pack
run: |
dotnet tool restore
dotnet cake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,5 @@ MigrationBackup/
Artifacts/
tools/
.idea/

.DS_Store
6 changes: 4 additions & 2 deletions Cake.Buildah.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
LICENSE = LICENSE
README.md = README.md
SimCubeBuildTool.yml = SimCubeBuildTool.yml
build.cake = build.cake
dotnet-tools.json = dotnet-tools.json
global.json = global.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F17B1FA8-2860-40C7-BD34-8A5D7FE7A6E4}"
Expand All @@ -24,8 +26,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Buildah.Tests", "tests
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "github", "github", "{449F9620-38BD-4278-AD27-6582EEF3A18D}"
ProjectSection(SolutionItems) = preProject
.github\workflows\master.yml = .github\workflows\master.yml
.github\workflows\pull-requests.yml = .github\workflows\pull-requests.yml
.github\workflows\main.yml = .github\workflows\main.yml
EndProjectSection
EndProject
Global
Expand Down
8 changes: 0 additions & 8 deletions SimCubeBuildTool.yml

This file was deleted.

104 changes: 104 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#addin nuget:?package=SimpleExec&version=11.0.0
#addin "nuget:?package=Cake.MinVer&version=3.0.0"

using System.Text.Json;
using SimpleExec;

var target = Argument("Target", "Default");

var configuration =
HasArgument("Configuration") ? Argument<string>("Configuration") :
EnvironmentVariable("Configuration", "Release");

var shouldPack = HasArgument("pack") ? Argument<bool>("pack") : false;

var settings = new MinVerSettings()
{
AutoIncrement = MinVerAutoIncrement.Minor,
DefaultPreReleasePhase = "preview",
MinimumMajorMinor = "1.0",
TagPrefix = "v",
Verbosity = MinVerVerbosity.Trace,
};

var version = MinVer(settings);

Task("Clean")
.Description("Cleans the artifacts, bin and obj directories.")
.Does(() =>
{
DeleteDirectories(GetDirectories("**/bin"), new DeleteDirectorySettings() { Force = true, Recursive = true });
DeleteDirectories(GetDirectories("**/obj"), new DeleteDirectorySettings() { Force = true, Recursive = true });
CleanDirectory("./artifacts");
CleanDirectory("./test-output");
});

Task("Restore")
.Description("Restores NuGet packages.")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetRestore();
});

Task("Build")
.Description("Builds the solution.")
.IsDependentOn("Restore")
.Does(() =>
{
DotNetBuild(
".",
new DotNetBuildSettings()
{
Configuration = configuration,
NoRestore = true,
ArgumentCustomization = args =>
args
.Append($"-p:Version={version}")
.Append($"-p:InformationalVersion={version}"),
});
});

Task("Test")
.Description("Runs unit tests and outputs test results to the artifacts directory.")
.Does(() =>
{
DotNetTest(
"tests/Cake.Buildah.Tests/Cake.Buildah.Tests.csproj",
new DotNetTestSettings()
{
Blame = true,
Configuration = configuration,
ResultsDirectory = "./test-output",
NoBuild = true,
NoRestore = true,
Collectors = new string[] { "Code Coverage", "XPlat Code Coverage" },
});
});

Task("Pack")
.Description("Packs the Required Project")
.IsDependentOn("Test")
.WithCriteria(shouldPack)
.Does(() =>
{
DotNetPack("src/Cake.Buildah/Cake.Buildah.csproj",
new DotNetPackSettings()
{
NoBuild = true,
NoRestore = true,
NoLogo = true,
OutputDirectory = "./artifacts",
Verbosity = DotNetVerbosity.Minimal,
Configuration = configuration,
ArgumentCustomization = builder => builder.Append($"-p:PackageVersion={version}")
});
});

Task("Default")
.Description("Cleans, restores NuGet packages, builds the solution and then runs unit tests.")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack");

RunTarget(target);
18 changes: 18 additions & 0 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"commands": [
"dotnet-cake"
]
},
"minver-cli": {
"version": "4.2.0",
"commands": [
"minver"
]
}
}
}
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "7.0.100",
"rollForward": "latestMajor",
"allowPrerelease": false
}
}
2 changes: 1 addition & 1 deletion tests/Cake.Buildah.Tests/Cake.Buildah.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>latest</LangVersion>
<AnalysisMode>None</AnalysisMode>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
Expand Down

0 comments on commit a4ac98b

Please sign in to comment.