Skip to content

Commit 996d1c6

Browse files
authored
ci: add github actions pipeline (microsoft#10)
1 parent 0416a98 commit 996d1c6

14 files changed

Lines changed: 551 additions & 76 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Install Winget"
2+
description: "Install winget on windows runners since its not installed by default: https://github.com/actions/runner-images/issues/6472"
3+
inputs:
4+
GITHUB_TOKEN:
5+
description: 'GitHub token to execute authenticated Github API requests (for higher rate limit)'
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Get URIs for Latest Winget assets
11+
shell: pwsh
12+
run: |
13+
$AuthenticatedHeaders = @{ "Authorization" = "Bearer ${{ inputs.GITHUB_TOKEN }}" }
14+
15+
$LatestReleaseInfo = Invoke-RestMethod -Headers $AuthenticatedHeaders 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
16+
$LatestWingetDownloadUri = $LatestReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('.msixbundle') }
17+
$LatestWingetLicenseDownloadUri = $LatestReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('License1.xml') }
18+
19+
# Print to logs
20+
Write-Host "LatestWingetDownloadUri=$LatestWingetDownloadUri"
21+
Write-Host "LatestWingetLicenseDownloadUri=$LatestWingetLicenseDownloadUri"
22+
23+
# Save output for next step
24+
Write-Output "LatestWingetDownloadUri=$LatestWingetDownloadUri" >> $env:GITHUB_ENV
25+
Write-Output "LatestWingetLicenseDownloadUri=$LatestWingetLicenseDownloadUri" >> $env:GITHUB_ENV
26+
27+
- name: Download Winget Assets and Dependencies
28+
shell: pwsh
29+
run: |
30+
New-Item -Type Directory $env:RUNNER_TEMP/winget-install
31+
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.8.x64.appx
32+
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
33+
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:LatestWingetDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/winget.msixbundle
34+
Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:LatestWingetLicenseDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/license.xml
35+
36+
- name: Start Winget Installation
37+
shell: pwsh
38+
run: |
39+
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.8.x64.appx, $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx
40+
41+
- name: Wait for Completion of Winget Installation
42+
shell: pwsh
43+
run: |
44+
while ((Get-Command * | Select-String winget)?.ToString() -ne "winget.exe") {
45+
Start-Sleep -Seconds 1
46+
}
47+
Write-Output "Winget Version: $(winget --version)"

.github/dependabot.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "cargo"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
day: "wednesday"
8+
timezone: "America/Los_Angeles"
9+
time: "06:00"
10+
commit-message:
11+
prefix: "chore"
12+
labels:
13+
- "type:dependabot"
14+
- "type:dependencies-cargo"
15+
16+
- package-ecosystem: "github-actions"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"
20+
day: "wednesday"
21+
timezone: "America/Los_Angeles"
22+
time: "06:00"
23+
commit-message:
24+
prefix: "chore"
25+
labels:
26+
- "type:dependabot"
27+
- "type:dependencies-github-actions"

.github/workflows/build.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
on:
2+
push:
3+
pull_request:
4+
merge_group:
5+
schedule: # Trigger a job on default branch at 4AM PST everyday
6+
- cron: "0 11 * * *"
7+
8+
name: Build
9+
10+
env:
11+
RUSTFLAGS: -D warnings
12+
13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: windows-latest
17+
strategy:
18+
matrix:
19+
wdk:
20+
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
21+
22+
rust_toolchain:
23+
- stable
24+
- beta
25+
- nightly
26+
27+
cargo_profile:
28+
- dev
29+
- release
30+
31+
target_triple:
32+
- x86_64-pc-windows-msvc
33+
- aarch64-pc-windows-msvc
34+
35+
steps:
36+
- name: Checkout Repository
37+
uses: actions/checkout@v4
38+
39+
- name: Install Winget
40+
uses: ./.github/actions/winget-install
41+
with:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Install WDK (${{ matrix.wdk }})
45+
run: |
46+
if (!(winget list --exact --source winget --id ${{ matrix.wdk }})[-1].contains("${{ matrix.wdk }}")) {
47+
winget install --disable-interactivity --source winget --exact --id ${{ matrix.wdk }}
48+
}
49+
50+
- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
51+
uses: dtolnay/rust-toolchain@master
52+
with:
53+
toolchain: ${{ matrix.rust_toolchain }}
54+
targets: ${{ matrix.target_triple }}
55+
56+
- name: Run Cargo Build
57+
run: cargo +${{ matrix.rust_toolchain }} build --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace
58+
59+
- name: Install Cargo Make
60+
uses: taiki-e/install-action@v2
61+
with:
62+
tool: cargo-make
63+
64+
- name: Build and Package Sample Drivers
65+
run: cargo make default +${{ matrix.rust_toolchain }} --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }}

