diff --git a/.build/BuildToolkit.ps1 b/.build/BuildToolkit.ps1 deleted file mode 100644 index 26d22db..0000000 --- a/.build/BuildToolkit.ps1 +++ /dev/null @@ -1,680 +0,0 @@ -# Tool Versions -$NunitVersion = "3.12.0"; -$OpenCoverVersion = "4.7.1221"; -$DocFxVersion = "2.58.4"; -$ReportGeneratorVersion = "4.8.13"; -$OpenCoverToCoberturaVersion = "0.3.4"; - -# Folder Pathes -$RootPath = $MyInvocation.PSScriptRoot; -$BuildTools = "$RootPath\packages"; - -# Artifacts -$ArtifactsDir = "$RootPath\artifacts"; - -# Documentation -$DocumentationDir = "$RootPath\docs"; -$DocumentationArtifcacts = "$ArtifactsDir\Documentation"; - -# Tests -$NunitReportsDir = "$ArtifactsDir\Tests"; -$OpenCoverReportsDir = "$ArtifactsDir\Tests" -$CoberturaReportsDir = "$ArtifactsDir\Tests" - -# Nuget -$NugetConfig = "$RootPath\NuGet.Config"; -$NugetPackageArtifacts = "$ArtifactsDir\Packages"; - -# Load partial scripts -. "$PSScriptRoot\Output.ps1"; - -# Define Tools -$global:DotNetCli = "dotnet.exe"; -$global:NugetCli = "nuget.exe"; -$global:GitCli = ""; -$global:OpenCoverCli = "$BuildTools\OpenCover.$OpenCoverVersion\tools\OpenCover.Console.exe"; -$global:NunitCli = "$BuildTools\NUnit.ConsoleRunner.$NunitVersion\tools\nunit3-console.exe"; -$global:ReportGeneratorCli = "$BuildTools\ReportGenerator.$ReportGeneratorVersion\tools\net47\ReportGenerator.exe"; -$global:DocFxCli = "$BuildTools\docfx.console.$DocFxVersion\tools\docfx.exe"; -$global:OpenCoverToCoberturaCli = "$BuildTools\OpenCoverToCoberturaConverter.$OpenCoverToCoberturaVersion\tools\OpenCoverToCoberturaConverter.exe"; - -# Git -$global:GitCommitHash = ""; - -# Functions -function Invoke-Initialize([string]$Version = "1.0.0", [bool]$Cleanup = $False) { - Write-Step "Initializing BuildToolkit" - - # First check the powershell version - if ($PSVersionTable.PSVersion.Major -lt 5) { - Write-Host ("The needed major powershell version for this script is 5. Your version: " + ($PSVersionTable.PSVersion.ToString())) - exit 1; - } - - # Assign git.exe - $gitCommand = (Get-Command "git.exe" -ErrorAction SilentlyContinue); - if ($null -eq $gitCommand) { - Write-Host "Unable to find git.exe in your PATH. Download from https://git-scm.com"; - exit 1; - } - - $global:GitCli = $gitCommand.Path; - - # Load Hash - $global:GitCommitHash = (& $global:GitCli rev-parse HEAD); - Invoke-ExitCodeCheck $LastExitCode; - - # Initialize Folders - CreateFolderIfNotExists $BuildTools; - CreateFolderIfNotExists $ArtifactsDir; - - # Environment Variable Defaults - if (-not $env:MORYX_BUILDNUMBER) { - $env:MORYX_BUILDNUMBER = 0; - } - - if (-not $env:MORYX_BUILD_CONFIG) { - $env:MORYX_BUILD_CONFIG = "Debug"; - } - - if (-not $env:MORYX_BUILD_VERBOSITY) { - $env:MORYX_BUILD_VERBOSITY = "minimal" - } - - if (-not $env:MORYX_TEST_VERBOSITY) { - $env:MORYX_TEST_VERBOSITY = "normal" - } - - if (-not $env:MORYX_NUGET_VERBOSITY) { - $env:MORYX_NUGET_VERBOSITY = "normal" - } - - if (-not $env:MORYX_OPTIMIZE_CODE) { - $env:MORYX_OPTIMIZE_CODE = $True; - } - else { - if (-not [bool]::TryParse($env:MORYX_OPTIMIZE_CODE, [ref]$env:MORYX_OPTIMIZE_CODE)) { - $env:MORYX_OPTIMIZE_CODE = $True; - } - } - - if (-not $env:MORYX_PACKAGE_TARGET) { - $env:MORYX_PACKAGE_TARGET = ""; - } - - if (-not $env:MORYX_PACKAGE_TARGET_V3) { - $env:MORYX_PACKAGE_TARGET_V3 = ""; - } - - if (-not $env:MORYX_ASSEMBLY_VERSION) { - $env:MORYX_ASSEMBLY_VERSION = $Version; - } - - if (-not $env:MORYX_FILE_VERSION) { - $env:MORYX_FILE_VERSION = $Version; - } - - if (-not $env:MORYX_INFORMATIONAL_VERSION) { - $env:MORYX_INFORMATIONAL_VERSION = $Version; - } - - if (-not $env:MORYX_PACKAGE_VERSION) { - $env:MORYX_PACKAGE_VERSION = $Version; - } - - Set-Version $Version; - - # Printing Variables - Write-Step "Printing global variables" - Write-Variable "RootPath" $RootPath; - Write-Variable "DocumentationDir" $DocumentationDir; - Write-Variable "NunitReportsDir" $NunitReportsDir; - - Write-Step "Printing global scope" - Write-Variable "OpenCoverCli" $global:OpenCoverCli; - Write-Variable "NUnitCli" $global:NUnitCli; - Write-Variable "ReportGeneratorCli" $global:ReportGeneratorCli; - Write-Variable "DocFxCli" $global:DocFxCli; - Write-Variable "OpenCoverToCoberturaCli" $global:OpenCoverToCoberturaCli; - Write-Variable "GitCli" $global:GitCli; - Write-Variable "GitCommitHash" $global:GitCommitHash; - - Write-Step "Printing environment variables" - Write-Variable "MORYX_OPTIMIZE_CODE" $env:MORYX_OPTIMIZE_CODE; - Write-Variable "MORYX_BUILDNUMBER" $env:MORYX_BUILDNUMBER; - Write-Variable "MORYX_BUILD_CONFIG" $env:MORYX_BUILD_CONFIG; - Write-Variable "MORYX_BUILD_VERBOSITY" $env:MORYX_BUILD_VERBOSITY; - Write-Variable "MORYX_TEST_VERBOSITY" $env:MORYX_TEST_VERBOSITY; - Write-Variable "MORYX_NUGET_VERBOSITY" $env:MORYX_NUGET_VERBOSITY; - Write-Variable "MORYX_PACKAGE_TARGET" $env:MORYX_PACKAGE_TARGET; - Write-Variable "MORYX_PACKAGE_TARGET_V3" $env:MORYX_PACKAGE_TARGET_V3; - - Write-Variable "MORYX_ASSEMBLY_VERSION" $env:MORYX_ASSEMBLY_VERSION; - Write-Variable "MORYX_FILE_VERSION" $env:MORYX_FILE_VERSION; - Write-Variable "MORYX_INFORMATIONAL_VERSION" $env:MORYX_INFORMATIONAL_VERSION; - Write-Variable "MORYX_PACKAGE_VERSION" $env:MORYX_PACKAGE_VERSION; - - - # Cleanp - if ($Cleanup) { - Write-Step "Cleanup" - - Write-Host "Cleaning up repository ..." -ForegroundColor Red; - & $global:GitCli clean -f -d -x - Invoke-ExitCodeCheck $LastExitCode; - - & $global:GitCli checkout . - Invoke-ExitCodeCheck $LastExitCode; - } -} - -function Invoke-Cleanup { - # Clean up - Write-Step "Cleaning up repository ..."; - & $global:GitCli clean -f -d -x - Invoke-ExitCodeCheck $LastExitCode; -} - -function Install-Tool([string]$PackageName, [string]$Version, [string]$TargetExecutable, [string]$OutputDirectory = $BuildTools) { - if (-not (Test-Path $TargetExecutable)) { - & $global:NugetCli install $PackageName -version $Version -outputdirectory $OutputDirectory -configfile $NugetConfig - Invoke-ExitCodeCheck $LastExitCode; - } - else { - Write-Host "$PackageName ($Version) already exists. Do not need to install." - } -} - -function Invoke-Build([string]$ProjectFile, [string]$Options = "") { - Write-Step "Building $ProjectFile" - - # TODO: maybe we find a better way: currently all packages of all solutions are restored. - ForEach ($solution in (Get-ChildItem $RootPath -Filter "*.sln")) { - Write-Host "Restoring Nuget packages of $solution"; - - & $global:DotNetCli restore $solution --verbosity $env:MORYX_NUGET_VERBOSITY --configfile $NugetConfig; - Invoke-ExitCodeCheck $LastExitCode; - } - - $additonalOptions = ""; - if (-not [string]::IsNullOrEmpty($Options)) { - $additonalOptions = ",$Options"; - } - - $msbuildParams = "Optimize=" + (&{If($env:MORYX_OPTIMIZE_CODE -eq $True) {"true"} Else {"false"}}) + ",DebugSymbols=true$additonalOptions"; - $buildArgs = "--configuration", "$env:MORYX_BUILD_CONFIG"; - $buildArgs += "--verbosity", $env:MORYX_BUILD_VERBOSITY; - $buildArgs += "-p:$msbuildParams" - - & $global:DotNetCli build $ProjectFile @buildArgs - Invoke-ExitCodeCheck $LastExitCode; -} - -function Invoke-Nunit([string]$SearchPath = $RootPath, [string]$SearchFilter = "*.csproj") { - $randomIncrement = Get-Random -Minimum 2000 -Maximum 2100 - Write-Step "Running $Name Tests: $SearchPath" - - $testProjects = Get-ChildItem $SearchPath -Recurse -Include $SearchFilter - if ($testProjects.Length -eq 0) { - Write-Host-Warning "No test projects found!" - return; - } - - $env:PORT_INCREMENT = $randomIncrement; - - if (-not (Test-Path $global:NUnitCli)) { - Install-Tool "NUnit.Console" $NunitVersion $global:NunitCli; - } - - CreateFolderIfNotExists $NunitReportsDir; - - ForEach($testProject in $testProjects ) { - $projectName = ([System.IO.Path]::GetFileNameWithoutExtension($testProject.Name)); - $testAssembly = [System.IO.Path]::Combine($testProject.DirectoryName, "bin", $env:MORYX_BUILD_CONFIG, "$projectName.dll"); - - # If assembly does not exists, the project will be build - if (-not (Test-Path $testAssembly)) { - Invoke-Build $testProject - } - - & $global:NUnitCli $testProject /config:"$env:MORYX_BUILD_CONFIG" - } - - Invoke-ExitCodeCheck $LastExitCode; -} - -function Invoke-SmokeTest([string]$RuntimePath, [int]$ModulesCount, [int]$InterruptTime) { - $randomIncrement = Get-Random -Minimum 2000 -Maximum 2100 - Write-Step "Invoking Runtime SmokeTest Modules: $ModulesCount, Interrupt Time: $InterruptTime, Port Increment: $randomIncrement." - - & "$RuntimePath" @("smokeTest", "-e $ModulesCount", "-i $InterruptTime", "-p $randomIncrement") - Invoke-ExitCodeCheck $LastExitCode; -} - -function Invoke-CoverTests($SearchPath = $RootPath, $SearchFilter = "*.csproj", $FilterFile = "$RootPath\OpenCoverFilter.txt") { - Write-Step "Starting cover tests from $SearchPath with filter $FilterFile." - - if (-not (Test-Path $SearchPath)) { - Write-Host-Warning "$SearchPath does not exists, ignoring!"; - return; - } - - $testProjects = Get-ChildItem $SearchPath -Recurse -Include $SearchFilter - if ($testProjects.Length -eq 0) { - Write-Host-Warning "No test projects found!" - return; - } - - if (-not (Test-Path $global:NUnitCli)) { - Install-Tool "NUnit.Console" $NunitVersion $global:NunitCli; - } - - if (-not (Test-Path $global:OpenCoverCli)) { - Install-Tool "OpenCover" $OpenCoverVersion $global:OpenCoverCli; - } - - if (-not (Test-Path $global:OpenCoverToCoberturaCli)) { - Install-Tool "OpenCoverToCoberturaConverter" $OpenCoverToCoberturaVersion $global:OpenCoverToCoberturaCli; - } - - CreateFolderIfNotExists $OpenCoverReportsDir; - CreateFolderIfNotExists $NunitReportsDir; - - $includeFilter = "+[Moryx*]*"; - $excludeFilter = "-[*nunit*]* -[*Tests]* -[*Model*]*"; - - if (Test-Path $FilterFile) { - $ignoreContent = Get-Content $FilterFile; - - foreach ($line in $ignoreContent) { - $parts = $line.Split(":"); - if ($parts.Count -lt 2) { - continue - } - - $filterType = $parts[0]; - $filterValue = $parts[1]; - - if ($filterType.StartsWith("INCLUDE")) { - $includeFilter += " $filterValue"; - } - - if ($filterType.StartsWith("EXCLUDE")) { - $excludeFilter += " $filterValue"; - } - } - - Write-Host "Active Filter: `r`n Include: $includeFilter `r`n Exclude: $excludeFilter"; - } - - ForEach($testProject in $testProjects ) { - $projectName = ([System.IO.Path]::GetFileNameWithoutExtension($testProject.Name)); - $testAssembly = [System.IO.Path]::Combine($testProject.DirectoryName, "bin", $env:MORYX_BUILD_CONFIG, "$projectName.dll"); - $isNetCore = Get-CsprojIsNetCore($testProject); - - Write-Host "OpenCover Test: ${projectName}:"; - - $nunitXml = ($NunitReportsDir + "\$projectName.TestResult.xml"); - $openCoverXml = ($OpenCoverReportsDir + "\$projectName.OpenCover.xml"); - $coberturaXml = ($CoberturaReportsDir + "\$projectName.Cobertura.xml"); - - if ($isNetCore) { - $targetArgs = '"test -v ' + $env:MORYX_TEST_VERBOSITY + ' -c ' + $env:MORYX_BUILD_CONFIG + ' ' + $testProject + '"'; - $openCoverAgs = "-target:$global:DotNetCli", "-targetargs:$targetArgs" - } - else { - # If assembly does not exists, the project will be build - if (-not (Test-Path $testAssembly)) { - Invoke-Build $testProject - } - - $openCoverAgs = "-target:$global:NunitCli", "-targetargs:/config:$env:MORYX_BUILD_CONFIG /result:$nunitXml $testAssembly" - } - - $openCoverAgs += "-log:Debug", "-register:administrator", "-output:$openCoverXml", "-hideskipped:all", "-skipautoprops"; - $openCoverAgs += "-returntargetcode" # We need the nunit return code - $openCoverAgs += "-filter:$includeFilter $excludeFilter" - - & $global:OpenCoverCli $openCoverAgs - - $exitCode = [int]::Parse($LastExitCode); - if ($exitCode -ne 0) { - $errorText = ""; - switch ($exitCode) { - -1 { $errorText = "INVALID_ARG"; } - -2 { $errorText = "INVALID_ASSEMBLY"; } - -4 { $errorText = "INVALID_TEST_FIXTURE"; } - -5 { $errorText = "UNLOAD_ERROR"; } - Default { $errorText = "UNEXPECTED_ERROR"; } - } - - if ($exitCode -gt 0) { - $errorText = "FAILED_TESTS ($exitCode)"; - } - - Write-Host-Error "Nunit exited with $errorText for $projectName"; - Invoke-ExitCodeCheck $exitCode; - } - - & $global:OpenCoverToCoberturaCli -input:$openCoverXml -output:$coberturaXml -sources:$rootPath - Invoke-ExitCodeCheck $LastExitCode; - } -} - -function Get-CsprojIsNetCore($CsprojItem) { - [xml]$csprojContent = Get-Content $CsprojItem.FullName - $sdkProject = $csprojContent.Project.Sdk; - if ($null -ne $sdkProject) { - # Read Target Framework - $targetFramework = $csprojContent.Project.PropertyGroup.TargetFramework; - if ($targetFramework -Match "netcoreapp" -or $targetFramework -Match "net5.") { - # NETCore - return $true; - } - } - return $false; -} - -function Get-CsprojIsSdkProject($CsprojItem) { - [xml]$csprojContent = Get-Content $CsprojItem.FullName - $sdkProject = $csprojContent.Project.Sdk; - if ($null -ne $sdkProject) { - return $true; - } - return $false; -} - -function Invoke-CoverReport { - Write-Step "Creating cover report. Searching for OpenCover.xml files in $OpenCoverReportsDir." - - if (-not (Test-Path $OpenCoverReportsDir)) { - Write-Host-Error "$OpenCoverReportsDir was not found!"; - Invoke-ExitCodeCheck 1; - } - - if (-not (Test-Path $global:ReportGeneratorCli)) { - Install-Tool "ReportGenerator" $ReportGeneratorVersion $global:ReportGeneratorCli; - } - - $reports = (Get-ChildItem $OpenCoverReportsDir -Recurse -Include '*.OpenCover.xml'); - $asArgument = [string]::Join(";",$reports); - - CreateFolderIfNotExists $DocumentationArtifcacts; - - & $global:ReportGeneratorCli -reports:"$asArgument" -targetDir:"$DocumentationArtifcacts/OpenCover" - Invoke-ExitCodeCheck $LastExitCode; -} - -function Invoke-DocFx($Metadata = [System.IO.Path]::Combine($DocumentationDir, "docfx.json")) { - Write-Step "Generating documentation using DocFx" - - if (-not (Test-Path $Metadata)) { - Write-Host-Error "Metadata was not found at: $Metadata!" - Invoke-ExitCodeCheck 1; - } - - if (-not (Test-Path $global:DocFxCli)) { - Install-Tool "docfx.console" $DocFxVersion $global:DocFxCli; - } - - $docFxObj = (Get-Content $Metadata) | ConvertFrom-Json; - $metadataFolder = [System.IO.Path]::GetDirectoryName($Metadata); - $docFxDest = [System.IO.Path]::Combine($metadataFolder, $docFxObj.build.dest); - - & $global:DocFxCli $Metadata; - Invoke-ExitCodeCheck $LastExitCode; - - CreateFolderIfNotExists $DocumentationArtifcacts; - CopyAndReplaceFolder $docFxDest "$DocumentationArtifcacts\DocFx"; -} - -function Invoke-PackSdkProject($CsprojItem, [bool]$IncludeSymbols = $False) { - Write-Host "Try to pack .NET SDK project: $($CsprojItem.Name) ..."; - - # Check if the project should be packed - $csprojFullName = $CsprojItem.FullName; - [xml]$csprojContent = Get-Content $csprojFullName - $createPackage = $csprojContent.Project.PropertyGroup.CreatePackage; -; - if ($null -eq $createPackage -or "false" -eq $createPackage) { - Write-Host-Warning "... csproj not flagged with true: $($CsprojItem.Name)"; - return; - } - - $packargs = "--output", "$NugetPackageArtifacts"; - $packargs += "--configuration", "$env:MORYX_BUILD_CONFIG"; - $packargs += "--verbosity", "$env:MORYX_NUGET_VERBOSITY"; - $packargs += "--no-build"; - - if ($IncludeSymbols) { - $packargs += "--include-symbols"; - $packargs += "--include-source"; - } - - & $global:DotNetCli pack "$csprojFullName" @packargs - Invoke-ExitCodeCheck $LastExitCode; -} - -function Invoke-PackFrameworkProject($CsprojItem, [bool]$IsTool = $False, [bool]$IncludeSymbols = $False) { - Write-Host "Try to pack .NET Framework project: $CsprojItem.Name ..."; - - # Check if there is a matching nuspec for the proj - $csprojFullName = $CsprojItem.FullName; - $nuspecPath = [IO.Path]::ChangeExtension($csprojFullName, "nuspec") - if(-not (Test-Path $nuspecPath)) { - Write-Host-Warning "Nuspec for project not found: $CsprojItem.Name"; - return; - } - - $packargs = "-outputdirectory", "$NugetPackageArtifacts"; - $packargs += "-includereferencedprojects"; - $packargs += "-Version", "$env:MORYX_PACKAGE_VERSION"; - $packargs += "-Prop", "Configuration=$env:MORYX_BUILD_CONFIG"; - $packargs += "-Verbosity", "$env:MORYX_NUGET_VERBOSITY"; - - if ($IncludeSymbols) { - $packargs += "-Symbols"; - } - - if ($IsTool) { - $packargs += "-Tool"; - } - - # Call nuget with default arguments plus optional - & $global:NugetCli pack "$csprojFullName" @packargs - Invoke-ExitCodeCheck $LastExitCode; -} - -function Invoke-Pack($ProjectItem, [bool]$IsTool = $False, [bool]$IncludeSymbols = $False) { - CreateFolderIfNotExists $NugetPackageArtifacts; - - if (Get-CsprojIsSdkProject($ProjectItem)) { - Invoke-PackSdkProject $ProjectItem $IncludeSymbols; - } - else { - Invoke-PackFrameworkProject $ProjectItem $IsTool $IncludeSymbols; - } -} - -function Invoke-PackAll([switch]$Symbols = $False) { - Write-Host "Looking for .csproj files..." - # Look for csproj in this directory - foreach ($csprojItem in Get-ChildItem $RootPath -Recurse -Filter *.csproj) { - Invoke-Pack -ProjectItem $csprojItem -IncludeSymbols $Symbols - } -} - -function Invoke-Publish { - Write-Host "Pushing packages from $NugetPackageArtifacts to $env:MORYX_PACKAGE_TARGET" - - $packages = Get-ChildItem $NugetPackageArtifacts -Recurse -Include *.nupkg - if ($packages.Length -gt 0 -and [string]::IsNullOrEmpty($env:MORYX_PACKAGE_TARGET)) { - Write-Host-Error "There is no package target given. Set the environment varialble MORYX_PACKAGE_TARGET to publish packages."; - Invoke-ExitCodeCheck 1; - } - - foreach ($package in $packages) { - Write-Host "Pushing package $package" - & $global:DotNetCli nuget push $package --api-key $env:MORYX_NUGET_APIKEY --no-symbols --skip-duplicate --source $env:MORYX_PACKAGE_TARGET - Invoke-ExitCodeCheck $LastExitCode; - } - - $symbolPackages = Get-ChildItem $NugetPackageArtifacts -Recurse -Include *.snupkg - if ($symbolPackages.Length -gt 0 -and [string]::IsNullOrEmpty($env:MORYX_PACKAGE_TARGET_V3)) { - Write-Host-Error "There is no package (v3) target given. Set the environment varialble MORYX_PACKAGE_TARGET_V3 to publish snupkg symbol packages."; - Invoke-ExitCodeCheck 1; - } - - foreach ($symbolPackage in $symbolPackages) { - Write-Host "Pushing symbol (snupkg) $symbolPackage" - & $global:DotNetCli nuget push $symbolPackage --api-key $env:MORYX_NUGET_APIKEY --skip-duplicate --source $env:MORYX_PACKAGE_TARGET_V3 - Invoke-ExitCodeCheck $LastExitCode; - } -} - -function Set-Version ([string]$MajorMinorPatch) { - $semVer2Regex = "^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"; - - $version = Read-VersionFromRef($MajorMinorPatch); - Write-Host "Setting environment version to $version"; - - # Match semVer2 regex - $regexMatch = [regex]::Match($version, $semVer2Regex); - - if (-not $regexMatch.Success) { - Write-Host "Could not parse version: $version"; - Invoke-ExitCodeCheck 1; - } - - # Extract groups - $matchgroups = $regexMatch.captures.groups; - $majorGroup = $matchgroups[1]; - $minorGroup = $matchgroups[2]; - $patchGroup = $matchgroups[3]; - $preReleaseGroup = $matchgroups[4]; - - # Compose Major.Minor.Patch - $mmp = $majorGroup.Value + "." + $minorGroup.Value + "." + $patchGroup.Value; - - # Check if it is a pre release - $env:MORYX_ASSEMBLY_VERSION = $majorGroup.Value + ".0.0.0" # 3.0.0.0 - $env:MORYX_FILE_VERSION = $mmp + "." + $env:MORYX_BUILDNUMBER; # 3.1.2.42 - - if ($preReleaseGroup.Success) { - $env:MORYX_INFORMATIONAL_VERSION = $mmp + "-" + $preReleaseGroup.Value + "+" + $global:GitCommitHash; # 3.1.2-beta.1+d95a996ed5ba14a1421dafeb844a56ab08211ead - $env:MORYX_PACKAGE_VERSION = $mmp + "-" + $preReleaseGroup.Value; - } else { - $env:MORYX_INFORMATIONAL_VERSION = $mmp + "+" + $global:GitCommitHash; # 3.1.2+d95a996ed5ba14a1421dafeb844a56ab08211ead - $env:MORYX_PACKAGE_VERSION = $mmp; - } -} - -function Read-VersionFromRef([string]$MajorMinorPatch) { - function preReleaseVersion ([string] $name) - { - $name = $name.Replace("/","").ToLower(); - return "$MajorMinorPatch-$name.$env:MORYX_BUILDNUMBER";; - } - - $ref = ""; - if ($env:GITHUB_WORKFLOW) { # GitHub Workflow - Write-Host "Reading version from 'GitHub Workflow'"; - $ref = $env:GITHUB_REF; - - if ($ref.StartsWith("refs/tags/")) { - if ($ref.StartsWith("refs/tags/v")) { - # Its a version tag - $version = $ref.Replace("refs/tags/v","") - } - else { - # Just a tag - $name = $ref.Replace("refs/tags/",""); - $version = = preReleaseVersion($name); - } - } - elseif ($ref.StartsWith("refs/heads/")) { - # Its a branch - $name = $ref.Replace("refs/heads/",""); - $version = preReleaseVersion($name); - } - else { - $version = preReleaseVersion($ref); - } - } - else { # Local build - Write-Host "Reading version from 'local'"; - $ref = (& $global:GitCli rev-parse --abbrev-ref HEAD); - $version = preReleaseVersion($ref); - } - - return $version; -} - -function Set-AssemblyVersion([string]$InputFile) { - $file = Get-Childitem -Path $inputFile; - - if (-Not $file) { - Write-Host "AssemblyInfo: $inputFile was not found!"; - exit 1; - } - - Write-Host "Applying assembly info of $($file.FullName) -> $env:MORYX_ASSEMBLY_VERSION "; - - $assemblyVersionPattern = 'AssemblyVersion\("[0-9]+(\.([0-9]+)){3}"\)'; - $assemblyVersion = 'AssemblyVersion("' + $env:MORYX_ASSEMBLY_VERSION + '")'; - - $assemblyFileVersionPattern = 'AssemblyFileVersion\("[0-9]+(\.([0-9]+)){3}"\)'; - $assemblyFileVersion = 'AssemblyFileVersion("' + $env:MORYX_FILE_VERSION + '")'; - - $assemblyInformationalVersionPattern = 'AssemblyInformationalVersion\("[0-9]+(\.([0-9]+)){3}"\)'; - $assemblyInformationalVersion = 'AssemblyInformationalVersion("' + $env:MORYX_INFORMATIONAL_VERSION + '")'; - - $assemblyConfigurationPattern = 'AssemblyConfiguration\("\w+"\)'; - $assemblyConfiguration = 'AssemblyConfiguration("' + $env:MORYX_BUILD_CONFIG + '")'; - - $content = (Get-Content $file.FullName) | ForEach-Object { - ForEach-Object {$_ -replace $assemblyVersionPattern, $assemblyVersion } | - ForEach-Object {$_ -replace $assemblyFileVersionPattern, $assemblyFileVersion } | - ForEach-Object {$_ -replace $assemblyInformationalVersionPattern, $assemblyInformationalVersion } | - ForEach-Object {$_ -replace $assemblyConfigurationPattern, $assemblyConfiguration } - } - - Out-File -InputObject $content -FilePath $file.FullName -Encoding utf8; -} - -function Set-AssemblyVersions([string[]]$Ignored = $(), [string]$SearchPath = $RootPath) { - $Ignored = $Ignored + "\\.build\\" + "\\Tests\\" + "\\IntegrationTests\\" + "\\SystemTests\\"; - - $assemblyInfos = Get-ChildItem -Path $RootPath -include "*AssemblyInfo.cs" -Recurse | Where-Object { - $fullName = $_.FullName; - return -not ($Ignored.Where({ $fullName -match $_ }).Count -gt 0); - } - - if ($assemblyInfos) - { - Write-Host "Will apply version to $($assemblyInfos.Count) AssemblyInfos."; - foreach ($file in $assemblyInfos) { - Set-AssemblyVersion -InputFile $file; - } - } -} - -function CreateFolderIfNotExists([string]$Folder) { - if (-not (Test-Path $Folder)) { - Write-Host "Creating missing directory '$Folder'" - New-Item $Folder -Type Directory | Out-Null - } -} - -function CopyAndReplaceFolder($SourceDir, $TargetDir) { - Write-Host-Info "Copy $SourceDir to $TargetDir!" - # Remove old folder if exists - if (Test-Path $TargetDir) { - Write-Host "Target path already exists, removing ..." -ForegroundColor Yellow - Remove-Item -Recurse -Force $TargetDir - } - - # Copy to target path - Write-Host "Copy from $SourceDir to $TargetDir ..." -ForegroundColor Green - Copy-Item -Path $SourceDir -Recurse -Destination $TargetDir -Container -} diff --git a/.build/Common.props b/.build/Common.props deleted file mode 100644 index d5b059b..0000000 --- a/.build/Common.props +++ /dev/null @@ -1,31 +0,0 @@ - - - - 0.0.0 - $(MORYX_ASSEMBLY_VERSION) - - 0.0.0.0 - $(MORYX_FILE_VERSION) - - 0.0.0.0 - $(MORYX_INFORMATIONAL_VERSION) - - 0.0.0 - $(MORYX_PACKAGE_VERSION) - - PHOENIXCONTACT - PHOENIX CONTACT - MORYX - - $([System.DateTime]::Now.ToString("yyyy")) - Copyright © PHOENIX CONTACT $(CurrentYear) - - moryx-logo.png - https://moryx-industry.net/ - - - - - - - \ No newline at end of file diff --git a/.build/Output.ps1 b/.build/Output.ps1 deleted file mode 100644 index 913f557..0000000 --- a/.build/Output.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -################################ -# Functions for Console Output # -################################ - -function Write-Step([string]$step) { - Write-Host "########################################################################################################" -foreground Magenta; - Write-Host "#### $step" -foreground Magenta; - Write-Host "########################################################################################################" -foreground Magenta -} - -function Write-Variable ([string]$variableName, [string]$variableValue) { - Write-Host ($variableName + " = " + $variableValue) -} - -function Invoke-ExitCodeCheck([string]$exitCode) { - if ([int]::Parse($exitCode) -gt 0) { - Write-Host "This is the end, you know (ExitCode: $exitCode) - Lady, the plans we had went all wrong - We ain't nothing but fight and shout and tears." -ForegroundColor Red - exit $exitCode; - } -} - -function Write-Host-Info([string]$message) { - Write-Host $message -} - -function Write-Host-Success([string]$message) { - Write-Host $message -ForegroundColor Green -} - -function Write-Host-Warning([string]$message) { - Write-Host $message -ForegroundColor Yellow -} - -function Write-Host-Error([string]$message) { - Write-Host $message -ForegroundColor Red -} \ No newline at end of file diff --git a/.build/moryx-logo.png b/.build/moryx-logo.png deleted file mode 100644 index 5d9def6..0000000 Binary files a/.build/moryx-logo.png and /dev/null differ diff --git a/.github/workflows/build-and-test-tool.yml b/.github/workflows/build-and-test-tool.yml index f276f12..300de10 100644 --- a/.github/workflows/build-and-test-tool.yml +++ b/.github/workflows/build-and-test-tool.yml @@ -12,94 +12,88 @@ on: branches: - dev - future - + env: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true REPOSITORY_NAME: ${{ github.event.repository.name }} + MORYX_PACKAGE_TARGET_DEV: 'https://www.myget.org/F/moryx/api/v2/package' + MORYX_PACKAGE_TARGET_V3_DEV: 'https://www.myget.org/F/moryx/api/v3/index.json' + MORYX_PACKAGE_TARGET_FUTURE: 'https://www.myget.org/F/moryx-future/api/v2/package' + MORYX_PACKAGE_TARGET_V3_FUTURE: 'https://www.myget.org/F/moryx-future/api/v3/index.json' + MORYX_PACKAGE_TARGET_RELEASE: 'https://api.nuget.org/v3/index.json' + MORYX_PACKAGE_TARGET_V3_RELEASE: 'https://api.nuget.org/v3/index.json' jobs: + EnvVar: + runs-on: ubuntu-latest + steps: + - run: echo "" + outputs: + dotnet_sdk_version: ${{ env.dotnet_sdk_version }} + REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }} + MORYX_PACKAGE_TARGET_DEV: ${{ env.MORYX_PACKAGE_TARGET_DEV }} + MORYX_PACKAGE_TARGET_V3_DEV: ${{ env.MORYX_PACKAGE_TARGET_V3_DEV }} + MORYX_PACKAGE_TARGET_FUTURE: ${{ env.MORYX_PACKAGE_TARGET_FUTURE }} + MORYX_PACKAGE_TARGET_V3_FUTURE: ${{ env.MORYX_PACKAGE_TARGET_V3_FUTURE }} + MORYX_PACKAGE_TARGET_RELEASE: ${{ env.MORYX_PACKAGE_TARGET_RELEASE }} + MORYX_PACKAGE_TARGET_V3_RELEASE: ${{ env.MORYX_PACKAGE_TARGET_V3_RELEASE }} + Build: - uses: PHOENIXCONTACT/tools/.github/workflows/build-tool.yml@main + needs: [EnvVar] + uses: phoenixcontact/tools/.github/workflows/build-tool.yml@main with: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} - dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - REPOSITORY_NAME: ${{ github.event.repository.name }} + dotnet_sdk_version: ${{ needs.EnvVar.outputs.dotnet_sdk_version }} + REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} UnitTests: - needs: [Build] - uses: PHOENIXCONTACT/tools/.github/workflows/unittest-tool.yml@main + needs: [EnvVar, Build] + uses: phoenixcontact/tools/.github/workflows/unittest-tool.yml@main with: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} - dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - REPOSITORY_NAME: ${{ github.event.repository.name }} + dotnet_sdk_version: ${{ needs.EnvVar.outputs.dotnet_sdk_version }} + REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} IntegrationTests: - needs: [Build] - uses: PHOENIXCONTACT/tools/.github/workflows/integrationtest-tool.yml@main + needs: [EnvVar, Build] + uses: phoenixcontact/tools/.github/workflows/integrationtest-tool.yml@main with: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} - dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - REPOSITORY_NAME: ${{ github.event.repository.name }} + dotnet_sdk_version: ${{ needs.EnvVar.outputs.dotnet_sdk_version }} + REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} ReportGenerator: - needs: [UnitTests, IntegrationTests] - uses: PHOENIXCONTACT/tools/.github/workflows/reportgenerator-tool.yml@main + needs: [EnvVar, UnitTests, IntegrationTests] + uses: phoenixcontact/tools/.github/workflows/reportgenerator-tool.yml@main with: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} - dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - REPOSITORY_NAME: ${{ github.event.repository.name }} + REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} Publish-Test-Coverage: - needs: [ReportGenerator] - uses: PHOENIXCONTACT/tools/.github/workflows/publish-test-coverage-tool.yml@main + needs: [EnvVar, ReportGenerator] + uses: phoenixcontact/tools/.github/workflows/publish-test-coverage-tool.yml@main with: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} - dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - REPOSITORY_NAME: ${{ github.event.repository.name }} + REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} secrets: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - Documentation: - needs: [UnitTests] - uses: PHOENIXCONTACT/tools/.github/workflows/documentation-tool.yml@main - with: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} - dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - REPOSITORY_NAME: ${{ github.event.repository.name }} + # currently not working with .Net 8 and in Framework-repo + # Documentation: + # needs: [EnvVar, UnitTests] + # uses: phoenixcontact/tools/.github/workflows/documentation-tool.yml@main + # with: + # REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} Publish: - needs: [UnitTests] - uses: PHOENIXCONTACT/tools/.github/workflows/publish-tool.yml@main + needs: [EnvVar, UnitTests] + uses: phoenixcontact/tools/.github/workflows/publish-tool.yml@main with: - MORYX_OPTIMIZE_CODE: "false" - MORYX_BUILD_CONFIG: "Release" - MORYX_BUILDNUMBER: ${{github.run_number}} - dotnet_sdk_version: '7.x' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - REPOSITORY_NAME: ${{ github.event.repository.name }} + dotnet_sdk_version: ${{ needs.EnvVar.outputs.dotnet_sdk_version }} + REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} + MORYX_PACKAGE_TARGET_DEV: ${{ needs.EnvVar.outputs.MORYX_PACKAGE_TARGET_DEV }} + MORYX_PACKAGE_TARGET_V3_DEV: ${{ needs.EnvVar.outputs.MORYX_PACKAGE_TARGET_V3_DEV }} + MORYX_PACKAGE_TARGET_FUTURE: ${{ needs.EnvVar.outputs.MORYX_PACKAGE_TARGET_FUTURE }} + MORYX_PACKAGE_TARGET_V3_FUTURE: ${{ needs.EnvVar.outputs.MORYX_PACKAGE_TARGET_V3_FUTURE }} + MORYX_PACKAGE_TARGET_RELEASE: ${{ needs.EnvVar.outputs.MORYX_PACKAGE_TARGET_RELEASE }} + MORYX_PACKAGE_TARGET_V3_RELEASE: ${{ needs.EnvVar.outputs.MORYX_PACKAGE_TARGET_V3_RELEASE }} secrets: MYGET_TOKEN: ${{secrets.MYGET_TOKEN}} NUGET_TOKEN: ${{secrets.NUGET_TOKEN}} + \ No newline at end of file diff --git a/.github/workflows/build-tool.yml b/.github/workflows/build-tool.yml index ab39858..b38d272 100644 --- a/.github/workflows/build-tool.yml +++ b/.github/workflows/build-tool.yml @@ -9,47 +9,80 @@ on: REPOSITORY_NAME: required: true type: string - MORYX_OPTIMIZE_CODE: - required: false - type: string - MORYX_BUILD_CONFIG: - required: false - type: string - MORYX_BUILDNUMBER: - required: false - type: string - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: - required: false - type: boolean - + jobs: Build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup .NET SDK - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ inputs.dotnet_sdk_version }} + # - name: Setup .NET SDK + # uses: actions/setup-dotnet@v3 + # with: + # dotnet-version: 6.x - name: Setup Node version uses: actions/setup-node@v3 with: node-version: 16 - - name: Build - shell: pwsh - env: - MORYX_BUILDNUMBER: ${{inputs.MORYX_BUILDNUMBER}} - MORYX_OPTIMIZE_CODE: ${{inputs.MORYX_OPTIMIZE_CODE}} - MORYX_BUILD_CONFIG: ${{inputs.MORYX_BUILD_CONFIG}} - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: ${{inputs.DOTNET_SKIP_FIRST_TIME_EXPERIENCE}} - run: ./Build.ps1 -Build -Pack + - name: Setup .NET SDK standard (7) + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ inputs.dotnet_sdk_version }} + + - name: Clean + run: dotnet clean && dotnet nuget locals all --clear + + - name: Execute dotnet restore + run: dotnet restore + - name: Execute dotnet build + if: ${{ !(startsWith(github.ref, 'refs/tags/v')) }} + run: | + ASSEMBLY_VERSION="$(cat VERSION)" + ASSEMBLY_VERSION="${ASSEMBLY_VERSION%%.*}".0.0.0 + echo "ASSEMBLY_VERSION = ${ASSEMBLY_VERSION}" + FILE_VERSION="$(cat VERSION)"."${{github.run_number}}" + echo "FILE_VERSION = ${FILE_VERSION}" + INFORMATIONAL_VERSION="$(cat VERSION)"-"${{github.ref_name}}"."${{github.run_number}}" + echo "INFORMATIONAL_VERSION = ${INFORMATIONAL_VERSION}" + dotnet build --configuration Release --no-restore -p:AssemblyVersion=$ASSEMBLY_VERSION -p:FileVersion=$FILE_VERSION -p:InformationalVersion=$INFORMATIONAL_VERSION + + + - name: Execute dotnet build (Release) + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + ASSEMBLY_VERSION="${{github.ref_name}}" + ASSEMBLY_VERSION="${ASSEMBLY_VERSION#v}" + ASSEMBLY_VERSION="${ASSEMBLY_VERSION%%.*}".0.0.0 + echo "ASSEMBLY_VERSION = ${ASSEMBLY_VERSION}" + FILE_VERSION="$(cat VERSION)"."${{github.run_number}}" + echo "FILE_VERSION = ${FILE_VERSION}" + INFORMATIONAL_VERSION="$(cat VERSION)"-"${{github.ref_name}}"."${{github.run_number}}" + echo "INFORMATIONAL_VERSION = ${INFORMATIONAL_VERSION}" + dotnet build --configuration Release --no-restore -p:AssemblyVersion=$ASSEMBLY_VERSION -p:FileVersion=$FILE_VERSION -p:InformationalVersion=$INFORMATIONAL_VERSION + + + - name: Execute dotnet pack with release version + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + RELEASE_VERSION="${{github.ref_name}}" + RELEASE_VERSION="${RELEASE_VERSION#v}" + echo "RELEASE_VERSION = ${RELEASE_VERSION}" + dotnet pack --configuration Release --no-build --no-restore --output artifacts/packages -p:PackageVersion=$RELEASE_VERSION + + + - name: Execute dotnet pack with production version (dev or future) + if: ${{ github.ref_name == 'dev' || github.ref_name == 'future'}} + run: | + PRODUCTION_VERSION="$(cat VERSION)"-"${{github.ref_name}}"."${{github.run_number}}" + echo "PRODUCTION_VERSION = ${PRODUCTION_VERSION}" + dotnet pack --configuration Release --no-build --no-restore --output artifacts/packages -p:PackageVersion=$PRODUCTION_VERSION + - name: Upload package artifacts uses: actions/upload-artifact@v2 with: - name: packages - path: artifacts/Packages/ - retention-days: 1 \ No newline at end of file + name: ${{inputs.REPOSITORY_NAME}}-packages + path: artifacts/packages/ + retention-days: 1 diff --git a/.github/workflows/documentation-tool.yml b/.github/workflows/documentation-tool.yml index 7149621..7719e80 100644 --- a/.github/workflows/documentation-tool.yml +++ b/.github/workflows/documentation-tool.yml @@ -3,43 +3,28 @@ name: Documentation on: workflow_call: inputs: - dotnet_sdk_version: - required: true - type: string REPOSITORY_NAME: required: true type: string - MORYX_OPTIMIZE_CODE: - required: false - type: string - MORYX_BUILD_CONFIG: - required: false - type: string - MORYX_BUILDNUMBER: - required: false - type: string - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: - required: false - type: boolean jobs: Documentation: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Generate docFx - shell: pwsh - env: - MORYX_BUILDNUMBER: ${{inputs.MORYX_BUILDNUMBER}} - MORYX_OPTIMIZE_CODE: ${{inputs.MORYX_OPTIMIZE_CODE}} - MORYX_BUILD_CONFIG: ${{inputs.MORYX_BUILD_CONFIG}} - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: ${{inputs.DOTNET_SKIP_FIRST_TIME_EXPERIENCE}} - run: ./Build.ps1 -GenerateDocs + - uses: nuget/setup-nuget@v1 + with: + nuget-version: latest + + - name: Build Documentation + uses: nunit/docfx-action@v2.4.0 + with: + args: docs/docfx.json - name: Upload documentation results uses: actions/upload-artifact@v2 with: - name: documentation - path: artifacts/Documentation/ + name: ${{inputs.REPOSITORY_NAME}}-documentation + path: docs/_site retention-days: 2 \ No newline at end of file diff --git a/.github/workflows/integrationtest-tool.yml b/.github/workflows/integrationtest-tool.yml index a4fc85c..66edfd2 100644 --- a/.github/workflows/integrationtest-tool.yml +++ b/.github/workflows/integrationtest-tool.yml @@ -9,30 +9,23 @@ on: REPOSITORY_NAME: required: true type: string - MORYX_OPTIMIZE_CODE: - required: false - type: string - MORYX_BUILD_CONFIG: - required: false - type: string - MORYX_BUILDNUMBER: - required: false - type: string - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: - required: false - type: boolean jobs: IntegrationTests: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup .NET SDK + - name: Setup .NET SDK standard (7) uses: actions/setup-dotnet@v1 with: dotnet-version: ${{ inputs.dotnet_sdk_version }} + - name: Setup .NET SDK 6 for testing purposes + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.x + - name: Setup Node version uses: actions/setup-node@v3 with: @@ -41,18 +34,19 @@ jobs: - name: Clean run: dotnet clean && dotnet nuget locals all --clear - - name: Execute Integration Tests - shell: pwsh - env: - MORYX_BUILDNUMBER: ${{inputs.MORYX_BUILDNUMBER}} - MORYX_OPTIMIZE_CODE: ${{inputs.MORYX_OPTIMIZE_CODE}} - MORYX_BUILD_CONFIG: ${{inputs.MORYX_BUILD_CONFIG}} - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: ${{inputs.DOTNET_SKIP_FIRST_TIME_EXPERIENCE}} - run: ./Build.ps1 -IntegrationTests + - name: Execute dotnet restore + run: dotnet restore + - name: Execute dotnet build + run: dotnet build --no-restore + + - name: Execute dotnet test (needs coverlet.collector nuget) + run: dotnet test --no-build --filter FullyQualifiedName~Integration --collect:"XPlat Code Coverage" + - name: Upload test results uses: actions/upload-artifact@v2 with: name: ${{inputs.REPOSITORY_NAME}}-test-results - path: artifacts/Tests/ - retention-days: 1 \ No newline at end of file + path: src/Tests/**/TestResults/**/coverage.cobertura.xml + retention-days: 1 + diff --git a/.github/workflows/publish-test-coverage-tool.yml b/.github/workflows/publish-test-coverage-tool.yml index 93696c3..86cd0cb 100644 --- a/.github/workflows/publish-test-coverage-tool.yml +++ b/.github/workflows/publish-test-coverage-tool.yml @@ -3,24 +3,9 @@ name: Publish-Test-Coverage on: workflow_call: inputs: - dotnet_sdk_version: - required: true - type: string REPOSITORY_NAME: required: true type: string - MORYX_OPTIMIZE_CODE: - required: false - type: string - MORYX_BUILD_CONFIG: - required: false - type: string - MORYX_BUILDNUMBER: - required: false - type: string - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: - required: false - type: boolean secrets: AWS_ACCESS_KEY_ID: required: true diff --git a/.github/workflows/publish-tool.yml b/.github/workflows/publish-tool.yml index 0b1cd2f..4924745 100644 --- a/.github/workflows/publish-tool.yml +++ b/.github/workflows/publish-tool.yml @@ -9,28 +9,34 @@ on: REPOSITORY_NAME: required: true type: string - MORYX_OPTIMIZE_CODE: - required: false + MORYX_PACKAGE_TARGET_DEV: + required: true + type: string + MORYX_PACKAGE_TARGET_V3_DEV: + required: true + type: string + MORYX_PACKAGE_TARGET_FUTURE: + required: true + type: string + MORYX_PACKAGE_TARGET_V3_FUTURE: + required: true type: string - MORYX_BUILD_CONFIG: - required: false + MORYX_PACKAGE_TARGET_RELEASE: + required: true type: string - MORYX_BUILDNUMBER: - required: false + MORYX_PACKAGE_TARGET_V3_RELEASE: + required: true type: string - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: - required: false - type: boolean secrets: MYGET_TOKEN: - required: false + required: true NUGET_TOKEN: - required: false + required: true jobs: Publish: if: ${{ github.event_name == 'push' }} - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -38,48 +44,39 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: ${{ inputs.dotnet_sdk_version }} + + - name: Setup NuGet + uses: NuGet/setup-nuget@v1 - name: Download package artifacts uses: actions/download-artifact@v2 with: - name: packages - path: artifacts/Packages/ + name: ${{inputs.REPOSITORY_NAME}}-packages + path: artifacts/packages/ + # Use if dev branch - name: Publish on MyGet-CI if: ${{ github.ref == 'refs/heads/dev' }} # dev branche is published to myget moryx - shell: pwsh env: - MORYX_BUILDNUMBER: ${{inputs.MORYX_BUILDNUMBER}} - MORYX_OPTIMIZE_CODE: ${{inputs.MORYX_OPTIMIZE_CODE}} - MORYX_BUILD_CONFIG: ${{inputs.MORYX_BUILD_CONFIG}} - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: ${{inputs.DOTNET_SKIP_FIRST_TIME_EXPERIENCE}} MORYX_NUGET_APIKEY: ${{secrets.MYGET_TOKEN}} - MORYX_PACKAGE_TARGET: 'https://www.myget.org/F/moryx/api/v2/package' - MORYX_PACKAGE_TARGET_V3: 'https://www.myget.org/F/moryx/api/v3/index.json' - run: ./Build.ps1 -Publish - - - name: Publish on MyGet-Future + MORYX_PACKAGE_TARGET: ${{ inputs.MORYX_PACKAGE_TARGET_DEV }} + MORYX_PACKAGE_TARGET_V3: ${{ inputs.MORYX_PACKAGE_TARGET_V3_DEV }} + run: dotnet nuget push "artifacts/packages/" --api-key $MORYX_NUGET_APIKEY --source $MORYX_PACKAGE_TARGET --skip-duplicate --symbol-api-key $MORYX_NUGET_APIKEY --symbol-source $MORYX_PACKAGE_TARGET_V3 + + # Use if future branch + - name: Publish on MyGet-CI if: ${{ github.ref == 'refs/heads/future' }} # Future branch is published to myget moryx-future - shell: pwsh env: - MORYX_BUILDNUMBER: ${{inputs.MORYX_BUILDNUMBER}} - MORYX_OPTIMIZE_CODE: ${{inputs.MORYX_OPTIMIZE_CODE}} - MORYX_BUILD_CONFIG: ${{inputs.MORYX_BUILD_CONFIG}} - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: ${{inputs.DOTNET_SKIP_FIRST_TIME_EXPERIENCE}} MORYX_NUGET_APIKEY: ${{secrets.MYGET_TOKEN}} - MORYX_PACKAGE_TARGET: 'https://www.myget.org/F/moryx-future/api/v2/package' - MORYX_PACKAGE_TARGET_V3: 'https://www.myget.org/F/moryx-future/api/v3/index.json' - run: ./Build.ps1 -Publish - + MORYX_PACKAGE_TARGET: ${{ inputs.MORYX_PACKAGE_TARGET_FUTURE }} + MORYX_PACKAGE_TARGET_V3: ${{ inputs.MORYX_PACKAGE_TARGET_V3_FUTURE }} + run: dotnet nuget push "artifacts/packages/" --api-key $MORYX_NUGET_APIKEY --source $MORYX_PACKAGE_TARGET --skip-duplicate --symbol-api-key $MORYX_NUGET_APIKEY --symbol-source $MORYX_PACKAGE_TARGET_V3 + + # Use if tag - name: Publish on NuGet if: ${{ startsWith(github.ref, 'refs/tags/v') }} # Version Tags are published to nuget - shell: pwsh env: - MORYX_BUILDNUMBER: ${{inputs.MORYX_BUILDNUMBER}} - MORYX_OPTIMIZE_CODE: ${{inputs.MORYX_OPTIMIZE_CODE}} - MORYX_BUILD_CONFIG: ${{inputs.MORYX_BUILD_CONFIG}} - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: ${{inputs.DOTNET_SKIP_FIRST_TIME_EXPERIENCE}} MORYX_NUGET_APIKEY: ${{secrets.NUGET_TOKEN}} - MORYX_PACKAGE_TARGET: 'https://api.nuget.org/v3/index.json' - MORYX_PACKAGE_TARGET_V3: 'https://api.nuget.org/v3/index.json' - run: ./Build.ps1 -Publish + MORYX_PACKAGE_TARGET: ${{ inputs.MORYX_PACKAGE_TARGET_RELEASE }} + MORYX_PACKAGE_TARGET_V3: ${{ inputs.MORYX_PACKAGE_TARGET_V3_RELEASE }} + run: dotnet nuget push "artifacts/packages/" --api-key $MORYX_NUGET_APIKEY --source $MORYX_PACKAGE_TARGET --skip-duplicate --symbol-api-key $MORYX_NUGET_APIKEY --symbol-source $MORYX_PACKAGE_TARGET_V3 \ No newline at end of file diff --git a/.github/workflows/reportgenerator-tool.yml b/.github/workflows/reportgenerator-tool.yml index 4bf6603..e7c6ae0 100644 --- a/.github/workflows/reportgenerator-tool.yml +++ b/.github/workflows/reportgenerator-tool.yml @@ -3,28 +3,13 @@ name: ReportGenerator on: workflow_call: inputs: - dotnet_sdk_version: - required: true - type: string REPOSITORY_NAME: required: true type: string - MORYX_OPTIMIZE_CODE: - required: false - type: string - MORYX_BUILD_CONFIG: - required: false - type: string - MORYX_BUILDNUMBER: - required: false - type: string - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: - required: false - type: boolean jobs: ReportGenerator: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -37,7 +22,7 @@ jobs: - name: ReportGenerator uses: danielpalme/ReportGenerator-GitHub-Action@5.1.12 with: - reports: artifacts/test-results/**/TestResults\**\coverage.cobertura.xml; artifacts/test-results/*.Cobertura.xml + reports: artifacts/test-results/**/TestResults/**/coverage.cobertura.xml targetdir: Coverage reporttypes: Html @@ -46,4 +31,4 @@ jobs: with: name: ${{inputs.REPOSITORY_NAME}}-coverage-results path: Coverage/ - retention-days: 1 \ No newline at end of file + retention-days: 1 diff --git a/.github/workflows/unittest-tool.yml b/.github/workflows/unittest-tool.yml index 8e8d643..2b5efbc 100644 --- a/.github/workflows/unittest-tool.yml +++ b/.github/workflows/unittest-tool.yml @@ -9,22 +9,10 @@ on: REPOSITORY_NAME: required: true type: string - MORYX_OPTIMIZE_CODE: - required: false - type: string - MORYX_BUILD_CONFIG: - required: false - type: string - MORYX_BUILDNUMBER: - required: false - type: string - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: - required: false - type: boolean jobs: UnitTests: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -50,14 +38,14 @@ jobs: run: dotnet restore - name: Execute dotnet build - run: dotnet build + run: dotnet build --no-restore - name: Execute dotnet test (needs coverlet.collector nuget) - run: dotnet test --collect:"XPlat Code Coverage" + run: dotnet test --no-build --filter FullyQualifiedName!~Integration --collect:"XPlat Code Coverage" - name: Upload test results uses: actions/upload-artifact@v2 with: name: ${{inputs.REPOSITORY_NAME}}-test-results - path: src\Tests\**\TestResults\**\coverage.cobertura.xml - retention-days: 1 \ No newline at end of file + path: src/Tests/**/TestResults/**/coverage.cobertura.xml + retention-days: 1