-
Notifications
You must be signed in to change notification settings - Fork 258
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 azure-autorust bin #896
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
members = [ | ||
"codegen", | ||
"openapi", | ||
"azure-autorust", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "azure-autorust" | ||
version = "0.1.0" | ||
authors = ["Cameron Taggart <[email protected]>"] | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
autorust_codegen = { path = "../codegen" } | ||
clap = { version = "3.2.7", features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// cargo run --release -p azure-autorust | ||
|
||
use autorust_codegen::{ | ||
crates::{list_crate_names, list_dirs}, | ||
gen::gen_crate, | ||
get_mgmt_readmes, get_svc_readmes, | ||
jinja::{CargoToml, CheckAllServicesYml, PublishSdksYml, PublishServicesYml}, | ||
Result, RunConfig, | ||
}; | ||
use clap::Parser; | ||
|
||
#[derive(Debug, clap::Parser)] | ||
struct Args { | ||
/// Generate the publish GitHub workflows | ||
#[clap(long)] | ||
publish: bool, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let args = Args::parse(); | ||
gen_mgmt()?; | ||
gen_svc()?; | ||
gen_services_workspace()?; | ||
gen_workflow_check_all_services()?; | ||
if args.publish { | ||
gen_workflow_publish_sdks()?; | ||
gen_workflow_publish_services()?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn gen_mgmt() -> Result<()> { | ||
const OUTPUT_FOLDER: &str = "../mgmt"; | ||
const ONLY_SERVICES: &[&str] = &[]; | ||
let run_config = &mut RunConfig::new("azure_mgmt_"); | ||
for (i, spec) in get_mgmt_readmes()?.iter().enumerate() { | ||
if !ONLY_SERVICES.is_empty() { | ||
if ONLY_SERVICES.contains(&spec.spec()) { | ||
println!("{} {}", i + 1, spec.spec()); | ||
gen_crate(spec, run_config, OUTPUT_FOLDER)?; | ||
} | ||
} else { | ||
println!("{} {}", i + 1, spec.spec()); | ||
gen_crate(spec, run_config, OUTPUT_FOLDER)?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn gen_svc() -> Result<()> { | ||
const OUTPUT_FOLDER: &str = "../svc"; | ||
const ONLY_SERVICES: &[&str] = &[]; | ||
let run_config = &mut RunConfig::new("azure_svc_"); | ||
for (i, spec) in get_svc_readmes()?.iter().enumerate() { | ||
if !ONLY_SERVICES.is_empty() { | ||
if ONLY_SERVICES.contains(&spec.spec()) { | ||
println!("{} {}", i + 1, spec.spec()); | ||
gen_crate(spec, run_config, OUTPUT_FOLDER)?; | ||
} | ||
} else { | ||
println!("{} {}", i + 1, spec.spec()); | ||
gen_crate(spec, run_config, OUTPUT_FOLDER)?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn gen_services_workspace() -> Result<()> { | ||
let dirs = list_dirs()?; | ||
let dirs: Vec<String> = dirs.iter().map(|dir| dir.as_str().replace('\\', "/").replace("../", "")).collect(); | ||
|
||
let yml = CargoToml { dirs }; | ||
yml.create("../Cargo.toml")?; | ||
Ok(()) | ||
} | ||
|
||
fn gen_workflow_check_all_services() -> Result<()> { | ||
let packages = list_crate_names()?; | ||
let packages = &packages.iter().map(String::as_str).collect(); | ||
|
||
let yml = CheckAllServicesYml { packages }; | ||
yml.create("../../.github/workflows/check-all-services.yml")?; | ||
Ok(()) | ||
} | ||
|
||
fn gen_workflow_publish_sdks() -> Result<()> { | ||
let packages = &vec![ | ||
"azure_core", | ||
"azure_data_cosmos", | ||
"azure_data_tables", | ||
"azure_identity", | ||
"azure_iot_hub", | ||
"azure_messaging_eventgrid", | ||
"azure_messaging_servicebus", | ||
"azure_security_keyvault", | ||
"azure_storage", | ||
"azure_storage_blobs", | ||
"azure_storage_datalake", | ||
"azure_storage_queues", | ||
]; | ||
let yml = PublishSdksYml { packages }; | ||
yml.create("../../.github/workflows/publish-sdks.yml")?; | ||
Ok(()) | ||
} | ||
|
||
fn gen_workflow_publish_services() -> Result<()> { | ||
let packages = list_crate_names()?; | ||
let packages = &packages.iter().map(String::as_str).collect(); | ||
let yml = PublishServicesYml { packages }; | ||
yml.create("../../.github/workflows/publish-services.yml")?; | ||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels weird that configs for the SDK crates are written by azure-autorust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. It is behind a
--publish
arg and I'm the only one who runs it. It would be nice to keep the creation of the workflows together. It just saves me time. I can move this back into an example if you would prefer that.