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

First attempt at filing bugs if WDK is out-of-date #850

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
62 changes: 62 additions & 0 deletions .github/workflows/check_wdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright (c) eBPF for Windows contributors
# SPDX-License-Identifier: MIT

# This workflow performs a build of the project and uploads the result as a build artifact.

name: Check for updates to the Windows Driver Kit

on:
# Run script every Sunday at midnight
schedule:
- cron: '0 0 * * 0'
# Allow manual triggering of the script
workflow_dispatch:

jobs:
check:
runs-on: Windows-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
if: steps.skip_check.outputs.should_skip != 'true'
with:
repository: ${{inputs.repository}}
submodules: 'recursive'
ref: ${{inputs.ref}}
Comment on lines +20 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix workflow configuration issues

Several critical issues need to be addressed:

  1. The skip_check step is referenced but not defined
  2. The workflow uses undefined inputs (repository and ref)

Either:

  1. Define the inputs in the workflow:
on:
  schedule:
    - cron: '0 0 * * 0'
  workflow_dispatch:
+    inputs:
+      repository:
+        description: 'Repository to check'
+        required: false
+        default: ${{ github.repository }}
+      ref:
+        description: 'Git ref to check'
+        required: false
+        default: ${{ github.ref }}

Or:
2. Remove the unused inputs:

     - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
-      if: steps.skip_check.outputs.should_skip != 'true'
       with:
-        repository: ${{inputs.repository}}
         submodules: 'recursive'
-        ref: ${{inputs.ref}}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if: steps.skip_check.outputs.should_skip != 'true'
with:
repository: ${{inputs.repository}}
submodules: 'recursive'
ref: ${{inputs.ref}}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
submodules: 'recursive'
🧰 Tools
🪛 actionlint (1.7.4)

20-20: property "skip_check" is not defined in object type {}

(expression)


22-22: property "repository" is not defined in object type {}

(expression)


24-24: property "ref" is not defined in object type {}

(expression)


- name: Check for updates to the Windows Driver Kit
id: check_wdk
run: |
# Get the latest version of the Windows Driver Kit
$packages = nuget list "Microsoft.Windows.WDK.x64"
$packageLine = $package | Where-Object { $_ -match $packageName }
$packageVersion = $packageLine -replace "Microsoft.Windows.WDK.x64", ""
echo "::set-output name=wdk_version::$packageVersion"

Comment on lines +28 to +34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix PowerShell script and update deprecated workflow commands

The script has multiple issues:

  1. The $package variable is undefined but used in line 31
  2. The set-output command is deprecated

Apply these fixes:

     run: |
       # Get the latest version of the Windows Driver Kit
       $packages = nuget list "Microsoft.Windows.WDK.x64"
-      $packageLine = $package | Where-Object { $_ -match $packageName }
+      $packageLine = $packages | Where-Object { $_ -match "Microsoft.Windows.WDK.x64" }
       $packageVersion = $packageLine -replace "Microsoft.Windows.WDK.x64", ""
-      echo "::set-output name=wdk_version::$packageVersion"
+      "wdk_version=$packageVersion" >> $env:GITHUB_OUTPUT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
# Get the latest version of the Windows Driver Kit
$packages = nuget list "Microsoft.Windows.WDK.x64"
$packageLine = $package | Where-Object { $_ -match $packageName }
$packageVersion = $packageLine -replace "Microsoft.Windows.WDK.x64", ""
echo "::set-output name=wdk_version::$packageVersion"
run: |
# Get the latest version of the Windows Driver Kit
$packages = nuget list "Microsoft.Windows.WDK.x64"
$packageLine = $packages | Where-Object { $_ -match "Microsoft.Windows.WDK.x64" }
$packageVersion = $packageLine -replace "Microsoft.Windows.WDK.x64", ""
"wdk_version=$packageVersion" >> $env:GITHUB_OUTPUT
🧰 Tools
🪛 actionlint (1.7.4)

28-28: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)

- name: Check the version of the WDK in the repo
id: check_repo_wdk
run: |
$wdkVersion = (Get-Content -Path .\wdk.props | Select-String -Pattern "<WDKVersion>" | ForEach-Object { $_ -replace "<WDKVersion>", "" -replace "</WDKVersion>", "" }).trim()
echo "::set-output name=repo_wdk_version::$wdkVersion"

Comment on lines +35 to +40
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling and update deprecated workflow commands

The script needs error handling and uses deprecated commands.

     run: |
+      if (-not (Test-Path .\wdk.props)) {
+        Write-Error "wdk.props file not found"
+        exit 1
+      }
       $wdkVersion = (Get-Content -Path .\wdk.props | Select-String -Pattern "<WDKVersion>" | ForEach-Object { $_ -replace "<WDKVersion>", "" -replace "</WDKVersion>", "" }).trim()
-      echo "::set-output name=repo_wdk_version::$wdkVersion"
+      "repo_wdk_version=$wdkVersion" >> $env:GITHUB_OUTPUT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Check the version of the WDK in the repo
id: check_repo_wdk
run: |
$wdkVersion = (Get-Content -Path .\wdk.props | Select-String -Pattern "<WDKVersion>" | ForEach-Object { $_ -replace "<WDKVersion>", "" -replace "</WDKVersion>", "" }).trim()
echo "::set-output name=repo_wdk_version::$wdkVersion"
- name: Check the version of the WDK in the repo
id: check_repo_wdk
run: |
if (-not (Test-Path .\wdk.props)) {
Write-Error "wdk.props file not found"
exit 1
}
$wdkVersion = (Get-Content -Path .\wdk.props | Select-String -Pattern "<WDKVersion>" | ForEach-Object { $_ -replace "<WDKVersion>", "" -replace "</WDKVersion>", "" }).trim()
"repo_wdk_version=$wdkVersion" >> $env:GITHUB_OUTPUT
🧰 Tools
🪛 actionlint (1.7.4)

37-37: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)

- name: File issue if the versions don't match and an issue doesn't already exist
if: steps.check_wdk.outputs.wdk_version != steps.check_repo_wdk.outputs.repo_wdk_version
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: issues } = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
creator: 'github-actions[bot]',
labels: 'wdk-update'
});
if (issues.length === 0) {
await github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Update the Windows Driver Kit',
body: 'The Windows Driver Kit version in the repository does not match the latest version available on NuGet. Please update the WDK version in the repository to match the latest version available on NuGet.',
labels: ['wdk-update']
});
}
Loading