Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
uses: ./.github/actions/fix-environment
with:
target: x86_64-pc-windows-msvc
# generated - run `cargo run -p tool_yml` to update
- name: Check cppwinrt
run: cargo clippy -p cppwinrt --tests
- name: Check csharp_client
Expand Down Expand Up @@ -397,4 +398,4 @@ jobs:
- name: Check windows_x86_64_gnullvm
run: cargo clippy -p windows_x86_64_gnullvm --tests
- name: Check windows_x86_64_msvc
run: cargo clippy -p windows_x86_64_msvc --tests
run: cargo clippy -p windows_x86_64_msvc --tests
3 changes: 2 additions & 1 deletion .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
# generated - run `cargo run -p tool_yml` to update
- name: Rust version
run: rustup update --no-self-update 1.74 && rustup default 1.74
- name: Check cppwinrt
Expand Down Expand Up @@ -95,4 +96,4 @@ jobs:
- name: Rust version
run: rustup update --no-self-update 1.74 && rustup default 1.74
- name: Check windows-version
run: cargo check -p windows-version --all-features
run: cargo check -p windows-version --all-features
3 changes: 2 additions & 1 deletion .github/workflows/no-default-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
uses: ./.github/actions/fix-environment
with:
target: x86_64-pc-windows-msvc
# generated - run `cargo run -p tool_yml` to update
- name: Check cppwinrt
run: cargo check -p cppwinrt --no-default-features
- name: Check windows
Expand Down Expand Up @@ -65,4 +66,4 @@ jobs:
- name: Check windows-threading
run: cargo check -p windows-threading --no-default-features
- name: Check windows-version
run: cargo check -p windows-version --no-default-features
run: cargo check -p windows-version --no-default-features
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
uses: ./.github/actions/fix-environment
with:
target: ${{ matrix.target }}
# generated - run `cargo run -p tool_yml` to update
- name: Clean
run: cargo clean
- name: Test cppwinrt
Expand Down Expand Up @@ -434,3 +435,4 @@ jobs:
run: |
git add -N .
git diff --exit-code || (echo 'Tests changed code in the repo.'; exit 1)

60 changes: 11 additions & 49 deletions crates/tools/yml/src/clippy.rs
Original file line number Diff line number Diff line change
@@ -1,55 +1,17 @@
use super::*;

pub fn yml() {
let mut yml = r"name: clippy
write_yml(".github/workflows/clippy.yml", |yml| {
// This unrolling is required since "cargo clippy --all" consumes too much memory for the GitHub hosted runners.
for manifest in helpers::crates("crates") {
let name = manifest.package.name;

on:
pull_request:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/web.yml'
- 'web/**'
push:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/web.yml'
- 'web/**'
branches:
- master

jobs:
clippy:
runs-on: windows-2025
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Update toolchain
run: rustup update --no-self-update nightly && rustup default nightly-x86_64-pc-windows-msvc
- name: Add toolchain target
run: rustup target add x86_64-pc-windows-msvc
- name: Install clippy
run: rustup component add clippy
- name: Install rustfmt
run: rustup component add rustfmt
- name: Fix environment
uses: ./.github/actions/fix-environment
with:
target: x86_64-pc-windows-msvc"
.to_string();

// This unrolling is required since "cargo clippy --all" consumes too much memory for the GitHub hosted runners.

for manifest in helpers::crates("crates") {
let name = manifest.package.name;

write!(
&mut yml,
r"
- name: Check {name}
writeln!(
yml,
r" - name: Check {name}
run: cargo clippy -p {name} --tests"
)
.unwrap();
}

std::fs::write(".github/workflows/clippy.yml", yml.as_bytes()).unwrap();
)
.unwrap();
}
});
}
24 changes: 24 additions & 0 deletions crates/tools/yml/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,34 @@ mod no_default_features;
mod test;

use std::fmt::Write;
use std::io::BufRead;

fn main() {
test::yml();
clippy::yml();
no_default_features::yml();
msrv::yml();
}

#[track_caller]
fn write_yml<F>(path: &str, f: F)
where
F: FnOnce(&mut String),
{
let mut yml = String::new();
let file = std::fs::File::open(path).unwrap();
let file = std::io::BufReader::new(file);

for line in file.lines() {
let line = line.unwrap();
yml.push_str(&line);
yml.push('\n');

if line.starts_with("# generated") {
break;
}
}

f(&mut yml);
std::fs::write(path, yml.as_bytes()).unwrap();
}
61 changes: 18 additions & 43 deletions crates/tools/yml/src/msrv.rs
Original file line number Diff line number Diff line change
@@ -1,52 +1,27 @@
use super::*;

pub fn yml() {
let mut yml = r"name: msrv
write_yml(".github/workflows/msrv.yml", |yml| {
for manifest in helpers::crates("crates/libs") {
let name = manifest.package.name;
let version = manifest.package.rust_version.expect("rust-version");

on:
pull_request:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/web.yml'
- 'web/**'
push:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/web.yml'
- 'web/**'
branches:
- master
let features = if name == "windows" {
// We can't use `--all-features` for the `windows` crate as that would exhaust the available
// memory on GitHub VMs so this is just a smoke test for representative Win32 and WinRT APIs.
" --features Globalization,Win32_Graphics_Direct2D"
} else {
" --all-features"
};

jobs:
msrv:
runs-on: windows-2025
steps:
- name: Checkout
uses: actions/checkout@v5"
.to_string();

for manifest in helpers::crates("crates/libs") {
let name = manifest.package.name;
let version = manifest.package.rust_version.expect("rust-version");

let features = if name == "windows" {
// We can't use `--all-features` for the `windows` crate as that would exhaust the available
// memory on GitHub VMs so this is just a smoke test for representative Win32 and WinRT APIs.
" --features Globalization,Win32_Graphics_Direct2D"
} else {
" --all-features"
};

write!(
&mut yml,
r"
- name: Rust version
writeln!(
yml,
r" - name: Rust version
run: rustup update --no-self-update {version} && rustup default {version}
- name: Check {name}
run: cargo check -p {name}{features}"
)
.unwrap();
}

std::fs::write(".github/workflows/msrv.yml", yml.as_bytes()).unwrap();
)
.unwrap();
}
});
}
53 changes: 10 additions & 43 deletions crates/tools/yml/src/no_default_features.rs
Original file line number Diff line number Diff line change
@@ -1,48 +1,15 @@
use super::*;

pub fn yml() {
let mut yml = r"name: no-default-features

on:
pull_request:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/web.yml'
- 'web/**'
push:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/web.yml'
- 'web/**'
branches:
- master

jobs:
no-default-features:
runs-on: windows-2025
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Update toolchain
run: rustup update --no-self-update nightly && rustup default nightly-x86_64-pc-windows-msvc
- name: Add toolchain target
run: rustup target add x86_64-pc-windows-msvc
- name: Fix environment
uses: ./.github/actions/fix-environment
with:
target: x86_64-pc-windows-msvc"
.to_string();

for manifest in helpers::crates("crates/libs") {
let name = manifest.package.name;
write!(
&mut yml,
r"
- name: Check {name}
write_yml(".github/workflows/no-default-features.yml", |yml| {
for manifest in helpers::crates("crates/libs") {
let name = manifest.package.name;
writeln!(
yml,
r" - name: Check {name}
run: cargo check -p {name} --no-default-features"
)
.unwrap();
}

std::fs::write(".github/workflows/no-default-features.yml", yml.as_bytes()).unwrap();
)
.unwrap();
}
});
}
Loading