Skip to content

Commit

Permalink
Modernize builder tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Jun 12, 2024
1 parent 8d6d4e9 commit 3a76570
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 91 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/pull-request.yaml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Validate
on: [push, pull_request]

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}
cancel-in-progress: true

jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

# - name: Build Native Bridge
# run: dotnet build -c Release ./SharpShellNativeBridge/SharpShellNativeBridge.sln

- name: Build SharpShell
run: dotnet build -c Release ./SharpShell/SharpShell.sln

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
./SharpShellNativeBridge/artifacts
./SharpShell/artifacts
8 changes: 4 additions & 4 deletions SharpShell/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ $solutionFile = "SharpShell.sln"
# Get the 'MSBuild.exe' path. On CI platforms (e.g. GitHub actions) it will
# already be in the path. If it's not, use vswhere to find it.
$msbuildPath = If (Get-Command $msbuild -ErrorAction SilentlyContinue) {
# MSBuild.exe is avaialble from %PATH% - we are probably in CI...
$msbuild
# MSBuild.exe is avaialble from %PATH% - we are probably in CI...
$msbuild
} Else {
# Find MSBuild.exe using 'vswhere'...
& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
# Find MSBuild.exe using 'vswhere'...
& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
}
$arguments = @("/t:Clean,Restore,Build", "/p:Configuration=Release", "$PSScriptRoot\$solutionFile")

Expand Down
20 changes: 10 additions & 10 deletions SharpShell/coverage.ps1
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Define the location of the xml report and html report.
$coverageDir = "$PSScriptRoot\artifacts\coverage"
$coverageDir = "$PSScriptRoot\artifacts\coverage"
$coverageReport = "$coverageDir\coverage.xml"

# Quote arguments for the commandline.
$testAssemblyArgs = "`"$PSScriptRoot\SharpShell.Tests\bin\Release\SharpShell.Tests.dll`""
$workArgs = "`"$PSScriptRoot\artifacts\tests`""
# Get the set of test assemblies and the work folder.
$testAssemblies = Get-ChildItem -Include *.Tests.dll -Recurse | Where-Object {$_.FullName -like "*bin\Release*"}
$workArgs = "$PSScriptRoot\artifacts\tests"

