Skip to content

Commit 186149a

Browse files
PerkseyHurricanKai
andauthored
[2.0] NUKE and much-needed CI work (#353)
* Initial NUKE prototype * First iteration of NUKE is done * Add a test target * Attempt one at updating the CI workflow * Attempt two at CI * Update global.json * Update build.yml * Update Silk.NET.NUKE.csproj * Disable SilkTouch debug dump, checkout recursively * Only test projects that have tests in the name .NET insists on building everything again for some reason * Stop deleting packages before pushing them * Try adding Android in the loop * Stop building libsilkdroid in CI (NDK issue) * NUKE is complete * Apply suggestions from code review Co-authored-by: Kai Jellinghaus <kai.jellinghaus1@gmail.com> Co-authored-by: Kai Jellinghaus <kai.jellinghaus1@gmail.com>
1 parent 82e27dc commit 186149a

29 files changed

+1040
-89
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,22 @@ on:
1010

1111
jobs:
1212
Build:
13-
runs-on: ubuntu-latest
13+
runs-on: windows-latest
1414
steps:
1515
- uses: actions/checkout@v2
16+
with:
17+
submodules: 'true'
1618
- name: Setup .NET Core
1719
uses: actions/setup-dotnet@v1
1820
with:
19-
dotnet-version: 5.0.100-rc.2.20479.15
20-
- name: Test
21-
run: dotnet test --verbosity normal
21+
dotnet-version: 5.0.100
22+
- name: Setup NUKE
23+
run: dotnet tool install Nuke.GlobalTool --global
2224
- name: Pack
23-
run: dotnet pack --configuration Release --version-suffix build$GITHUB_RUN_NUMBER.0 -p:ContinuousIntegrationBuild=true
24-
- name: Setup NuGet
25-
if: ${{ github.repository == 'Ultz/Silk.NET' && github.event_name != 'pull_request' }}
26-
uses: nuget/setup-nuget@v1
27-
with:
28-
nuget-version: '5.x'
29-
- name: Setup Feed
30-
if: ${{ github.repository == 'Ultz/Silk.NET' && github.event_name != 'pull_request' }}
31-
run: nuget sources add -Name Experimental -Source https://pkgs.dev.azure.com/UltzOS/Silk.NET/_packaging/Experimental/nuget/v3/index.json -username ${{ secrets.AZDO_ARTIFACTS_USERNAME }} -password ${{ secrets.AZDO_ARTIFACTS_TOKEN }}
32-
- name: Push Experimental Packages
25+
# TODO build native mixins such as BuildLibSilkDroid
26+
run: nuke Pack --configuration Release --msbuild-properties VersionSuffix=build$GITHUB_RUN_NUMBER.0 ContinuousIntegrationBuild=true --feature-sets Android iOS
27+
- name: Test
28+
run: nuke Test --skip Clean Restore Compile
29+
- name: Push to NuGet
3330
if: ${{ github.repository == 'Ultz/Silk.NET' && github.event_name != 'pull_request' }}
34-
run: nuget push "build/output_packages/*.nupkg" -Source Experimental -ApiKey ${{ secrets.AZDO_ARTIFACTS_TOKEN }}
31+
run: nuke PushToNuGet --skip Clean Restore Pack --nuget-feed https://pkgs.dev.azure.com/UltzOS/Silk.NET/_packaging/Experimental/nuget/v3/index.json --nuget-username ${{ secrets.AZDO_ARTIFACTS_USERNAME }} --nuget-password ${{ secrets.AZDO_ARTIFACTS_TOKEN }} --nuget-api-key az

.github/workflows/deploy.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,16 @@ on:
77

88
jobs:
99
Publish:
10-
11-
runs-on: ubuntu-latest
12-
10+
runs-on: windows-latest
1311
steps:
1412
- uses: actions/checkout@v2
13+
with:
14+
submodules: 'true'
1515
- name: Setup .NET Core
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 5.0.100-rc.2.20479.15
19-
- name: Install dependencies
20-
run: dotnet restore
21-
- name: Pack
22-
run: dotnet pack --configuration Release -p:ContinuousIntegrationBuild=true
23-
- name: Test
24-
run: dotnet test --no-restore --verbosity normal
25-
- name: Setup NuGet
26-
uses: nuget/setup-nuget@v1
27-
with:
28-
nuget-version: '5.x'
18+
dotnet-version: 5.0.100
19+
- name: Setup NUKE
20+
run: dotnet tool install Nuke.GlobalTool --global
2921
- name: Push to NuGet
30-
run: nuget push "build/output_packages/Silk.NET.*.nupkg" -SkipDuplicate -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }}
22+
run: nuke PushToNuGet --configuration Release --msbuild-properties ContinuousIntegrationBuild=true --feature-sets Android iOS --nuget-api-key ${{ secrets.NUGET_TOKEN }}

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ out/
355355
# release/
356356

357357
# Gradle files
358-
.gradle/
359-
build/
358+
**/.gradle/
360359

361360
# Local configuration file (sdk path, etc)
362361
local.properties
@@ -467,6 +466,9 @@ gradle-app.setting
467466
# gradle/wrapper/gradle-wrapper.properties
468467

469468
### Gradle Patch ###
470-
**/build/
469+
src/**/build/
471470

472471
# End of https://www.toptal.com/developers/gitignore/api/android,java,gradle
472+
473+
# Silk.NET Build System
474+
build/sln

.nuke

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Silk.NET.sln

