Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into remove-lazystatic-r…
Browse files Browse the repository at this point in the history
…ust-tag
  • Loading branch information
wmmc88 committed Oct 20, 2023
2 parents ba47040 + 136014b commit 75f6905
Show file tree
Hide file tree
Showing 32 changed files with 892 additions and 856 deletions.
47 changes: 47 additions & 0 deletions .github/actions/winget-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Install Winget"
description: "Install winget on windows runners since its not installed by default: https://github.com/actions/runner-images/issues/6472"
inputs:
GITHUB_TOKEN:
description: 'GitHub token to execute authenticated Github API requests (for higher rate limit)'
required: true
runs:
using: "composite"
steps:
- name: Get URIs for Latest Winget assets
shell: pwsh
run: |
$AuthenticatedHeaders = @{ "Authorization" = "Bearer ${{ inputs.GITHUB_TOKEN }}" }
$LatestReleaseInfo = Invoke-RestMethod -Headers $AuthenticatedHeaders 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
$LatestWingetDownloadUri = $LatestReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('.msixbundle') }
$LatestWingetLicenseDownloadUri = $LatestReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('License1.xml') }
# Print to logs
Write-Host "LatestWingetDownloadUri=$LatestWingetDownloadUri"
Write-Host "LatestWingetLicenseDownloadUri=$LatestWingetLicenseDownloadUri"
# Save output for next step
Write-Output "LatestWingetDownloadUri=$LatestWingetDownloadUri" >> $env:GITHUB_ENV
Write-Output "LatestWingetLicenseDownloadUri=$LatestWingetLicenseDownloadUri" >> $env:GITHUB_ENV
- name: Download Winget Assets and Dependencies
shell: pwsh
run: |
New-Item -Type Directory $env:RUNNER_TEMP/winget-install
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.7.3/Microsoft.UI.Xaml.2.7.x64.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.7.x64.appx
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx # Needed per https://github.com/microsoft/winget-cli/blob/21de1607ed5c90174e6bb931406975c18681a5dd/README.md?plain=1#L35C19-L35C19
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:LatestWingetDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/winget.msixbundle
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:LatestWingetLicenseDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/license.xml
- name: Start Winget Installation
shell: pwsh
run: |
Add-AppxProvisionedPackage -Online -PackagePath $env:RUNNER_TEMP/winget-install/winget.msixbundle -LicensePath $env:RUNNER_TEMP/winget-install/license.xml -DependencyPackagePath $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.7.x64.appx, $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx
- name: Wait for Completion of Winget Installation
shell: pwsh
run: |
while ((Get-Command * | Select-String winget).ToString() -ne "winget.exe") {
Start-Sleep -Seconds 1
}
Write-Output "Winget Version: $(winget --version)"
30 changes: 30 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
day: "wednesday"
timezone: "America/Los_Angeles"
time: "06:00"
commit-message:
prefix: "Cargo Dependency"
labels:
- "type:dependabot"
- "type:dependencies-cargo"
rebase-strategy: "disabled"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "wednesday"
timezone: "America/Los_Angeles"
time: "06:00"
ignore:
- dependency-name: "microsoft/mu_devops"
commit-message:
prefix: "GitHub Actions"
labels:
- "type:dependabot"
- "type:dependencies-github-actions"
57 changes: 57 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
push:
pull_request:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: "0 11 * * *"

name: Build

jobs:
build:
name: Build
runs-on: windows-latest
strategy:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK

rust_toolchain:
- stable
- beta
- nightly

cargo_profile:
- dev
- release

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Winget
uses: ./.github/actions/winget-install
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install WDK (${{ matrix.wdk }})
run: |
if (!(winget list --exact --source winget --id ${{ matrix.wdk }})[-1].contains("${{ matrix.wdk }}")) {
winget install --disable-interactivity --source winget --exact --id ${{ matrix.wdk }}
}
- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}

- name: Run Cargo Build
run: cargo build --locked --profile ${{ matrix.cargo_profile }} --workspace

- name: Install Cargo Make
uses: taiki-e/install-action@v2
with:
tool: cargo-make

- name: Build and Package Sample KMDF Driver
run: cargo make --cwd .\crates\sample-kmdf-driver --profile ${{ matrix.cargo_profile }}
continue-on-error: true # FIXME: Packaging tools in non-ewdk environments are not found
29 changes: 29 additions & 0 deletions .github/workflows/cargo-audit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Cargo Audit
on:
push:
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
pull_request:
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: 0 11 * * *

