Skip to content

Commit ec9d611

Browse files
committed
feat(nuke): convert existing pipelines
1 parent af48eb5 commit ec9d611

21 files changed

+721
-1
lines changed

.github/workflows/DotNET-build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ------------------------------------------------------------------------------
2+
# <auto-generated>
3+
#
4+
# This code was generated.
5+
#
6+
# - To turn off auto-generation set:
7+
#
8+
# [GitHubActions (AutoGenerate = false)]
9+
#
10+
# - To trigger manual generation invoke:
11+
#
12+
# nuke --generate-configuration GitHubActions_DotNET-build --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: DotNET-build
18+
19+
on:
20+
push:
21+
branches:
22+
- master
23+
- dev
24+
25+
jobs:
26+
ubuntu-latest:
27+
name: ubuntu-latest
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v3
31+
- name: Cache .nuke/temp, ~/.nuget/packages
32+
uses: actions/cache@v3
33+
with:
34+
path: |
35+
.nuke/temp
36+
~/.nuget/packages
37+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
38+
- name: Run './build.cmd Backend_Reporter'
39+
run: ./build.cmd Backend_Reporter
40+
env:
41+
DockerhubUsername: ${{ secrets.DOCKERHUB_USERNAME }}
42+
DockerhubPassword: ${{ secrets.DOCKERHUB_PASSWORD }}
43+
SonarToken: ${{ secrets.SONAR_TOKEN }}
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,6 @@ nuget.exe
352352
.vshistory/
353353

354354
coverage.xml
355-
coverage/
355+
coverage/
356+
357+
.nuke/temp/

.nuke/build.schema.json

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Build Schema",
4+
"$ref": "#/definitions/build",
5+
"definitions": {
6+
"build": {
7+
"type": "object",
8+
"properties": {
9+
"Configuration": {
10+
"type": "string",
11+
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
12+
"enum": [
13+
"Debug",
14+
"Release"
15+
]
16+
},
17+
"Continue": {
18+
"type": "boolean",
19+
"description": "Indicates to continue a previously failed build attempt"
20+
},
21+
"DockerhubPassword": {
22+
"type": "string",
23+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
24+
},
25+
"DockerhubUsername": {
26+
"type": "string",
27+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
28+
},
29+
"Help": {
30+
"type": "boolean",
31+
"description": "Shows the help text for this build assembly"
32+
},
33+
"Host": {
34+
"type": "string",
35+
"description": "Host for execution. Default is 'automatic'",
36+
"enum": [
37+
"AppVeyor",
38+
"AzurePipelines",
39+
"Bamboo",
40+
"Bitbucket",
41+
"Bitrise",
42+
"GitHubActions",
43+
"GitLab",
44+
"Jenkins",
45+
"Rider",
46+
"SpaceAutomation",
47+
"TeamCity",
48+
"Terminal",
49+
"TravisCI",
50+
"VisualStudio",
51+
"VSCode"
52+
]
53+
},
54+
"NoLogo": {
55+
"type": "boolean",
56+
"description": "Disables displaying the NUKE logo"
57+
},
58+
"Partition": {
59+
"type": "string",
60+
"description": "Partition to use on CI"
61+
},
62+
"Plan": {
63+
"type": "boolean",
64+
"description": "Shows the execution plan (HTML)"
65+
},
66+
"Profile": {
67+
"type": "array",
68+
"description": "Defines the profiles to load",
69+
"items": {
70+
"type": "string"
71+
}
72+
},
73+
"Root": {
74+
"type": "string",
75+
"description": "Root directory during build execution"
76+
},
77+
"Skip": {
78+
"type": "array",
79+
"description": "List of targets to be skipped. Empty list skips all dependencies",
80+
"items": {
81+
"type": "string",
82+
"enum": [
83+
"Backend_Clean",
84+
"Backend_Compile",
85+
"Backend_Reporter",
86+
"Backend_Restore",
87+
"Backend_Setup",
88+
"Backend_SonarScan_End",
89+
"Backend_SonarScan_Start",
90+
"Backend_Test",
91+
"Backend_Test_Ci",
92+
"Clean",
93+
"Docker_Setup",
94+
"Frontend_Build",
95+
"Frontend_Reporter",
96+
"Frontend_Restore",
97+
"Frontend_SonarScan",
98+
"Frontend_Tests",
99+
"Frontend_Tests_Ci"
100+
]
101+
}
102+
},
103+
"Solution": {
104+
"type": "string",
105+
"description": "Path to a solution file that is automatically loaded"
106+
},
107+
"SonarToken": {
108+
"type": "string",
109+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
110+
},
111+
"SonarTokenUi": {
112+
"type": "string",
113+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
114+
},
115+
"Target": {
116+
"type": "array",
117+
"description": "List of targets to be invoked. Default is '{default_target}'",
118+
"items": {
119+
"type": "string",
120+
"enum": [
121+
"Backend_Clean",
122+
"Backend_Compile",
123+
"Backend_Reporter",
124+
"Backend_Restore",
125+
"Backend_Setup",
126+
"Backend_SonarScan_End",
127+
"Backend_SonarScan_Start",
128+
"Backend_Test",
129+
"Backend_Test_Ci",
130+
"Clean",
131+
"Docker_Setup",
132+
"Frontend_Build",
133+
"Frontend_Reporter",
134+
"Frontend_Restore",
135+
"Frontend_SonarScan",
136+
"Frontend_Tests",
137+
"Frontend_Tests_Ci"
138+
]
139+
}
140+
},
141+
"Verbosity": {
142+
"type": "string",
143+
"description": "Logging verbosity during build execution. Default is 'Normal'",
144+
"enum": [
145+
"Minimal",
146+
"Normal",
147+
"Quiet",
148+
"Verbose"
149+
]
150+
}
151+
}
152+
}
153+
}
154+
}

