Skip to content

Commit

Permalink
Merge branch 'main' into broken-links-12-19-23
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemunk authored Jan 15, 2024
2 parents 3c9b1a8 + eddb30e commit d03ae78
Show file tree
Hide file tree
Showing 386 changed files with 26,475 additions and 363 deletions.
9 changes: 9 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,15 @@
"Fpushpins"
]
},
{
"filename": "**/specification/maps/data-plane/Spatial/stable/2022-08-01/spatial.json",
"words": [
"postbuffer",
"getbuffer",
"postclosestpoint",
"getclosestpoint"
]
},
{
"filename": "**/specification/communication/data-plane/Chat/preview/2020-09-21-preview2/communicationserviceschat.json",
"words": [
Expand Down
19 changes: 19 additions & 0 deletions custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ arima
arimax
arin
arjun
armn
armtemplates
arp
arpa
Expand Down Expand Up @@ -940,6 +941,7 @@ etags
etcd
ethereum
ethertype
ethi
eucloud
eucloudprototype
eugps
Expand Down Expand Up @@ -1097,6 +1099,7 @@ geofences
geofencing
geojson
geopair
geor
georegions
georeplication
geospatial
Expand Down Expand Up @@ -1170,6 +1173,7 @@ granularities
graphrbac
graphservice
greenplum
grek
groundstation
groupby
groupedby
Expand All @@ -1186,6 +1190,7 @@ guami
guestconfiguration
guid
guids
gujr
gurung
guti
gxlarge
Expand Down Expand Up @@ -1221,6 +1226,7 @@ healthmodels
healthstatus
heatbeat
heatmap
hebr
hecto
helmchart
helpdesk
Expand Down Expand Up @@ -1433,6 +1439,7 @@ jobschedules
johnc
johndeere
johnsmith
jpan
json
jsonl
jsonld
Expand Down Expand Up @@ -1473,6 +1480,7 @@ keyvaultproperties
keyvaulturi
keyversion
khaling
khmr
khtml
kibana
kiswahili
Expand All @@ -1481,6 +1489,7 @@ kmgtpe
kmph
Kmskeyaccessdenied
Kmskeynotfound
knda
knowledgebase
knowledgebases
koelner
Expand Down Expand Up @@ -1523,6 +1532,7 @@ labservices
lajolla
lakehouse
languagedata
laoo
largefacelists
largepersongroups
largerc
Expand Down Expand Up @@ -1753,6 +1763,7 @@ mlapi
mlflow
mlflowtrackinguri
mltable
mlym
mmtc
mnist
mobo
Expand Down Expand Up @@ -1834,6 +1845,7 @@ myimage
mylocation
mylog
mymodel
mymr
mypath
mypicture
mypictures
Expand Down Expand Up @@ -1932,6 +1944,7 @@ nonpaged
nonreadable
nonstarted
nonsupported
nopri
nopublicipaddresses
noreuse
northcentralus
Expand Down Expand Up @@ -1991,6 +2004,7 @@ octokit
odata
odatatype
odbc
odia
oeverify
offboard
offboarding
Expand Down Expand Up @@ -2052,6 +2066,7 @@ optout
organisation
orgs
originpath
orya
oscp
osdisk
osdiskforlinuxsimple
Expand Down Expand Up @@ -2853,6 +2868,7 @@ taginheritance
tagname
tagsandregions
tagvalue
taml
targetduration
taskcompletion
taskcounts
Expand All @@ -2867,6 +2883,7 @@ teamsinterop
telangana
telemetryconfig
teleportal
telu
tempdb
templated
templatelink
Expand Down Expand Up @@ -2895,10 +2912,12 @@ textanalytics
tfidf
tful
tfvc
thaa
thangmi
thirdparty
threatintelligence
threatintelligenceindicators
tibt
tilejson
tileset
tilesetconfiguration
Expand Down
5 changes: 5 additions & 0 deletions documentation/samplefiles/readme.python.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ clear-output-folder: true
no-namespace-folders: true
output-folder: $(python-sdks-folder)/[[ServiceName]]/azure-mgmt-[[ServiceName]]/azure/mgmt/[[ServiceName]]
```
``` yaml $(python)
modelerfour:
flatten-models: false
```
9 changes: 9 additions & 0 deletions eng/pipelines/templates/steps/npm-install.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
parameters:
- name: NodeVersion
type: string
default: 20.x
steps:
- task: NodeTool@0
inputs:
versionSpec: ${{ parameters.NodeVersion }}
displayName: "Use Node ${{ parameters.NodeVersion }}"

- script: npm --version --loglevel info
displayName: npm --version

Expand Down
14 changes: 14 additions & 0 deletions eng/pipelines/typespec-requirement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trigger: none

jobs:
- job:
displayName: TypeSpec Requirement
pool:
name: azsdk-pool-mms-ubuntu-2204-general
vmImage: ubuntu-22.04

steps:
- pwsh: |
$(Build.SourcesDirectory)/eng/scripts/TypeSpec-Requirement.ps1
displayName: TypeSpec Requirement
ignoreLASTEXITCODE: true
3 changes: 2 additions & 1 deletion eng/pipelines/typespec-validation-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ resources:
- main

jobs:
- job: Validate_All_Specs
- job:
displayName: Validate All Specs

strategy:
matrix:
Expand Down
3 changes: 2 additions & 1 deletion eng/pipelines/typespec-validation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
trigger: none

jobs:
- job: Validate_Impacted_Specs
- job:
displayName: Validated Impacted Specs
pool:
name: azsdk-pool-mms-ubuntu-2204-general
vmImage: ubuntu-22.04
Expand Down
110 changes: 110 additions & 0 deletions eng/scripts/TypeSpec-Requirement.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[CmdletBinding()]
param (
)
Set-StrictMode -Version 3

. $PSScriptRoot/ChangedFiles-Functions.ps1
. $PSScriptRoot/Logging-Functions.ps1

$repoPath = Resolve-Path "$PSScriptRoot/../.."
$pathsWithErrors = @()

$filesToCheck = @(Get-ChangedSwaggerFiles).Where({
($_ -notmatch "/(examples|scenarios|restler|common|common-types)/") -and
($_ -match "specification/[^/]+/(data-plane|resource-manager).*?/(preview|stable)/[^/]+/[^/]+\.json$")
})

if (!$filesToCheck) {
LogInfo "No OpenAPI files found to check"
}
else {
# Cache responses to GitHub web requests, for efficiency and to prevent rate limiting
$responseCache = @{}

# - Forward slashes on both Linux and Windows
# - May be nested 4 or 5 levels deep, perhaps even deeper
# - Examples
# - specification/foo/data-plane/Foo/stable/2023-01-01/Foo.json
# - specification/foo/data-plane/Foo/bar/stable/2023-01-01/Foo.json
# - specification/foo/resource-manager/Microsoft.Foo/stable/2023-01-01/Foo.json
foreach ($file in $filesToCheck) {
LogInfo "Checking $file"

$jsonContent = Get-Content (Join-Path $repoPath $file) | ConvertFrom-Json -AsHashtable

if ($null -ne ${jsonContent}?["info"]?["x-typespec-generated"]) {
LogInfo " OpenAPI was generated from TypeSpec (contains '/info/x-typespec-generated')"
# Skip further checks, since spec is already using TypeSpec
continue
}
else {
LogInfo " OpenAPI was not generated from TypeSpec (missing '/info/x-typespec-generated')"
}

# Extract path between "specification/" and "/(preview|stable)"
if ($file -match "specification/(?<servicePath>[^/]+/(data-plane|resource-manager).*?)/(preview|stable)/[^/]+/[^/]+\.json$") {
$servicePath = $Matches["servicePath"]
}
else {
LogError " Path to OpenAPI did not match expected regex. Unable to extract service path."
LogJobFailure
exit 1
}

$urlToStableFolder = "https://github.com/Azure/azure-rest-api-specs/tree/main/specification/$servicePath/stable"

# Avoid conflict with pipeline secret
$logUrlToStableFolder = $urlToStableFolder -replace '^https://',''

LogInfo " Checking $logUrlToStableFolder"

$responseStatus = $responseCache[$urlToStableFolder];
if ($null -ne $responseStatus) {
LogInfo " Found in cache"
}
else {
LogInfo " Not found in cache, making web request"
try {
$response = Invoke-WebRequest -Uri $urlToStableFolder -Method Head -SkipHttpErrorCheck
$responseStatus = $response.StatusCode
$responseCache[$urlToStableFolder] = $responseStatus
}
catch {
LogError " Exception making web request to ${logUrlToStableFolder}: $_"
LogJobFailure
exit 1
}
}

LogInfo " Status: $responseStatus"

if ($responseStatus -eq 200) {
LogInfo " Branch 'main' contains path '$servicePath/stable', so spec already exists and is not required to use TypeSpec"
}
elseif ($response.StatusCode -eq 404) {
LogInfo " Branch 'main' does not contain path '$servicePath/stable', so spec is new and must use TypeSpec"
$pathsWithErrors += $file
}
else {
LogError "Unexpected response from ${logUrlToStableFolder}: ${response.StatusCode}"
LogJobFailure
exit 1
}
}
}

if ($pathsWithErrors.Count -gt 0)
{
# DevOps only adds the first 4 errors to the github checks list so lets always add the generic one first
# and then as many of the individual ones as can be found afterwards
LogError "New specs must use TypeSpec. For more detailed docs see https://aka.ms/azsdk/typespec"
LogJobFailure

foreach ($path in $pathsWithErrors)
{
LogErrorForFile $path "OpenAPI was not generated from TypeSpec, and spec appears to be new"
}
exit 1
}

exit 0
7 changes: 6 additions & 1 deletion eng/tools/typespec-validation/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,28 @@ pr:
- eng/tools/typespec-validation

jobs:
- job: Test
- job:
displayName: Test

strategy:
matrix:
Linux:
Pool: azsdk-pool-mms-ubuntu-2204-general
OsVmImage: ubuntu-22.04
NodeVersion: 18.x
Windows:
Pool: azsdk-pool-mms-win-2022-general
OsVmImage: windows-2022
NodeVersion: 21.x

pool:
name: $(Pool)
vmImage: $(OSVmImage)

steps:
- template: /eng/pipelines/templates/steps/npm-install.yml
parameters:
NodeVersion: $(NodeVersion)

- script: npm test
displayName: npm test
Expand Down
2 changes: 1 addition & 1 deletion eng/tools/typespec-validation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"test": "mocha --recursive --exit"
},
"engines": {
"node": "^16.17.0 || ^18.3.0 || ^20.0.0"
"node": "^18.3.0 || ^20.0.0 || ^21.0.0"
}
}
8 changes: 8 additions & 0 deletions eng/tools/typespec-validation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export async function main() {
const folder = parsedArgs.positionals[0];
const absolutePath = host.normalizePath(folder);

if (!(await host.checkFileExists(absolutePath))) {
console.log(`Folder ${absolutePath} does not exist`);
process.exit(1);
}
if (!(await host.isDirectory(absolutePath))) {
console.log(`Please run TypeSpec Validation on a directory path`);
process.exit(1);
}
console.log("Running TypeSpecValidation on folder: ", absolutePath);

const rules = [
Expand Down
1 change: 1 addition & 0 deletions eng/tools/typespec-validation/src/tsv-host.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface TsvHost {
checkFileExists(file: string): Promise<boolean>;
isDirectory(path: string): Promise<boolean>;
gitOperation(folder: string): IGitOperation;
readTspConfig(folder: string): Promise<string>;
runCmd(cmd: string, cwd: string): Promise<[Error | null, string, string]>;
Expand Down
Loading

0 comments on commit d03ae78

Please sign in to comment.