Skip to content

Commit be66115

Browse files
committed
add msrvcheck
1 parent 6e3154b commit be66115

File tree

6 files changed

+180
-1
lines changed

6 files changed

+180
-1
lines changed

.github/workflows/dependencies.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Dependencies
19+
20+
concurrency:
21+
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
22+
cancel-in-progress: true
23+
24+
on:
25+
push:
26+
branches-ignore:
27+
- 'gh-readonly-queue/**'
28+
paths:
29+
- "**/Cargo.toml"
30+
- "**/Cargo.lock"
31+
pull_request:
32+
paths:
33+
- "**/Cargo.toml"
34+
- "**/Cargo.lock"
35+
merge_group:
36+
# manual trigger
37+
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
38+
workflow_dispatch:
39+
40+
jobs:
41+
depcheck:
42+
name: msrv dependency check
43+
runs-on: ubuntu-latest
44+
container:
45+
image: amd64/rust
46+
steps:
47+
- uses: actions/checkout@v5
48+
with:
49+
submodules: true
50+
fetch-depth: 1
51+
- name: Setup Rust toolchain
52+
uses: ./.github/actions/setup-builder
53+
with:
54+
rust-version: stable
55+
- name: Check dependencies
56+
run: |
57+
cd dev/msrvcheck
58+
cargo run

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717

1818
[workspace]
19-
exclude = ["python"]
19+
exclude = ["dev/msrvcheck", "python"]
2020
members = ["ballista-cli", "ballista/client", "ballista/core", "ballista/executor", "ballista/scheduler", "benchmarks", "examples"]
2121
resolver = "2"
2222

dev/msrvcheck/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cargo.lock

dev/msrvcheck/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# MSRV checker for upstream DataFusion
19+
[package]
20+
name = "msrvcheck"
21+
edition = "2021"
22+
23+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
24+
25+
[dependencies]
26+
cargo = "0.91.0"

dev/msrvcheck/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
This directory contains a tool that ensures there MSRV is consistent with upstream
21+
datafusion dependencies.
22+
23+
[issue 1271]: https://github.com/apache/datafusion-ballista/issues/1271#issuecomment-3094456313

dev/msrvcheck/src/main.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use cargo::CargoResult;
19+
use std::env;
20+
use std::path::Path;
21+
22+
use cargo::util::context::GlobalContext;
23+
24+
/// Verifies that we are tracking the right MSRV from datafusion.
25+
/// This is vastly inspired from <https://github.com/apache/datafusion/tree/10a437b826568c27b81d7d16a02b938a13d1a4ad/dev/depcheck>
26+
fn main() -> CargoResult<()> {
27+
let gctx = GlobalContext::default()?;
28+
// This is the path for the depcheck binary
29+
let path = env::var("CARGO_MANIFEST_DIR").unwrap();
30+
let root_cargo_toml = Path::new(&path)
31+
// dev directory
32+
.parent()
33+
.expect("Can not find dev directory")
34+
// project root directory
35+
.parent()
36+
.expect("Can not find project root directory")
37+
.join("Cargo.toml");
38+
39+
println!(
40+
"Checking for MSRV dependencies in {}",
41+
root_cargo_toml.display()
42+
);
43+
44+
let workspace = cargo::core::Workspace::new(&root_cargo_toml, &gctx)?;
45+
let project_msrv = workspace.lowest_rust_version().unwrap(); // there should be a MSRV project wise
46+
47+
let (_, resolve) = cargo::ops::resolve_ws(&workspace, false)?;
48+
let packages_with_rust_version: Vec<_> = resolve
49+
.iter()
50+
.filter(|id| id.name().starts_with("datafusion"))
51+
.map(|e| resolve.summary(e))
52+
.map(|e| (e.name(), e.rust_version()))
53+
.collect();
54+
55+
println!("Current project MSRV: {}", project_msrv);
56+
57+
for (package, version) in packages_with_rust_version {
58+
if let Some(v) = version {
59+
if !v.is_compatible_with(project_msrv.as_partial()) {
60+
panic!(
61+
"package {package} has {v} MSRV not compatible with current project MSRV {project_msrv}",
62+
);
63+
}
64+
65+
println!("{package} MSRV: {v}");
66+
}
67+
}
68+
69+
println!("No inconsistent MSRV found");
70+
Ok(())
71+
}

0 commit comments

Comments
 (0)