Silk.NET.sln

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 16
33
VisualStudioVersion = 16.0.30517.126
44
MinimumVisualStudioVersion = 15.0.26124.0
@@ -322,6 +322,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.Windowing.Sdl.iOS"
322322
EndProject
323323
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iOS", "iOS", "{488775D1-32CC-46D7-8DD7-BB331EC659B9}"
324324
EndProject
325+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.NUKE", "build\nuke\Silk.NET.NUKE.csproj", "{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}"
326+
EndProject
327+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.NUKE.SshAgent", "src\Core\Silk.NET.NUKE.SshAgent\Silk.NET.NUKE.SshAgent.csproj", "{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}"
328+
EndProject
325329
Global
326330
GlobalSection(SolutionConfigurationPlatforms) = preSolution
327331
Debug|Any CPU = Debug|Any CPU
@@ -332,6 +336,9 @@ Global
332336
Release|x86 = Release|x86
333337
EndGlobalSection
334338
GlobalSection(ProjectConfigurationPlatforms) = postSolution
339+
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
340+
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}.Release|Any CPU.ActiveCfg = Release|Any CPU
341+
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74}.Debug|Any CPU.Build.0 = Debug|Any CPU
335342
{FD24E9FF-1097-4777-A418-F2D88C558665}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
336343
{FD24E9FF-1097-4777-A418-F2D88C558665}.Debug|Any CPU.Build.0 = Debug|Any CPU
337344
{FD24E9FF-1097-4777-A418-F2D88C558665}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -1959,6 +1966,18 @@ Global
19591966
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2}.Release|x64.Build.0 = Release|Any CPU
19601967
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2}.Release|x86.ActiveCfg = Release|Any CPU
19611968
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2}.Release|x86.Build.0 = Release|Any CPU
1969+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1970+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
1971+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x64.ActiveCfg = Debug|Any CPU
1972+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x64.Build.0 = Debug|Any CPU
1973+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x86.ActiveCfg = Debug|Any CPU
1974+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Debug|x86.Build.0 = Debug|Any CPU
1975+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
1976+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|Any CPU.Build.0 = Release|Any CPU
1977+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x64.ActiveCfg = Release|Any CPU
1978+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x64.Build.0 = Release|Any CPU
1979+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x86.ActiveCfg = Release|Any CPU
1980+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9}.Release|x86.Build.0 = Release|Any CPU
19621981
EndGlobalSection
19631982
GlobalSection(SolutionProperties) = preSolution
19641983
HideSolutionNode = FALSE
@@ -2108,6 +2127,8 @@ Global
21082127
{8669819B-654F-4E41-9030-1CCA56D64E88} = {DFA0E841-33E5-4533-AF00-964E21A141B8}
21092128
{603F28D1-E982-47C0-98D9-3E6DA1DD37E2} = {488775D1-32CC-46D7-8DD7-BB331EC659B9}
21102129
{488775D1-32CC-46D7-8DD7-BB331EC659B9} = {23324041-2076-477C-A4BF-B385B8066C6C}
2130+
{B9A8D738-FE7D-4860-A446-4A03E3DDEB74} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490}
2131+
{5D2BCEBE-A163-47E2-9B56-2151D4EC30B9} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490}
21112132
EndGlobalSection
21122133
GlobalSection(ExtensibilityGlobals) = postSolution
21132134
SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D}

azure-pipelines.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

build.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:; set -eo pipefail
2+
:; ./build.sh "$@"
3+
:; exit $?
4+
5+
@ECHO OFF
6+
powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.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\nuke\Silk.NET.NUKE.csproj"
17+
$TempDirectory = "$PSScriptRoot\\.tmp"
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+
26+
###########################################################################
27+
# EXECUTION
28+
###########################################################################
29+
30+
function ExecSafe([scriptblock] $cmd) {
31+
& $cmd
32+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
33+
}
34+
35+
# If global.json exists, load expected version
36+
if (Test-Path $DotNetGlobalFile) {
37+
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
38+
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
39+
$DotNetVersion = $DotNetGlobal.sdk.version
40+
}
41+
}
42+
43+
# If dotnet is installed locally, and expected version is not set or installation matches the expected version
44+
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
45+
(!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
46+
$env:DOTNET_EXE = (Get-Command "dotnet").Path
47+
}
48+
else {
49+
$DotNetDirectory = "$TempDirectory\dotnet-win"
50+
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
51+
52+
# Download install script
53+
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
54+
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
55+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
56+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
57+
58+
# Install by channel or version
59+
if (!(Test-Path variable:DotNetVersion)) {
60+
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
61+
} else {
62+
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
63+
}
64+
}
65+
66+
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
67+
68+
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse: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+
echo $(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/nuke/Silk.NET.NUKE.csproj"
13+
TEMP_DIRECTORY="$SCRIPT_DIR//.tmp"
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+
22+
###########################################################################
23+
# EXECUTION
24+
###########################################################################
25+
26+
function FirstJsonValue {
27+
perl -nle 'print $1 if m{"'$1'": "([^"]+)",?}' <<< ${@:2}
28+
}
29+
30+
# If global.json exists, load expected version
31+
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
32+
DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE"))
33+
if [[ "$DOTNET_VERSION" == "" ]]; then
34+
unset DOTNET_VERSION
35+
fi
36+
fi
37+
38+
# If dotnet is installed locally, and expected version is not set or installation matches the expected version
39+
if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then
40+
export DOTNET_EXE="$(command -v dotnet)"
41+
else
42+
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
43+
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
44+
45+
# Download install script
46+
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
47+
mkdir -p "$TEMP_DIRECTORY"
48+
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
49+
chmod +x "$DOTNET_INSTALL_FILE"
50+
51+
# Install by channel or version
52+
if [[ -z ${DOTNET_VERSION+x} ]]; then
53+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
54+
else
55+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
56+
fi
57+
fi
58+
59+
echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
60+
61+
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet
62+
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"

build/nuke/.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)