Skip to content

Commit

Permalink
Workfow with uploaded artifacts and generate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeuchler committed Oct 26, 2020
1 parent af2ff90 commit dd9e74a
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 58 deletions.
38 changes: 18 additions & 20 deletions .build/BuildToolkit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ function Invoke-CoverTests($SearchPath = $RootPath, $SearchFilter = "*.csproj",
}
}

function Get-CsprojIsNetCore($csprojFile) {
[xml]$csprojContent = Get-Content $csprojFile.FullName
function Get-CsprojIsNetCore($CsprojItem) {
[xml]$csprojContent = Get-Content $CsprojItem.FullName
$sdkProject = $csprojContent.Project.Sdk;
if ($null -ne $sdkProject) {
# Read Target Framework
Expand All @@ -356,8 +356,8 @@ function Get-CsprojIsNetCore($csprojFile) {
return $false;
}

function Get-CsprojIsSdkProject($csprojFile) {
[xml]$csprojContent = Get-Content $csprojFile.FullName
function Get-CsprojIsSdkProject($CsprojItem) {
[xml]$csprojContent = Get-Content $CsprojItem.FullName
$sdkProject = $csprojContent.Project.Sdk;
if ($null -ne $sdkProject) {
return $true;
Expand Down Expand Up @@ -409,16 +409,16 @@ function Invoke-DocFx($Metadata = [System.IO.Path]::Combine($DocumentationDir, "
CopyAndReplaceFolder $docFxDest "$DocumentationArtifcacts\DocFx";
}

function Invoke-PackSdkProject($CsprojFile, [bool]$IncludeSymbols = $False) {
Write-Host "Try to pack .NET SDK project: $($CsprojFile.Name) ...";
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 = $CsprojFile.FullName;
$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 <CreatePackage>true</CreatePackage>: $($CsprojFile.Name)";
Write-Host-Warning "... csproj not flagged with <CreatePackage>true</CreatePackage>: $($CsprojItem.Name)";
return;
}

Expand All @@ -436,14 +436,14 @@ function Invoke-PackSdkProject($CsprojFile, [bool]$IncludeSymbols = $False) {
Invoke-ExitCodeCheck $LastExitCode;
}

function Invoke-PackFrameworkProject($CsprojFile, [bool]$IsTool = $False, [bool]$IncludeSymbols = $False) {
Write-Host "Try to pack .NET Framework project: $CsprojFile.Name ...";
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 = $CsprojFile.FullName;
$csprojFullName = $CsprojItem.FullName;
$nuspecPath = [IO.Path]::ChangeExtension($csprojFullName, "nuspec")
if(-not (Test-Path $nuspecPath)) {
Write-Host-Warning "Nuspec for project not found: $CsprojFile.Name";
Write-Host-Warning "Nuspec for project not found: $CsprojItem.Name";
return;
}

Expand All @@ -466,24 +466,22 @@ function Invoke-PackFrameworkProject($CsprojFile, [bool]$IsTool = $False, [bool]
Invoke-ExitCodeCheck $LastExitCode;
}

function Invoke-Pack($ProjectPath, [bool]$IsTool = $False, [bool]$IncludeSymbols = $False) {
function Invoke-Pack($ProjectItem, [bool]$IsTool = $False, [bool]$IncludeSymbols = $False) {
CreateFolderIfNotExists $NugetPackageArtifacts;

$csprojFile = Get-Item $ProjectPath;

if (Get-CsprojIsSdkProject($csprojFile)) {
Invoke-PackSdkProject $csprojFile $IncludeSymbols;
if (Get-CsprojIsSdkProject($ProjectItem)) {
Invoke-PackSdkProject $ProjectItem $IncludeSymbols;
}
else {
Invoke-PackFrameworkProject $csprojFile $IsTool $IncludeSymbols;
Invoke-PackFrameworkProject $ProjectItem $IsTool $IncludeSymbols;
}
}

function Invoke-PackAll([switch]$Symbols = $False) {
Write-Host "Looking for .csproj files..."
# Look for csproj in this directory
foreach ($csprojFile in Get-ChildItem $RootPath -Recurse -Filter *.csproj) {
Invoke-Pack -ProjectPath $csprojFile -IncludeSymbols $Symbols
foreach ($csprojItem in Get-ChildItem $RootPath -Recurse -Filter *.csproj) {
Invoke-Pack -ProjectItem $csprojItem -IncludeSymbols $Symbols
}
}

Expand Down
121 changes: 83 additions & 38 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,64 +34,109 @@ jobs:

- name: Build
shell: pwsh
run: ./Build.ps1 -Build
run: ./Build.ps1 -Build -Pack

- name: Upload package artefacts
uses: actions/upload-artifact@v2
with:
name: packages
path: artifacts/Packages/
retention-days: 1

UnitTests:
needs: [Build]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet.exe
uses: NuGet/[email protected]

- name: Execute Unit Tests
shell: pwsh
run: ./Build.ps1 -UnitTests

- name: Codecov
uses: codecov/codecov-action@v1
with:
files: '*.OpenCover.xml'
- uses: actions/checkout@v2

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet.exe
uses: NuGet/[email protected]

- name: Execute Unit Tests
shell: pwsh
run: ./Build.ps1 -UnitTests

- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: test-results
path: artifacts/Tests/
retention-days: 1

IntegrationTests:
needs: [Build]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet.exe
uses: NuGet/[email protected]

- name: Execute Integration Tests
shell: pwsh
run: ./Build.ps1 -IntegrationTests

- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: test-results
path: artifacts/Tests/
retention-days: 1

Codecov:
needs: [UnitTests, IntegrationTests]
runs-on: windows-latest
steps:
- name: Download test results
uses: actions/download-artifact@v2
with:
name: test-results
path: artifacts/Tests/

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
- name: Codecov
uses: codecov/codecov-action@v1
with:
files: '*.OpenCover.xml'

- name: Setup NuGet.exe
uses: NuGet/[email protected]
Documentation:
needs: [Build]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- name: Execute Integration Tests
shell: pwsh
run: ./Build.ps1 -IntegrationTests
- name: Generate docFx
shell: pwsh
run: ./Build.ps1 -GenerateDocs

- name: Upload documentation results
uses: actions/upload-artifact@v2
with:
name: dcoumentation
path: artifacts/Documentation/
retention-days: 1

- name: Codecov
uses: codecov/codecov-action@v1
with:
files: '*.OpenCover.xml'
Publish:
needs: [UnitTests, IntegrationTests]
needs: [Build, UnitTests, IntegrationTests]
if: ${{ github.event_name == 'push' }}
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet.exe
uses: NuGet/[email protected]

- name: Build
shell: pwsh
run: ./Build.ps1 -Build
- name: Download package artefacts
uses: actions/download-artifact@v2
with:
name: packages
path: artifacts/Packages/

- name: Pack & Publish
- name: Publish packages
shell: pwsh
run: ./Build.ps1 -Pack -Publish
run: ./Build.ps1 -Publish

0 comments on commit dd9e74a

Please sign in to comment.