Skip to content

Commit cbc18d1

Browse files
authored
build: Run clippy against matrix of OSes/targets (#27)
1 parent 0dcbdd1 commit cbc18d1

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

.github/workflows/rust.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: ci
2-
on:
3-
pull_request:
4-
push:
5-
branches:
6-
- main
2+
on: [push]
73

84
env:
95
CARGO_TERM_COLOR: always
106

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
1111
jobs:
1212
rustfmt:
1313
name: "📋 Check formatting"
@@ -21,7 +21,24 @@ jobs:
2121

2222
clippy:
2323
name: 📎 Clippy
24-
runs-on: ubuntu-latest
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
- os: ubuntu-latest
30+
target: x86_64-unknown-linux-gnu
31+
32+
- os: ubuntu-latest
33+
target: aarch64-unknown-linux-gnu
34+
35+
- os: windows-latest
36+
37+
- os: macos-latest
38+
target: aarch64-apple-darwin
39+
40+
- os: macos-latest
41+
target: x86_64-apple-darwin
2542

2643
steps:
2744
- uses: actions/checkout@v4

src/rust_project.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::collections::{HashMap, HashSet};
22
use std::fmt::Display;
3-
use std::fs::File;
43
use std::path::PathBuf;
54

65
use anyhow::{Result, anyhow};
@@ -301,7 +300,7 @@ pub(crate) fn find_sysroot(ctx: &Context) -> Result<Utf8PathBuf> {
301300

302301
pub(crate) fn compute_project_json(
303302
ctx: &Context,
304-
discover_args: DiscoverArgs,
303+
#[allow(unused)] discover_args: DiscoverArgs,
305304
metadata: Metadata,
306305
manifest_path: FilePath<'_>,
307306
) -> Result<ProjectJson> {
@@ -310,7 +309,13 @@ pub(crate) fn compute_project_json(
310309
debug!(sysroot = %sysroot);
311310

312311
let sysroot_src = sysroot.join("lib/rustlib/src/rust/library");
313-
let crates = crates_from_metadata(ctx, discover_args, metadata, manifest_path)?;
312+
let crates = crates_from_metadata(
313+
ctx,
314+
#[cfg(not(target_os = "windows"))]
315+
discover_args.flamegraph,
316+
metadata,
317+
manifest_path,
318+
)?;
314319

315320
Ok(ProjectJson {
316321
sysroot,
@@ -565,14 +570,13 @@ impl PackageGraph {
565570

566571
fn crates_from_metadata(
567572
ctx: &Context,
568-
discover_args: DiscoverArgs,
573+
#[cfg(not(target_os = "windows"))] flamegraph: Option<PathBuf>,
569574
metadata: Metadata,
570575
manifest_path: FilePath<'_>,
571576
) -> Result<Vec<Crate>> {
572577
#[cfg(not(target_os = "windows"))]
573578
let pprof_guard = {
574-
discover_args
575-
.flamegraph
579+
flamegraph
576580
.as_ref()
577581
.map(|path| {
578582
Ok::<_, anyhow::Error>((
@@ -607,7 +611,7 @@ fn crates_from_metadata(
607611
#[cfg(not(target_os = "windows"))]
608612
if let Some((guard, path)) = pprof_guard {
609613
let report = guard.report().build()?;
610-
let file = File::create(path)?;
614+
let file = std::fs::File::create(path)?;
611615

612616
report.flamegraph(file)?;
613617
}

0 commit comments

Comments
 (0)