Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a maturin version comment to generated CI configuration #1485

Merged
merged 1 commit into from
Feb 15, 2023
Merged
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
41 changes: 30 additions & 11 deletions src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,19 @@ impl GenerateCI {
| BridgeModel::Cffi
| BridgeModel::UniFfi
);
let mut conf = "on:
let mut conf = format!(
"# Generated by maturin v{version}
on:
push:
branches:
- main
- master
pull_request:
workflow_dispatch:

jobs:\n"
.to_string();
jobs:\n",
version = env!("CARGO_PKG_VERSION"),
);

let mut needs = Vec::new();
let platforms: BTreeSet<_> = self
Expand Down Expand Up @@ -424,7 +427,11 @@ mod tests {
fn test_generate_github() {
let conf = GenerateCI::default()
.generate_github("example", &BridgeModel::Bindings("pyo3".to_string(), 7))
.unwrap();
.unwrap()
.lines()
.skip(1)
.collect::<Vec<_>>()
.join("\n");
let expected = indoc! {r#"
on:
push:
Expand Down Expand Up @@ -517,14 +524,18 @@ mod tests {
command: upload
args: --skip-existing *
"#};
assert_eq!(conf, expected);
assert_eq!(conf, expected.trim());
}

#[test]
fn test_generate_github_abi3() {
let conf = GenerateCI::default()
.generate_github("example", &BridgeModel::BindingsAbi3(3, 7))
.unwrap();
.unwrap()
.lines()
.skip(1)
.collect::<Vec<_>>()
.join("\n");
let expected = indoc! {r#"
on:
push:
Expand Down Expand Up @@ -617,7 +628,7 @@ mod tests {
command: upload
args: --skip-existing *
"#};
assert_eq!(conf, expected);
assert_eq!(conf, expected.trim());
}

#[test]
Expand All @@ -629,7 +640,11 @@ mod tests {
};
let conf = gen
.generate_github("example", &BridgeModel::Bindings("pyo3".to_string(), 7))
.unwrap();
.unwrap()
.lines()
.skip(1)
.collect::<Vec<_>>()
.join("\n");
let expected = indoc! {r#"
on:
push:
Expand Down Expand Up @@ -761,14 +776,18 @@ mod tests {
command: upload
args: --skip-existing *
"#};
assert_eq!(conf, expected);
assert_eq!(conf, expected.trim());
}

#[test]
fn test_generate_github_bin_no_binding() {
let conf = GenerateCI::default()
.generate_github("example", &BridgeModel::Bin(None))
.unwrap();
.unwrap()
.lines()
.skip(1)
.collect::<Vec<_>>()
.join("\n");
let expected = indoc! {r#"
on:
push:
Expand Down Expand Up @@ -851,6 +870,6 @@ mod tests {
command: upload
args: --skip-existing *
"#};
assert_eq!(conf, expected);
assert_eq!(conf, expected.trim());
}
}