Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI Pipelines build with WDK Nuget Packages #1179

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/scripts/Install-Vsix.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<#

.SYNOPSIS
Checks WDK vsix version and downloads and installs as necessary.

#>

[CmdletBinding()]
param(
[bool]$optimize = $false
)

$root = Get-Location

# launch developer powershell (if necessary)
if (-not $env:VSCMD_VER) {
middlemose marked this conversation as resolved.
Show resolved Hide resolved
Import-Module (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*")
cd $root
}

# source environment variables
. .\Env-Vars.ps1

$version = $env:SAMPLES_VSIX_VERSION
$uri = $env:SAMPLES_VSIX_URI

function PrintWdkVsix {
$installed = ls "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select -ExpandProperty Name
"WDK Vsix Version: $installed"
}

function TestWdkVsix {
Test-Path "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=$version"
}

if ($optimize) {
"---> Downloading vsix and configuring build environment..."
Invoke-WebRequest -Uri "$uri" -OutFile wdk.zip
Expand-Archive ".\wdk.zip" .\
cp ".\`$MSBuild\*" (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\MSBuild\") -Recurse -Force
"<--- Finished"
}
else {
"Getting installed WDK vsix..."
PrintWdkVsix
"Checking the WDK.vsix version installed..."
if (-not (TestWdkVsix)) {
"The correct WDK vsix is not installed."
"Will attempt to download and install now..."
Invoke-WebRequest -Uri "$uri" -OutFile wdk.vsix
"Finished downloading."
"Starting install process. This will take some time to complete..."
Start-Process vsixinstaller -ArgumentList "/f /q /sp .\wdk.vsix" -wait
"The install process has finished."
"Checking the WDK.vsix version installed..."
if (TestWdkVsix) {
PrintWdkVsix
"The WDK vsix version is OK"
}
else {
"The WDK vsix install FAILED"
Write-Host "`u{274C} wdk vsix install had an issue"
Write-Error "the wdk vsix cannot be installed at this time"
exit 1
}
}
}
56 changes: 28 additions & 28 deletions .github/workflows/Code-Scanning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@ jobs:
language: [ 'cpp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
packs: microsoft/windows-drivers
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Retrieve and build all available solutions
run: |
.\Build-AllSamples.ps1 -Verbose -ThrottleLimit 1
env:
WDS_Configuration: Debug
WDS_Platform: x64
WDS_WipeOutputs: ${{ true }}

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"



- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install WDK VSIX
run: .\.github\scripts\Install-Vsix.ps1 -optimize:$true

- name: Install Nuget Packages
run: nuget restore .\packages.config -PackagesDirectory .\packages\

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
packs: microsoft/windows-drivers

- name: Retrieve and build all available solutions
run: .\Build-AllSamples.ps1 -Verbose -ThrottleLimit 1
env:
WDS_Configuration: Debug
WDS_Platform: x64
WDS_WipeOutputs: ${{ true }}

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
10 changes: 6 additions & 4 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ jobs:
with:
submodules: 'recursive'

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Install WDK VSIX
run: .\.github\scripts\Install-Vsix.ps1 -optimize:$true

- name: Install Nuget Packages
run: nuget restore .\packages.config -PackagesDirectory .\packages\

- name: Get changed files
id: get-changed-files
Expand Down Expand Up @@ -63,8 +66,7 @@ jobs:
path: _logs

- name: Join and generate global reports
run: |
.\.github\scripts\Join-CsvReports.ps1
run: .\.github\scripts\Join-CsvReports.ps1

- name: Archive global overview build reports
uses: actions/upload-artifact@v3
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ jobs:
with:
submodules: 'recursive'

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Install WDK VSIX
run: .\.github\scripts\Install-Vsix.ps1 -optimize:$true

- name: Install Nuget Packages
run: nuget restore .\packages.config -PackagesDirectory .\packages\

- name: Retrieve and build all available solutions
run: |
.\Build-AllSamples.ps1 -Verbose
run: .\Build-AllSamples.ps1 -Verbose
env:
WDS_Configuration: ${{ matrix.configuration }}
WDS_Platform: ${{ matrix.platform }}
Expand Down Expand Up @@ -56,8 +58,7 @@ jobs:
path: _logs

- name: Join and generate global reports
run: |
.\.github\scripts\Join-CsvReports.ps1
run: .\.github\scripts\Join-CsvReports.ps1

- name: Archive global overview build reports
uses: actions/upload-artifact@v3
Expand Down
24 changes: 17 additions & 7 deletions Build-SampleSet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ param(
)

$root = Get-Location

# launch developer powershell (if necessary)
middlemose marked this conversation as resolved.
Show resolved Hide resolved
if (-not $env:VSCMD_VER) {
Import-Module (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*")
cd $root
}

# source environment variables
. .\Env-Vars.ps1

$ThrottleFactor = 5
$LogicalProcessors = (Get-CIMInstance -Class 'CIM_Processor' -Verbose:$false).NumberOfLogicalProcessors

Expand Down Expand Up @@ -51,21 +62,20 @@ finally {
$build_environment=""
$build_number=0
#
# WDK NuGet will require presence of a folder 'packages'
# In Github we build using Nuget only and source version from repo .\Env-Vars.ps1.
#
#
# Hack: In GitHub we do not have an environment variable where we can see WDK build number, so we have it hard coded.
#
if (-not $env:GITHUB_REPOSITORY -eq '') {
if ($env:GITHUB_REPOSITORY) {
$build_environment="GitHub"
$build_number=22621
$build_number=$env:SAMPLES_BUILD_NUMBER
}
#
# WDK NuGet will require presence of a folder 'packages'. The version is sourced from repo .\Env-Vars.ps1.
#
# Hack: If user has hydrated nuget packages, then use those. That will be indicated by presence of a folder named .\packages.
#
elseif(Test-Path(".\packages")) {
$build_environment=("NuGet")
$build_number=26100
$build_number=$env:SAMPLES_BUILD_NUMBER
}
#
# EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'.
Expand Down
9 changes: 9 additions & 0 deletions Env-Vars.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Environment variables for script sourcing.
# Note: When a new WDK ships the following need to be updated:
# 1. Environment variables in .\Env-Vars.ps1 (this script)
# 2. Nuget package versions in .\packages.config
# 3. Nuget package versions in .\Directory.Build.props
# 4. SDK and WDK versions and WDK vsix link in .\configuration.dsc.yaml
$env:SAMPLES_VSIX_VERSION = "10.0.26100.0"
$env:SAMPLES_VSIX_URI = "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/DriverDeveloperKits-WDK/vsextensions/WDKVsix/10.0.26100.0/vspackage?targetPlatform=5e3e564c-03bb-4499-8ae5-b2b35e9a86dc"
$env:SAMPLES_BUILD_NUMBER = "26100"
Loading