.github/workflows/cargo-audit.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Cargo Audit
2+
on:
3+
push:
4+
paths:
5+
- "**/Cargo.toml"
6+
- "**/Cargo.lock"
7+
pull_request:
8+
merge_group:
9+
schedule: # Trigger a job on default branch at 4AM PST everyday
10+
- cron: 0 11 * * *
11+
12+
jobs:
13+
cargo_audit:
14+
name: Cargo Audit
15+
runs-on: windows-latest
16+
permissions:
17+
issues: write
18+
checks: write
19+
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
24+
- name: Run Cargo Audit
25+
uses: rustsec/audit-check@v1
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Code Formatting Check
2+
on:
3+
push:
4+
pull_request:
5+
merge_group:
6+
schedule: # Trigger a job on default branch at 4AM PST everyday
7+
- cron: 0 11 * * *
8+
9+
10+
jobs:
11+
cargo-fmt:
12+
name: .rs Formatting Check
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
19+
- name: Install Rust Toolchain (Nightly)
20+
# Need to temporarily pin nightly used for fmt because of upstream bug: https://github.com/rust-lang/rustfmt/issues/6082, https://github.com/rust-lang/rustfmt/issues/6099
21+
uses: dtolnay/rust-toolchain@master
22+
with:
23+
toolchain: nightly-2024-02-17
24+
components: rustfmt
25+
26+
- name: Run Cargo Format
27+
run: cargo +nightly-2024-02-17 fmt --all -- --check
28+
29+
taplo-fmt:
30+
name: .toml Formatting Check
31+
runs-on: windows-latest
32+
33+
steps:
34+
- name: Checkout Repository
35+
uses: actions/checkout@v4
36+
37+
- name: Install Rust Toolchain (Stable)
38+
uses: dtolnay/rust-toolchain@stable
39+
40+
- name: Install taplo-cli
41+
uses: taiki-e/install-action@v2
42+
with:
43+
tool: taplo-cli
44+
45+
- run: taplo fmt --check --diff
46+
name: Check TOML files formatting

.github/workflows/docs.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
on:
2+
push:
3+
pull_request:
4+
merge_group:
5+
schedule: # Trigger a job on default branch at 4AM PST everyday
6+
- cron: "0 11 * * *"
7+
8+
name: Docs
9+
10+
jobs:
11+
docs:
12+
name: Docs
13+
runs-on: windows-latest
14+
strategy:
15+
matrix:
16+
wdk:
17+
- Microsoft.WindowsWDK.10.0.22621 # NI WDK
18+
19+
rust_toolchain:
20+
- stable
21+
- beta
22+
- nightly
23+
24+
cargo_profile:
25+
- dev
26+
- release
27+
28+
target_triple:
29+
- x86_64-pc-windows-msvc
30+
- aarch64-pc-windows-msvc
31+
32+
steps:
33+
- name: Checkout Repository
34+
uses: actions/checkout@v4
35+
36+
- name: Install Winget
37+
uses: ./.github/actions/winget-install
38+
with:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Install WDK (${{ matrix.wdk }})
42+
run: |
43+
if (!(winget list --exact --source winget --id ${{ matrix.wdk }})[-1].contains("${{ matrix.wdk }}")) {
44+
winget install --disable-interactivity --source winget --exact --id ${{ matrix.wdk }}
45+
}
46+
47+
- name: Install Rust Toolchain (${{ matrix.rust_toolchain }})
48+
uses: dtolnay/rust-toolchain@master
49+
with:
50+
toolchain: ${{ matrix.rust_toolchain }}
51+
targets: ${{ matrix.target_triple }}
52+
53+
- name: Run Cargo Doc
54+
# proc-macro crates must be excluded to avoid cargo doc bug: https://github.com/rust-lang/cargo/issues/10368
55+
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros
56+
57+
- name: Run Cargo Doc (--features nightly)
58+
if: matrix.rust_toolchain == 'nightly'
59+
# proc-macro crates must be excluded to avoid cargo doc bug: https://github.com/rust-lang/cargo/issues/10368
60+
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros --features nightly
61+
62+
- name: Run Cargo Doc w/ proc-macro crates
63+
if: matrix.target_triple == 'x86_64-pc-windows-msvc'
64+
# cargo doc can only generate documentation for proc-macro crates when --target is not specified due to a cargo doc bug: https://github.com/rust-lang/cargo/issues/7677
65+
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }}
66+
67+
- name: Run Cargo Doc w/ proc-macro crates (--features nightly)
68+
if: ${{ matrix.target_triple == 'x86_64-pc-windows-msvc' && matrix.rust_toolchain == 'nightly' }}
69+
# cargo doc can only generate documentation for proc-macro crates when --target is not specified due to a cargo doc bug: https://github.com/rust-lang/cargo/issues/7677
70+
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --features nightly
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Dependency Review
2+
on:
3+
push:
4+
pull_request:
5+
merge_group:
6+
7+
jobs:
8+
dependency-review:
9+
name: Github Dependency Review
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
13+
contents: read
14+
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
19+
- name: Dependency Review
20+
uses: actions/dependency-review-action@v4
21+
with:
22+
# AND combinations are currently bugged and must be listed separately: https://github.com/actions/dependency-review-action/issues/263
23+
allow-licenses: MIT, Apache-2.0, BSD-3-Clause, ISC, Unicode-DFS-2016, (MIT OR Apache-2.0) AND Unicode-DFS-2016
24+
# anstyle is licensed as (MIT OR Apache-2.0), but the Github api fails to detect it: https://github.com/rust-cli/anstyle/tree/main/crates/anstyle
25+
allow-dependencies-licenses: 'pkg:cargo/anstyle@1.0.4'
26+
comment-summary-in-pr: on-failure
27+
# Explicit refs required for merge_group and push triggers:
28+
# https://github.com/actions/dependency-review-action/issues/456
29+
# https://github.com/actions/dependency-review-action/issues/252
30+
base-ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || (github.event_name == 'push' && github.event.before || (github.event_name == 'merge_group' && 'main' || 'unsupported trigger' ) ) }}
31+
head-ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || (github.event_name == 'push' && github.sha || (github.event_name == 'merge_group' && github.ref || 'unsupported trigger' ) ) }}

0 commit comments

Comments
 (0)