diff options
| author | Adonais Romero González <[email protected]> | 2023-01-30 15:00:49 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-30 15:00:49 -0800 |
| commit | 07779ee84973f2f63a1f2ced6377463b1c01baaf (patch) | |
| tree | d28fc10efc8f5dee97ec5df162bb533f6e801585 /.github | |
| parent | 2c0c8763300988d92ddd139cadf012f5ab1b12e1 (diff) | |
Build scripts update (#844)
---------
Co-authored-by: Jakob Lichtenberg (170957) <[email protected]>
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 | 4 | ||||
| -rw-r--r-- | .github/workflows/ci-pr.yml | 10 | ||||
| -rw-r--r-- | .github/workflows/ci.yml | 6 |
6 files changed, 84 insertions, 45 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 index 2993c393..b2c851b6 100644 --- a/.github/workflows/Code-Scanning.yml +++ b/.github/workflows/Code-Scanning.yml @@ -46,9 +46,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 env: Configuration: ${{ matrix.configuration }} Platform: ${{ matrix.platform }} 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 }} |
