-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Added preliminary Rust binding to a whole lot of tspconfig.yaml files #38890
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
base: main
Are you sure you want to change the base?
Changes from 25 commits
caeecb8
5d555e4
e5364fb
596055d
3097974
f563b9f
89cb592
78a2184
1ceee62
4586277
060a3a2
13ca73d
a5babae
a0e2d88
91db6ef
9701966
68444bc
a850334
30559e1
29a41a7
dba6513
2682457
faa62cc
b7cde68
21213c3
82889ff
41e72ec
e496ccd
c09ebe4
f8f5ea2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| /* eslint-disable */ | ||
| // TODO: Enable eslint, fix errors | ||
|
|
||
|
|
@@ -628,6 +628,37 @@ | |
| } | ||
| } | ||
|
|
||
| // ----- Rust sub rules ----- | ||
| export class TspConfigRustMgmtCrateNameSubRule extends TspconfigEmitterOptionsSubRuleBase { | ||
| constructor() { | ||
| super( | ||
| "@azure-tools/typespec-rust", | ||
| "crate-name", | ||
| new RegExp(/^azure_resourcemanager_(?:[a-z0-9]+_)*[a-z0-9]+$/), | ||
| ); | ||
| } | ||
| protected skip(_: any, folder: string) { | ||
| return skipForDataPlane(folder); | ||
| } | ||
| } | ||
|
|
||
| export class TspConfigRustAzEmitterOutputDirSubRule extends TspconfigEmitterOptionsSubRuleBase { | ||
| constructor() { | ||
| super("@azure-tools/typespec-rust", "emitter-output-dir", new RegExp(/{output-dir}\/{service-dir}\/{crate-name}/)); | ||
| } | ||
|
|
||
| protected validate(config: any): RuleResult { | ||
| let emitterOutputDir = config?.options?.[this.emitterName]?.["emitter-output-dir"]; | ||
| if (emitterOutputDir === undefined) return this.createFailedResult("Failed to find \"options.@azure-tools/typespec-rust.emitter-output-dir\"", "Please add \"options.@azure-tools/typespec-rust.emitter-output-dir\" with a path matching the SDK naming convention \"{output-dir}/{service-dir}/{crate-name}\""); | ||
| if (emitterOutputDir !== "{output-dir}/{service-dir}/{crate-name}") { | ||
| return this.createFailedResult( | ||
| `The value of options.${this.emitterName}.emitter-output-dir "${emitterOutputDir}" does not match the required format "{output-dir}/{service-dir}/{crate-name}"`, "Correct the emitter-output-dir to be \"{output-dir}/{service-dir}/{crate-name}\"" | ||
| ); | ||
| } | ||
| return { success: true }; | ||
| } | ||
| } | ||
|
|
||
| export const defaultRules = [ | ||
| new TspConfigCommonAzServiceDirMatchPatternSubRule(), | ||
| new TspConfigJavaAzEmitterOutputDirMatchPatternSubRule(), | ||
|
|
@@ -659,6 +690,8 @@ | |
| new TspConfigCsharpMgmtNamespaceSubRule(), | ||
| new TspConfigCsharpAzEmitterOutputDirSubRule(), | ||
| new TspConfigCsharpMgmtEmitterOutputDirSubRule(), | ||
| new TspConfigRustMgmtCrateNameSubRule(), | ||
| new TspConfigRustAzEmitterOutputDirSubRule(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is Rust emitter config a required check for SdkTspConfigValidationRule in tspconfig.yaml? The required check means if the tspconfig.yaml would appear, then any absent of Rust config would fail the SdkTspConfigValidationRule. If we design this as optional check, which means:
Please note I am not talking about the implementation and the current impl may not design for required and optional check. But we want to introduce this idea since we notice some checks are optional and here is the issue to track this: Azure/azure-sdk-tools#13124. |
||
| ]; | ||
|
|
||
| export class SdkTspConfigValidationRule implements Rule { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,10 @@ options: | |
| flavor: "azure" | ||
| generate-test: true | ||
| generate-sample: true | ||
| "@azure-tools/typespec-rust": | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do all these SDK successfully generate currently? @raych1 are there any plans to have an SDK validation pipeline for rust? @LarryOsterman @heaths we should probably avoid adding all these configurations until we have some sort of validation pipeline for them.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I heard from @ronniegeraghty several months ago for the interest to onboard Rust to the @LarryOsterman @heaths do we want to onboard Rust to the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now, we can't onboard a rust pipeline because we have a ton of validation errors. A large part of the purpose f this PR is to make it simpler for the Rust SDK team to bulk compile the azure-rest-api-specs repo to find the gaps between spector and the real validators (gaps we've found for example: CBOR support, Text/Plain support). Once we've done the validation, I think a validation pipeline is a great idea.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have individual pipeline to support the batch run on multiple specs. The config changes do not have to be in the |
||
| crate-name: "azure_resourcemanager_agricultureplatform" | ||
| crate-version: "0.1.0" | ||
| emitter-output-dir: "{output-dir}/{service-dir}/{crate-name}" | ||
| "@azure-tools/typespec-java": | ||
| emitter-output-dir: "{output-dir}/{service-dir}/azure-resourcemanager-agricultureplatform" | ||
| namespace: "com.azure.resourcemanager.agricultureplatform" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.