Skip to content

Commit

Permalink
Merge branch 'Azure:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad-jamrozik authored Jul 8, 2024
2 parents eb20a9b + cbbe228 commit dabfcaf
Show file tree
Hide file tree
Showing 986 changed files with 88,305 additions and 3,730 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
/specification/sql/ @jamestao @ericshape @jeremyfrosti

# PRLabel: %Storage
/specification/storage/ @jasonyang-msft
/specification/storage/resource-manager/ @blueww @yifanz7
/specification/storage/data-plane/ @seanmcc-msft @Azure/api-stewardship-board

# PRLabel: %Import Export
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/typespec-requirement-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: TypeSpec Requirement - Test

on:
push:
branches:
- main
pull_request:
paths:
- package-lock.json
- package.json
- tsconfig.json
- .github/workflows/_reusable-eng-tools-test.yaml
- .github/workflows/typespec-requirement-test.yaml
- eng/scripts/**
- eng/tools/package.json
- eng/tools/tsconfig.json
- eng/tools/typespec-requirement/**

jobs:
typespec-requirement:
uses: ./.github/workflows/_reusable-eng-tools-test.yaml
with:
package: typespec-requirement
38 changes: 38 additions & 0 deletions .github/workflows/typespec-requirement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: TypeSpec Requirement

on: pull_request

jobs:
TypeSpec-Requirement:
name: TypeSpec Requirement
strategy:
fail-fast: false
matrix:
spec-type: [data-plane, resource-manager]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
# Required since "HEAD^" is passed to TypeSpec-Requirement.ps1
fetch-depth: 2

- name: Use Node 20.0
uses: actions/setup-node@v4
with:
node-version: 20.0

- run: npm --version --loglevel info

- run: npm ci

- run: npm ls -a
continue-on-error: true

- run: |
eng/scripts/TypeSpec-Requirement.ps1 `
-BaseCommitish HEAD^ `
-TargetCommitish HEAD `
-SpecType ${{ matrix.spec-type }}
shell: pwsh
8 changes: 8 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@
"Accesskey"
]
},
{
"filename": "**/specification/billing/**/*.json",
"words": [
"mosp",
"resellee",
"cnpj"
]
},
{
"filename": "**/specification/compute/resource-manager/Microsoft.ContainerService/preview/2015-11-01-preview/containerService.json",
"words": [
Expand Down
6 changes: 3 additions & 3 deletions documentation/Getting-started-with-TypeSpec-specifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Within the azure-rest-api-specs repository, the TypeSpec specification serves as

#### ARM:
- :white_check_mark: TypeSpec folder name should end with `.Management`.
- :white_check_mark: This `tspconfig.yaml` is [standard for ARM](https://github.com/microsoft/typespec/blob/main/eng/feeds/arm/tspconfig.yaml). The one thing you may customize is the output json file name for `typespec-autorest` emitter.
- :white_check_mark: This `tspconfig.yaml` is [standard for ARM](https://github.com/Azure/typespec-azure/blob/main/eng/feeds/arm/tspconfig.yaml). The one thing you may customize is the output json file name for `typespec-autorest` emitter.

#### Data-Plane:
- :white_check_mark: `tspconfig.yaml` starting template for [Data-plane is here.](https://github.com/microsoft/typespec/blob/main/eng/feeds/arm/tspconfig.yaml). For `typespec-autorest` emitter, you may only customize the output json file name. For other language SDK emitters' settings, you may override values for TypeSpec direct SDK generation.
- :white_check_mark: `tspconfig.yaml` starting template for [Data-plane is here.](https://github.com/Azure/typespec-azure/blob/main/eng/feeds/data-plane/tspconfig.yaml). For `typespec-autorest` emitter, you may only customize the output json file name. For other language SDK emitters' settings, you may override values for TypeSpec direct SDK generation.

### Detailed information

- [Setting up local environment for TypeSpec](./typespec-rest-api-dev-process.md#2-repo-setup--prerequisites)
- Read up on [Folder Structure for TypeSpec](./typespec-structure-guidelines.md)
- [Setting up a new TypeSpec project](./typespec-rest-api-dev-process.md#3-creating-a-new-typespec-project)
- [Setting up and regenerate SDK projects](./typespec-rest-api-dev-process.md#4-generate-or-refresh-sdk-code-from-a-typespec-project)
- [Setting up and regenerate SDK projects](./typespec-rest-api-dev-process.md#4-generate-or-refresh-sdk-code-from-a-typespec-project)
86 changes: 2 additions & 84 deletions documentation/ci-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,70 +190,7 @@ To reproduce LintDiff failures locally, see [CONTRIBUTING.md / How to locally re

## `Swagger LintDiff` for TypeSpec: troubleshooting guides

Check `Swagger LintDiff` may fail for the OpenAPI generated from TypeSpec, even if there are no warnings or errors reported from the TypeSpec compiler. Causes include bugs in the TypeSpec OpenAPI emitter, bugs in LintDiff rules, incompatibilities between TypeSpec and LintDiff, or checks duplicated in TypeSpec and LintDiff.

We are working to address the root causes (where possible). Until then, we recommend you [suppress](#suppression-process) these LintDiff errors, using a "permanent suppression" with a descriptive "reason", so we can revert your suppression when the root cause is fixed.

### `Record<unknown>` causes `AvoidAdditionalProperties` and `PropertiesTypeObjectNoDefinition`

The use of `Record<unknown>` in TypeSpec is discouraged, and there is a TypeSpec lint rule to enforce this. If you still need to use `Record<unknown>`, the OpenAPI spec generated will cause many LintDiff errors of types `AvoidAdditionalProperties` and `PropertiesTypeObjectNoDefinition`. You will need to suppress both the TypeSpec violation (in TypeSpec source code) and the LintDiff violations.

### `RequestBodyMustExistForPutPatch`

We believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/641

### `PatchPropertiesCorrespondToPutProperties`

We believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/642

### `@singleton` causes `EvenSegmentedPathForPutOperation` and `XmsPageableForListCalls`

If `EvenSegmentedPathForPutOperation` and/or `XmsPageableForListCalls` are failing for OpenAPI generated from TypeSpec using `@singleton` (OpenAPI path ends with `/default`), we believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/646

### `AvoidAnonymousParameter`, `AvoidAnonymousTypes`, `IntegerTypeMustHaveFormat`

Data-plane specs can suppress violations of the following rules, since they only exist for the benefit of SDKs generated from swagger, and data-plane SDKs are generated directly from TypeSpec. Resource-manager specs should **not** suppress violations of these rules, since resource-manager SDKs are generated from OpenAPI, and rely on these errors being fixed.

- `AvoidAnonymousParameter`
- `AvoidAnonymousTypes`
- `IntegerTypeMustHaveFormat`

### `AvoidAnonymousTypes` inside a 202 response

As an exception to the previous note, resource-manager specs **may** be able to suppress `AvoidAnonymousTypes`, but only if the error is inside a 202 response from a long-running operation (LRO). It is known that SDKs do not need to generate type names for such responses.

### `OAuth2Auth` causes `XmsEnumValidation`

TypeSpec using `OAuth2Auth` may generate the following OpenAPI:

``` yaml
"type": {
"type": "string",
"description": "OAuth2 authentication",
"enum": [
"oauth2"
]
},
```

Which causes error `XmsEnumValidation`. The recommended workaround is to add `omit-unreachable-types: true` to your `tspconfig.yaml`.

### `ProvisioningStateMustBeReadOnly`

The root cause is bugs in `azure-openapi-validator` and `oav`:

https://github.com/Azure/azure-openapi-validator/issues/637
https://github.com/Azure/oav/issues/848

The recommended workaround is to add `use-read-only-status-schema: true` to your `tspconfig.yaml`.

### `PatchBodyParameterSchema`

The root cause is a bug in typespec-azure:

https://github.com/Azure/typespec-azure/issues/383.

Please see the issue above for the suggested workaround and apply it directly to the spec TypeSpec sources. The LintDiff error should **not** be ignored or suppressed.
https://github.com/Azure/azure-rest-api-specs/wiki/Swagger-LintDiff-for-TypeSpec

## `Swagger ModelValidation`

Expand Down Expand Up @@ -343,26 +280,7 @@ If you need more information on see [cspell configuration](https://cspell.org/co

## `TypeSpec Validation`

This validator will help ensure your TypeSpec project follows [standard conventions](https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/typespec-structure-guidelines.md) as well ensures that the [generated OpenAPI spec](https://azure.github.io/typespec-azure/docs/emitters/typespec-autorest) files are in-sync with your project.

### Run `tsv` locally

``` powershell
cd <repo>
git checkout <your-branch>
git merge <target-branch>
npm ci
npx tsv <path-to-your-spec>
git commit; git push (if any changes)
# example
npx tsv specification/contosowidgetmanager/Contoso.WidgetManager
```

Then check any errors that might be outputted and address any issues as needed. If there are changed files after the runit generally means
that the generated OpenAPI spec files were not in-sync with the TypeSpec project and you should include those changes in your pull request as well.

If none of the above helped, please reach out on [TypeSpec Discussions Teams channel].
https://github.com/Azure/azure-rest-api-specs/wiki/TypeSpec-Validation

## `license/cla`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
// az rest --resource <client-id> -u "{URL}" --output-file {FILENAME}
"type": "boolean"
},
"downloadUrlPrefix": {
// All the artifacts will be uploaded and user could access the artifact via
// a link composed by this prefix and artifact filename.
"type": "string"
},
"downloadCommandTemplate": {
// Download command template. Replace {URL} and {FILENAME} to get the real command.
"type": "string"
Expand Down
34 changes: 8 additions & 26 deletions documentation/sdkautomation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ SDK Automation is launched with matrix in azure pipeline. For each language conf
- repo: azure-sdk-for-js
``` <EOL>
```
2. For TypeSpec PR, filter the list of tspconfig.yaml: find the `options` config in tspconfig.yaml, and see if the specified language is configure for that tsp-location.yaml.
2. For TypeSpec PR, filter the list of tspconfig.yaml: find the `options` config in tspconfig.yaml, and see if the specified language emitter is configured.
If the configured language is not found here, generation for this typespec project will be skipped.
If the specific language is not configured here, generation for this typespec project will be skipped.
4. Get `specificationRepositoryConfiguration.json` from spec repo default branch. See [SpecRepoConfig](#specrepoconfig). Get the repo and branch config in the file.
Expand All @@ -46,19 +46,17 @@ SDK Automation is launched with matrix in azure pipeline. For each language conf
11. Launch __buildScript__ to build the package. Collect the artifacts by config __artifactPathFromFileSearch__. This step could be skipped if it's not defined in [SwaggerToSdkConfig](#swaggertosdkconfig) and it's covered by __generateScript__ and the result could be found in [generateOutput.json](#generateoutput).
12. Upload all the package related artifacts to Azure Storage Blob Container. All the artifact for one package is uploaded in one folder. These file could be downloaded on URL prefixed by __downloadUrlPrefix__ defined in [InstallInstructionScriptInput](#installinstructionscriptinput). It's redirected by openapiHub by design, and for SDK Automation on public repo the redirect don't need auth, but for SDK Automation in private repo it requires microsoft AAD auth. User could authenticate and download via web page oauth in browser or bearer token auth with `az rest --resource` in command line.
12. Launch __changelogScript__ to get changelog and detect breaking change. This step could be skipped if changelog and breaking change could be found in [generateOutput.json](#generateoutput). If breaking change is found, the spec PR will be labelled with `BreakingChange-<Lang>-Sdk`.
13. Launch __changelogScript__ to get changelog and detect breaking change. This step could be skipped if changelog and breaking change could be found in [generateOutput.json](#generateoutput). If breaking change is found, the spec PR will be labelled with `CI-BreakingChange-<Lang>`.
13. Launch __installInstructionScript__ to get install instruction for that package. This step could be skipped if install instruction could be found in [generateOutput.json](#generateoutput). The lite install instruction will be shown in spec PR comment, the full install instruction will be shown in generated SDK PR.
14. Launch __installInstructionScript__ to get install instruction for that package. This step could be skipped if install instruction could be found in [generateOutput.json](#generateoutput). The lite install instruction will be shown in spec PR comment, the full install instruction will be shown in generated SDK PR.
15. Commit the package related code in SDK repository. Force push to [GenerationBranch](#generationbranch) in __integrationRepository__. Create or update [GenerationPR](#generationpr) from [GenerationBranch](#generationbranch) to [MainBranch](#mainbranch) in __integrationRepository__. If __integrationRepository__ is a fork of __mainRepository__, its [MainBranch](#mainbranch) should be synced once a day.
14. Commit the package related code in SDK repository. Force push to [GenerationBranch](#generationbranch) in __integrationRepository__. Create or update [GenerationPR](#generationpr) from [GenerationBranch](#generationbranch) to [MainBranch](#mainbranch) in __integrationRepository__. If __integrationRepository__ is a fork of __mainRepository__, its [MainBranch](#mainbranch) should be synced once a day.
### Continuous Integration (PR Merged) Trigger
Almost the same as opened PR trigger, with different on step 15:
Almost the same as opened PR trigger, with different on step 14:
15. Commit the package related code in SDK repository. Close [GenerationPR](#generationpr) and delete [GenerationBranch](#generationbranch). Force push to [IntegrationBranch](#integrationbranch) in __integrationRepository__. Create or update [IntegrationPR](#integrationpr) from [IntegrationBranch](#integrationbranch) to [MainBranch](#mainbranch) in __mainRepository__. Close the [integrationPR](#integrationPR) if __closeIntegrationPR__ in [SwaggerToSdkConfig](#swaggertosdkconfig) is set to true.
14. Commit the package related code in SDK repository. Close [GenerationPR](#generationpr) and delete [GenerationBranch](#generationbranch). Force push to [IntegrationBranch](#integrationbranch) in __integrationRepository__. Create or update [IntegrationPR](#integrationpr) from [IntegrationBranch](#integrationbranch) to [MainBranch](#mainbranch) in __mainRepository__. Close the [integrationPR](#integrationPR) if __closeIntegrationPR__ in [SwaggerToSdkConfig](#swaggertosdkconfig) is set to true.
## Definitions
Expand All @@ -78,16 +76,6 @@ This is type of file `./specificationRepositoryConfiguration.json` in swagger sp
"integrationRepository": "AzureSDKAutomation/azure-sdk-for-python",
"mainRepository": "Azure/azure-sdk-for-python",
"mainBranch": "release/v3"
},
"azure-sdk-for-python-track2": {
"integrationRepository": "AzureSDKAutomation/azure-sdk-for-python",
"mainRepository": "Azure/azure-sdk-for-python"
},
"azure-sdk-for-trenton": {
"integrationRepository": "Azure/azure-sdk-for-trenton",
"mainRepository": "Azure/azure-sdk-for-trenton",
"secondaryRepository": "Azure/azure-sdk-for-trenton",
"secondaryBranch": "secondary"
}
},
"overrides": {
Expand All @@ -101,10 +89,6 @@ This is type of file `./specificationRepositoryConfiguration.json` in swagger sp
"integrationRepository": "azure-sdk/azure-sdk-for-python-pr",
"mainRepository": "Azure/azure-sdk-for-python-pr",
"mainBranch": "release/v3"
},
"azure-sdk-for-python-track2": {
"integrationRepository": "azure-sdk/azure-sdk-for-python-pr",
"mainRepository": "Azure/azure-sdk-for-python-pr"
}
}
}
Expand Down Expand Up @@ -175,7 +159,7 @@ The working folder of all the scripts is the __root folder of sdk repo__.
"breakingChangeDetect": "Breaking Change"
},

"breakingChangeLabel": "CI-BreakingChange-DotNet"
"breakingChangesLabel": "BreakingChange-DotNet-Sdk"
},
"artifactOptions": {
// Param: <path_to_installInstructionInput.json> <path_to_installInstructionOutput.json>
Expand Down Expand Up @@ -214,7 +198,6 @@ Input file for generate script.
],
"installInstructionInput": {
"isPublic": false,
"downloadUrlPrefix": "https://openapihub.test.azure-devex-tools.com/api/sdk-dl-pub?p=Azure/1234/azure-sdk-for-net/",
"downloadCommandTemplate": "curl -L \"{URL}\" -o {FILENAME}",
"trigger": "pullRequest"
}
Expand Down Expand Up @@ -278,7 +261,6 @@ Input of install instruction script.
"sdk/cdn/cdn.snuget"
],
"isPublic": true,
"downloadUrlPrefix": "https://portal.azure-devex-tools.com/api/sdk-dl-pub?p=Azure/azure-rest-api-specs/1234/azure-sdk-for-net/",
"downloadCommandTemplate": "curl -L \"{URL}\" -o {FILENAME}",
"trigger": "pullRequest",
}
Expand Down
2 changes: 1 addition & 1 deletion documentation/sdkautomation/SwaggerToSdkConfigSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
}
}
},
"breakingChangeLabel": {
"breakingChangesLabel": {
// Label to be added in spec PR if breaking change is found
"type": "string"
}
Expand Down
22 changes: 0 additions & 22 deletions eng/pipelines/typespec-requirement.yml

This file was deleted.

Loading

0 comments on commit dabfcaf

Please sign in to comment.