jobs:
cargo_audit:
name: Cargo Audit
runs-on: windows-latest
permissions:
issues: write
checks: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Run Cargo Audit
uses: rustsec/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/code-formatting-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Code Formatting Check
on:
push:
pull_request:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: 0 11 * * *


jobs:
cargo-fmt:
name: .rs Formatting Check
runs-on: windows-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Rust Toolchain (Nightly)
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt

- name: Run Cargo Format
run: cargo fmt --all -- --check

taplo-fmt:
name: .toml Formatting Check
runs-on: windows-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Rust Toolchain (Stable)
uses: dtolnay/rust-toolchain@stable

- name: Install taplo-cli
uses: taiki-e/install-action@v2
with:
tool: taplo-cli

- run: taplo fmt --check --diff
name: Check TOML files formatting
52 changes: 52 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
push:
pull_request:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: "0 11 * * *"

name: Docs

jobs:
docs:
name: Docs
runs-on: windows-latest
strategy:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK

rust_toolchain:
- stable
- beta
- nightly

cargo_profile:
- dev
- release

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Winget
uses: ./.github/actions/winget-install
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install WDK (${{ matrix.wdk }})
run: |
if (!(winget list --exact --source winget --id ${{ matrix.wdk }})[-1].contains("${{ matrix.wdk }}")) {
winget install --disable-interactivity --source winget --exact --id ${{ matrix.wdk }}
}
- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}

- name: Run Cargo Doc
run: cargo doc --locked --profile ${{ matrix.cargo_profile }}

- name: Run Cargo Doc (--features nightly)
if: matrix.rust_toolchain == 'nightly'
run: cargo doc --locked --profile ${{ matrix.cargo_profile }} --features nightly
21 changes: 21 additions & 0 deletions .github/workflows/github-dependency-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Dependency Review
on:
pull_request:

jobs:
dependency-review:
name: Github Dependency Review
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Dependency Review
uses: actions/dependency-review-action@v3
with:
allow-licenses: MIT, Apache-2.0
comment-summary-in-pr: on-failure
106 changes: 106 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
on:
push:
pull_request:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: "0 11 * * *"

name: Lint

jobs:
clippy:
name: Clippy
runs-on: windows-latest
permissions:
checks: write
strategy:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK

rust_toolchain:
- stable
- beta
- nightly

cargo_profile:
- dev
- release

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Winget
uses: ./.github/actions/winget-install
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install WDK (${{ matrix.wdk }})
run: |
if (!(winget list --exact --source winget --id ${{ matrix.wdk }})[-1].contains("${{ matrix.wdk }}")) {
winget install --disable-interactivity --source winget --exact --id ${{ matrix.wdk }}
}
- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}

- name: Run Cargo Clippy
uses: giraffate/clippy-action@v1
with:
tool_name: Clippy
clippy_flags: --locked --profile ${{ matrix.cargo_profile }} --all-targets -- -D warnings
reporter: ${{ github.event_name == 'pull_request' && 'github-pr-review' || 'github-check' }}
github_token: ${{ secrets.GITHUB_TOKEN }}
filter_mode: nofilter
fail_on_error: true

- name: Run Cargo Clippy (--features nightly)
if: matrix.rust_toolchain == 'nightly'
uses: giraffate/clippy-action@v1
with:
tool_name: Clippy (--features nightly)
clippy_flags: --locked --profile ${{ matrix.cargo_profile }} --all-targets --features nightly -- -D warnings
reporter: ${{ github.event_name == 'pull_request' && 'github-pr-review' || 'github-check' }}
github_token: ${{ secrets.GITHUB_TOKEN }}
filter_mode: nofilter
fail_on_error: true

udeps:
name: Detect Unused Cargo Dependencies
runs-on: windows-latest
strategy:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Winget
uses: ./.github/actions/winget-install
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install WDK (${{ matrix.wdk }})
run: |
if (!(winget list --exact --source winget --id ${{ matrix.wdk }})[-1].contains("${{ matrix.wdk }}")) {
winget install --disable-interactivity --source winget --exact --id ${{ matrix.wdk }}
}
- name: Install Rust Toolchain (Nightly)
uses: dtolnay/rust-toolchain@nightly
# Cargo udeps only supports running on nightly due to reliance on unstable dep-info feature: https://github.com/est31/cargo-udeps/issues/113, https://github.com/est31/cargo-udeps/issues/136

- name: Install Cargo Udeps
uses: taiki-e/install-action@v2
with:
tool: cargo-udeps

- name: Run Cargo Udeps
run: cargo udeps --locked --all-targets

- name: Run Cargo Udeps (--features nightly)
run: cargo udeps --locked --all-targets --features nightly
Loading

0 comments on commit 75f6905

Please sign in to comment.