# Create an artifacts directory and build the report.
# Create an artifacts directory and create the command to build the report.
New-Item -ItemType Directory -Force -Path "$PSScriptRoot\artifacts\coverage"
OpenCover.Console.exe "-target:nunit3-console.exe" `
-targetargs:"$testAssemblyArgs --work=$workArgs" `
$command = "OpenCover.Console.exe -target:nunit3-console.exe" `
"-targetargs:`"$testAssemblies --work=$workArgs`"" `
"-filter:+[SharpShell*]* -[SharpShell.Tests*]*" `
"-register:user" `
"-output:$coverageReport"
"-register:user -output:$coverageReport"
Write-Host "Running: `"$command`""
Invoke-Expression $command

# Create a local report.
reportgenerator "-reports:$coverageReport" "-targetdir:$coverageDir\html"

# Upload the report to codecov. The CODECOV_TOKEN env var must be set.
codecov -f "$coverageReport"

11 changes: 11 additions & 0 deletions SharpShell/pack.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Create the artifacts packages folder.
$artifactsFolder = "$PSScriptRoot/artifacts/packages"

if (Test-Path $artifactsFolder) { Remove-Item $artifactsFolder -Recurse -Force }
New-Item -Path $artifactsFolder -ItemType directory

# Package each of our projects. This must be run *after* ./build.ps1.
dotnet pack --no-restore --no-build "$PSScriptRoot/SharpShell.csproj" -c:Release

# Copy over the packages.
Get-ChildItem "$PSScriptRoot" -Include SharpGL*.nupkg -Recurse | Copy-Item -Destination $artifactsFolder
4 changes: 3 additions & 1 deletion SharpShell/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ New-Item -ItemType Directory -Force -Path "$PSScriptRoot\artifacts\tests"

# Find all test assemblies.
$testAssemblies = Get-ChildItem -Include *.Tests.dll -Recurse | Where-Object {$_.FullName -like "*bin\Release*"}
nunit3-console.exe $testAssemblies --work="$PSScriptRoot\artifacts\tests"
$command = "nunit3-console.exe $testAssemblies --work=`"$PSScriptRoot\artifacts\tests`""
Write-Host "Running: `"$command`""
Invoke-Expression $command
72 changes: 40 additions & 32 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,57 @@
version: 1.0.{build}
image: Visual Studio 2017
image: Visual Studio 2019
configuration: Release
environment:
CODECOV_TOKEN: 875a7530-b25b-49e9-a2ba-fe8b7a80cc6b

# Cache chocolatey packages and Nuget packages. Nuget package cache is invalidated
# on any change to a project file, the choco cache on any change to the config
# nuget file.
cache:
- SharpShell/packages -> **/*.csproj
- C:/ProgramData/chocolatey/bin -> ./SharpShell/config.ps1
- C:/ProgramData/chocolatey/lib -> ./SharpShell/config.ps1

# Before building, restore Nuget packages and install dependencies.
before_build:
- ps: |
nuget restore SharpShell\SharpShell.sln
.\SharpShell\config.ps1
- ps: |
nuget restore SharpShell/SharpShell.sln
./SharpShell/config.ps1
build:
project: SharpShell\SharpShell.sln
publish_nuget: true
verbosity: minimal
# Use our own build script.
build_script:
- ps: |
./SharpShell/build.ps1
./SharpShell/pack.ps1
# After the build as completed, analyse coverage and upload.
on_success:
- ps: ./SharpShell/coverage.ps1

# Before packaging, zip up the tools.
before_package:
- ps: |
7z a ServerManager.zip C:\projects\sharpshell\SharpShell\Tools\ServerManager\bin\Release\*
7z a ServerRegistrationManager.zip C:\projects\sharpshell\SharpShell\Tools\ServerRegistrationManager\bin\Release\*
- ps: |
7z a ServerManager.zip C:/projects/sharpshell/SharpShell/Tools/ServerManager/bin/Release/*
7z a ServerRegistrationManager.zip C:/projects/sharpshell/SharpShell/Tools/ServerRegistrationManager/bin/Release/*
# Track our artifacts.
artifacts:
- path: ServerManager.zip
name: ServerManager
- path: ServerRegistrationManager.zip
name: ServerRegistrationManager
- path: SharpShell\artifacts
name: artifacts
- path: ServerManager.zip
name: ServerManager
- path: ServerRegistrationManager.zip
name: ServerRegistrationManager
- path: SharpShell/artifacts
name: artifacts
- path: './source/**/*.nupkg'

# Deploy to Nuget and GitHub Releases.
deploy:
- provider: NuGet
api_key:
secure: TWio+nDN8Ew7+OH7J3tLcEoM6DmxrIwfAr+2Ag8ROWJUEnXyoSAZ/I1GxBgB0qMd
on:
APPVEYOR_REPO_TAG: true
- provider: GitHub
auth_token:
secure: KTWUORrnJKPKLSf/3ROLY50T9UfgTMnKHf3OjBOv8tlY/DAxtlglRU3eM+j45fMt
artifact: SharpShell.*.nupkg, ServerRegistrationManager.*.nupkg, ServerManager.zip, ServerRegistrationManager.zip
on:
APPVEYOR_REPO_TAG: true

# After the build as completed, analyse coverage and upload.
on_success:
- ps: ./SharpShell/coverage.ps1
- provider: NuGet
api_key:
secure: TWio+nDN8Ew7+OH7J3tLcEoM6DmxrIwfAr+2Ag8ROWJUEnXyoSAZ/I1GxBgB0qMd
on:
APPVEYOR_REPO_TAG: true
- provider: GitHub
auth_token:
secure: KTWUORrnJKPKLSf/3ROLY50T9UfgTMnKHf3OjBOv8tlY/DAxtlglRU3eM+j45fMt
on:
APPVEYOR_REPO_TAG: true

0 comments on commit 3a76570

Please sign in to comment.