diff options
| author | Adonais Romero González <[email protected]> | 2023-02-06 18:02:43 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-06 18:02:43 -0800 |
| commit | 767074e4950e2050cd143db2d1a38687f7a1ea33 (patch) | |
| tree | 9cf34f7565a45d15a741904d7abb5ecc77f39de0 /.github | |
| parent | 177192185e6ad176087849b7046411167954fb39 (diff) | |
| parent | 55f0ae520655ba8054a1fa97d9f60ea8d230b989 (diff) | |
Merge pull request #855 from microsoft/develop-2302-merge
Merge 'main' into 'develop'
Diffstat (limited to '.github')
| -rw-r--r-- | .github/README.md | 35 | ||||
| -rw-r--r-- | .github/scripts/Build-ChangedProjects.ps1 | 34 | ||||
| -rw-r--r-- | .github/scripts/Build-ChangedSamples.ps1 | 40 | ||||
| -rw-r--r-- | .github/workflows/Code-Scanning.yml | 59 | ||||
| -rw-r--r-- | .github/workflows/ci-pr.yml | 10 | ||||
| -rw-r--r-- | .github/workflows/ci.yml | 6 |
6 files changed, 141 insertions, 43 deletions
diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 00000000..b7569139 --- /dev/null +++ b/.github/README.md @@ -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 directly running `msbuild` directly. + +```yaml +name: Build all driver samples +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 }} +``` diff --git a/.github/scripts/Build-ChangedProjects.ps1 b/.github/scripts/Build-ChangedProjects.ps1 deleted file mode 100644 index a13e3501..00000000 --- a/.github/scripts/Build-ChangedProjects.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -param ( - [array]$ChangedFiles -) - -$root = (Get-Location).Path - -# To include in CI gate -$projectSet = @{} -foreach ($file in $ChangedFiles) -{ - if (-not (Test-Path $file)) { - Write-Output "`u{2754} Changed file $file cannot be found" - continue - } - $dir = (Get-Item $file).DirectoryName - while ((-not ($slnItems = (Get-ChildItem $dir '*.sln'))) -and ($dir -ne $root)) - { - $dir = (Get-Item $dir).Parent.FullName - } - if ($dir -eq $root) - { - Write-Output "`u{2754} Changed file $file does not match a project." - continue - } - $projectName = $dir.Replace($root, '').Trim('\').Replace('\', '.').ToLower() - Write-Output "`u{1F50E} Found project [$projectName] at $dir from changed file $file" - if (-not ($projectSet.ContainsKey($projectName))) - { - $projectSet[$projectName] = $dir - } -} - -.\Build-ProjectSet -ProjectSet $projectSet - diff --git a/.github/scripts/Build-ChangedSamples.ps1 b/.github/scripts/Build-ChangedSamples.ps1 new file mode 100644 index 00000000..82096cd6 --- /dev/null +++ b/.github/scripts/Build-ChangedSamples.ps1 @@ -0,0 +1,40 @@ +[CmdletBinding()] +param ( + [array]$ChangedFiles +) + +$Verbose = $false +if ($PSBoundParameters.ContainsKey('Verbose')) { + $Verbose = $PsBoundParameters.Get_Item('Verbose') +} + +$root = (Get-Location).Path + +# To include in CI gate +$sampleSet = @{} +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 + 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 + } +} + +.\Build-SampleSet -SampleSet $sampleSet -Verbose:$Verbose -LogFilesDirectory (Join-Path $root "_logs") + diff --git a/.github/workflows/Code-Scanning.yml b/.github/workflows/Code-Scanning.yml new file mode 100644 index 00000000..86be1ef0 --- /dev/null +++ b/.github/workflows/Code-Scanning.yml @@ -0,0 +1,59 @@ +# 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: + fetch-depth: 0 + + - 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 + env: + Configuration: Debug + Platform: x64 + + - name: Perform CodeQL analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 931df9e4..c701bd23 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -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 @@ -29,12 +27,14 @@ jobs: - name: Get changed files id: get-changed-files uses: tj-actions/changed-files@v27 + 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 }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c07460a..a8063d6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 }} |