.nuke/parameters.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./build.schema.json",
3+
"Solution": "Serilog.Ui.sln"
4+
}

Serilog.Ui.sln

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{04B4A8
5252
assets\serilog-ui.jpg = assets\serilog-ui.jpg
5353
EndProjectSection
5454
EndProject
55+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{5D0F29B0-11F4-4FEA-8D90-FD917F680D6D}"
56+
EndProject
5557
Global
5658
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5759
Debug|Any CPU = Debug|Any CPU
5860
Release|Any CPU = Release|Any CPU
5961
EndGlobalSection
6062
GlobalSection(ProjectConfigurationPlatforms) = postSolution
63+
{5D0F29B0-11F4-4FEA-8D90-FD917F680D6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64+
{5D0F29B0-11F4-4FEA-8D90-FD917F680D6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
6165
{3BF751F9-67CA-47F2-84E0-068344A8F306}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6266
{3BF751F9-67CA-47F2-84E0-068344A8F306}.Debug|Any CPU.Build.0 = Debug|Any CPU
6367
{3BF751F9-67CA-47F2-84E0-068344A8F306}.Release|Any CPU.ActiveCfg = Release|Any CPU

build.cmd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:; set -eo pipefail
2+
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
3+
:; ${SCRIPT_DIR}/build.sh "$@"
4+
:; exit $?
5+
6+
@ECHO OFF
7+
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*

build.ps1

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[CmdletBinding()]
2+
Param(
3+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
4+
[string[]]$BuildArguments
5+
)
6+
7+
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
8+
9+
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
10+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
11+
12+
###########################################################################
13+
# CONFIGURATION
14+
###########################################################################
15+
16+
$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
17+
$TempDirectory = "$PSScriptRoot\\.nuke\temp"
18+
19+
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
20+
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
21+
$DotNetChannel = "Current"
22+
23+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
24+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
25+
$env:DOTNET_MULTILEVEL_LOOKUP = 0
26+
27+
###########################################################################
28+
# EXECUTION
29+
###########################################################################
30+
31+
function ExecSafe([scriptblock] $cmd) {
32+
& $cmd
33+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
34+
}
35+
36+
# If dotnet CLI is installed globally and it matches requested version, use for execution
37+
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
38+
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
39+
$env:DOTNET_EXE = (Get-Command "dotnet").Path
40+
}
41+
else {
42+
# Download install script
43+
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
44+
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
45+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
46+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
47+
48+
# If global.json exists, load expected version
49+
if (Test-Path $DotNetGlobalFile) {
50+
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
51+
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
52+
$DotNetVersion = $DotNetGlobal.sdk.version
53+
}
54+
}
55+
56+
# Install by channel or version
57+
$DotNetDirectory = "$TempDirectory\dotnet-win"
58+
if (!(Test-Path variable:DotNetVersion)) {
59+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
60+
} else {
61+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
62+
}
63+
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
64+
}
65+
66+
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
67+
68+
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
69+
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

build.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
bash --version 2>&1 | head -n 1
4+
5+
set -eo pipefail
6+
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
7+
8+
###########################################################################
9+
# CONFIGURATION
10+
###########################################################################
11+
12+
BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
13+
TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
14+
15+
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
16+
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
17+
DOTNET_CHANNEL="Current"
18+
19+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
20+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
21+
export DOTNET_MULTILEVEL_LOOKUP=0
22+
23+
###########################################################################
24+
# EXECUTION
25+
###########################################################################
26+
27+
function FirstJsonValue {
28+
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
29+
}
30+
31+
# If dotnet CLI is installed globally and it matches requested version, use for execution
32+
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
33+
export DOTNET_EXE="$(command -v dotnet)"
34+
else
35+
# Download install script
36+
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
37+
mkdir -p "$TEMP_DIRECTORY"
38+
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
39+
chmod +x "$DOTNET_INSTALL_FILE"
40+
41+
# If global.json exists, load expected version
42+
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
43+
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
44+
if [[ "$DOTNET_VERSION" == "" ]]; then
45+
unset DOTNET_VERSION
46+
fi
47+
fi
48+
49+
# Install by channel or version
50+
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
51+
if [[ -z ${DOTNET_VERSION+x} ]]; then
52+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
53+
else
54+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
55+
fi
56+
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
57+
fi
58+
59+
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
60+
61+
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
62+
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"

build/.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[*.cs]
2+
dotnet_style_qualification_for_field = false:warning
3+
dotnet_style_qualification_for_property = false:warning
4+
dotnet_style_qualification_for_method = false:warning
5+
dotnet_style_qualification_for_event = false:warning
6+
dotnet_style_require_accessibility_modifiers = never:warning
7+
8+
csharp_style_expression_bodied_methods = true:silent
9+
csharp_style_expression_bodied_properties = true:warning
10+
csharp_style_expression_bodied_indexers = true:warning
11+
csharp_style_expression_bodied_accessors = true:warning

0 commit comments

Comments
 (0)