Skip to content

Commit

Permalink
Merge branch 'microsoft:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbromberger authored May 8, 2023
2 parents 66b589d + 95037b3 commit 32c7e7a
Show file tree
Hide file tree
Showing 772 changed files with 14,144 additions and 110,100 deletions.
35 changes: 35 additions & 0 deletions .github/Build-with-GitHub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Using GitHub actions for building drivers

If you use GitHub to host your code, you can leverage [GitHub Actions](https://docs.github.com/en/actions) to create automated workflows to build your driver projects.

`windows-2022` runner (provided by `windows-latest`) is configured with Windows Driver Kit version 22H2 and Visual Studio 2022 off the box, so most solutions can be built by running `msbuild` directly.

```yaml
name: Build driver solution
on:
push:
branches:
- main
jobs:
build:
strategy:
matrix:
configuration: [Debug, Release]
platform: [x64]
runs-on: windows-2022
env:
Solution_Path: path\to\driver\solution.sln
steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Add MSBuild to PATH
uses: microsoft/[email protected]

- name: Build solution
run: |
msbuild ${{ env.Solution_Path }} -p:Configuration:${{ env.Configuration }} -p:Platform:${{ env.Platform }}
env:
Configuration: ${{ matrix.configuration }}
Platform: ${{ matrix.platform }}
```
34 changes: 0 additions & 34 deletions .github/scripts/Build-ChangedProjects.ps1

This file was deleted.

60 changes: 60 additions & 0 deletions .github/scripts/Build-ChangedSamples.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[CmdletBinding()]
param (
[array]$ChangedFiles
)

$Verbose = $false
if ($PSBoundParameters.ContainsKey('Verbose')) {
$Verbose = $PsBoundParameters.Get_Item('Verbose')
}

$root = (Get-Location).Path

# Search for samples (directories) to build
$sampleSet = @{}
$buildAll = $false
foreach ($file in $ChangedFiles) {
if (-not (Test-Path $file)) {
Write-Verbose "`u{2754} Changed file $file cannot be found"
continue
}
$dir = (Get-Item $file).DirectoryName
$filename = Split-Path $file -Leaf

# Files that can affect how every sample is built should trigger a full build
if ($filename -eq "Build-AllSamples.ps1" -or $filename -eq "Build-Sample.ps1") {
$buildAll = $true
}
if ($dir -like "$root\.github\scripts" -or $dir -like "$root\.github\scripts\*") {
$buildAll = $true
}
if ($dir -like "$root\.github\workflows" -or $dir -like "$root\.github\workflows\*") {
$buildAll = $true
}
if ($buildAll)
{
Write-Verbose "`u{2754} Full build triggered by change in file $file"
break
}

while ((-not ($slnItems = (Get-ChildItem $dir '*.sln'))) -and ($dir -ne $root)) {
$dir = (Get-Item $dir).Parent.FullName
}
if ($dir -eq $root) {
Write-Verbose "`u{2754} Changed file $file does not match a sample"
continue
}
$sampleName = $dir.Replace($root, '').Trim('\').Replace('\', '.').ToLower()
Write-Verbose "`u{1F50E} Found sample [$sampleName] at $dir from changed file $file"
if (-not ($sampleSet.ContainsKey($sampleName))) {
$sampleSet[$sampleName] = $dir
}
}

if ($buildAll) {
.\Build-AllSamples -Verbose:$Verbose -LogFilesDirectory (Join-Path $root "_logs")
}
else {
.\Build-SampleSet -SampleSet $sampleSet -Verbose:$Verbose -LogFilesDirectory (Join-Path $root "_logs")
}

60 changes: 60 additions & 0 deletions .github/workflows/Code-Scanning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This workflow runs the latest CodeQL CLI and checks against CodeQL's Cpp library.
# This is the source for the GitHub Security Code Scanning job.

name: "CodeQL Analysis"

on:
push:
branches:
- main
- develop
pull_request:
# The branches below must be a subset of the branches above
branches:
- main
- develop

# Allow manual scheduling
workflow_dispatch:

jobs:
analyze:
name: Analysis
runs-on: windows-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Add MSBuild to PATH
uses: microsoft/[email protected]

- name: Retrieve and build all available solutions
id: build-all-samples
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@v2
with:
category: "/language:${{matrix.language}}"
16 changes: 8 additions & 8 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
configuration: [Debug, Release]
platform: [x64, arm64]
runs-on: windows-2022
env:
Solution_Path: general\echo\kmdf\kmdfecho.sln
steps:
- name: Check out repository code
uses: actions/checkout@v3
Expand All @@ -28,13 +26,15 @@ jobs:

- name: Get changed files
id: get-changed-files
uses: tj-actions/changed-files@v27
uses: tj-actions/changed-files@v35
with:
separator: ","

- name: Retrieve and build solutions from changed files
id: build-changed-projects
id: build-changed-samples
run: |
$changedFiles = "${{ steps.get-changed-files.outputs.all_changed_files }}".Split(' ')
.\.github\scripts\Build-ChangedProjects.ps1 -ChangedFiles $changedFiles
$changedFiles = "${{ steps.get-changed-files.outputs.all_changed_files }}".Split(',')
.\.github\scripts\Build-ChangedSamples.ps1 -ChangedFiles $changedFiles -Verbose
env:
Configuration: ${{ matrix.configuration }}
Platform: ${{ matrix.platform }}
WDS_Configuration: ${{ matrix.configuration }}
WDS_Platform: ${{ matrix.platform }}
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
configuration: [Debug, Release]
platform: [x64, arm64]
runs-on: windows-2022
env:
Solution_Path: general\echo\kmdf\kmdfecho.sln
steps:
- name: Check out repository code
uses: actions/checkout@v3
Expand All @@ -27,9 +25,9 @@ jobs:
uses: microsoft/[email protected]

- name: Retrieve and build all available solutions
id: build-all-projects
id: build-all-samples
run: |
.\Build-AllProjects.ps1
.\Build-AllSamples.ps1 -Verbose
env:
Configuration: ${{ matrix.configuration }}
Platform: ${{ matrix.platform }}
WDS_Configuration: ${{ matrix.configuration }}
WDS_Platform: ${{ matrix.platform }}
15 changes: 0 additions & 15 deletions Build-AllProjects.ps1

This file was deleted.

68 changes: 68 additions & 0 deletions Build-AllSamples.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<#
.SYNOPSIS
Builds all available sample solutions in the repository (excluding specific solutions).
.DESCRIPTION
This script searches for all available Visual Studio Solutions (.sln files) and attempts to run MSBuild to build them for the specified configurations and platforms.
.PARAMETER Samples
A regular expression matching the samples to be built. Default is '' that matches all samples. Examples include '^tools.' or '.dchu'.
.PARAMETER Configurations
A list of configurations to build samples under. Values available are 'Debug' and 'Release'. By default, $env:WDS_Configuration will be used as the sole configuration to build for. If this environment variable is not set the default is 'Debug' and 'Release'.
.PARAMETER Platforms
A list of platforms to build samples under (e.g. 'x64', 'arm64'). By default, $env:WDS_Platform will be used as the sole platform to build for. If this environment variable is not set the default is 'x64' and'arm64'.
.PARAMETER LogFilesDirectory
Path to a directory where the log files will be written to. If not provided, outputs will be logged to the '_logs' directory within the current working directory.
.PARAMETER ThrottleLimit
An integer indicating how many combinations to build in parallel. If 0 or not provided this defaults to 5 x number of logical processors.
.INPUTS
None.
.OUTPUTS
None.
.EXAMPLE
.\Build-AllSamples
.EXAMPLE
.\Build-AllSamples -Samples '^tools.' -Configurations 'Debug','Release' -Platforms 'x64','arm64'
#>

[CmdletBinding()]
param(
[string]$Samples = "",
[string[]]$Configurations = @(if ([string]::IsNullOrEmpty($env:WDS_Configuration)) { ('Debug', 'Release') } else { $env:WDS_Configuration }),
[string[]]$Platforms = @(if ([string]::IsNullOrEmpty($env:WDS_Platform)) { ('x64', 'arm64') } else { $env:WDS_Platform }),
[string]$LogFilesDirectory = (Join-Path (Get-Location) "_logs"),
[int]$ThrottleLimit
)

$Verbose = $false
if ($PSBoundParameters.ContainsKey('Verbose')) {
$Verbose = $PsBoundParameters.Get_Item('Verbose')
}

$root = Get-Location
$solutionFiles = Get-ChildItem -Path $root -Recurse -Filter *.sln | Select-Object -ExpandProperty FullName

# To include in CI gate
$sampleSet = @{}
foreach ($file in $solutionFiles) {
$dir = (Get-Item $file).DirectoryName
$dir_norm = $dir.Replace($root, '').Trim('\').Replace('\', '.').ToLower()
if ($dir_norm -match ($Samples)) {
Write-Verbose "`u{1F50E} Found and included sample [$dir_norm] at $dir"
$sampleSet[$dir_norm] = $dir
}
else {
Write-Verbose "`u{1F50E} Found and excluded sample [$dir_norm] at $dir"
}
}

.\Build-SampleSet -SampleSet $sampleSet -Configurations $Configurations -Platform $Platforms -LogFilesDirectory $LogFilesDirectory -Verbose:$Verbose -ThrottleLimit $ThrottleLimit
64 changes: 0 additions & 64 deletions Build-Project.ps1

This file was deleted.

Loading

0 comments on commit 32c7e7a

Please sign in to comment.