diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml deleted file mode 100644 index fc211143..00000000 --- a/.github/workflows/pull-request.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: Validate Pull Request - -on: - pull_request: - -jobs: - validate-pull-request: - strategy: - matrix: - windows-version: - - windows-2019 - - windows-2022 - visual-studio-version: - - 16.11 - - 17.3 - # The GitHub Actions Windows images do not contain multiple versions of - # msbuild, so we need to exclude certain combinations. - exclude: - - windows-version: windows-2019 - visual-studio-version: 17.3 - - windows-version: windows-2022 - visual-studio-version: 16.11 - runs-on: ${{ matrix.windows-version }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1.1 - with: - vs-version: ${{ matrix.visual-studio-version }} - msbuild-architecture: x64 - - - name: Build - run: ./SharpShellNativeBridge/build.ps1 - - # Upload the artifacts folder. - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - name: artifacts - path: | - ./SharpShellNativeBridge/artifacts/ diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 00000000..0619183d --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,38 @@ +name: Validate +on: [push, pull_request] + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - windows-version: windows-2019 + visual-studio-version: 16.11 + - windows-version: windows-2022 + visual-studio-version: 17.3 + runs-on: ${{ matrix.windows-version }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v2 + with: + vs-version: ${{ matrix.visual-studio-version }} + msbuild-architecture: x64 + + - name: Build Native Bridge + run: msbuild /p:Configuration=Release,Platform=x64 ./SharpShellNativeBridge/SharpShellNativeBridge.sln + + - name: Build SharpShell + run: msbuild /p:Configuration=Release ./SharpShell/SharpShell.sln + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.windows-version }} + path: | + ./SharpShellNativeBridge/artifacts + ./SharpShell/artifacts diff --git a/SharpShell/build.ps1 b/SharpShell/build.ps1 index 39efec87..5cca47fb 100644 --- a/SharpShell/build.ps1 +++ b/SharpShell/build.ps1 @@ -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") diff --git a/SharpShell/coverage.ps1 b/SharpShell/coverage.ps1 index d48ab678..037c1769 100644 --- a/SharpShell/coverage.ps1 +++ b/SharpShell/coverage.ps1 @@ -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" - diff --git a/SharpShell/pack.ps1 b/SharpShell/pack.ps1 new file mode 100644 index 00000000..c21ec334 --- /dev/null +++ b/SharpShell/pack.ps1 @@ -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 diff --git a/SharpShell/test.ps1 b/SharpShell/test.ps1 index 4e9f1185..c845289d 100644 --- a/SharpShell/test.ps1 +++ b/SharpShell/test.ps1 @@ -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" \ No newline at end of file +$command = "nunit3-console.exe $testAssemblies --work=`"$PSScriptRoot\artifacts\tests`"" +Write-Host "Running: `"$command`"" +Invoke-Expression $command diff --git a/appveyor.yml b/appveyor.yml index da278a93..4f179942 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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