Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemunk committed Jan 11, 2024
2 parents 0ffb1b1 + ea28180 commit 38da1bc
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 17 deletions.
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
2 changes: 1 addition & 1 deletion eng/pipelines/typespec-requirement.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
trigger: none

jobs:
- job: TypeSpec_Requirement
- job:
displayName: TypeSpec Requirement
pool:
name: azsdk-pool-mms-ubuntu-2204-general
Expand Down
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
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
6 changes: 5 additions & 1 deletion eng/tools/typespec-validation/src/tsv-runner-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { readFile } from "fs/promises";
import { IGitOperation, TsvHost } from "./tsv-host.js";
import { globby } from "globby";
import { simpleGit } from "simple-git";
import { checkFileExists, normalizePath, runCmd } from "./utils.js";
import { checkFileExists, isDirectory, normalizePath, runCmd } from "./utils.js";

export class TsvRunnerHost implements TsvHost {
checkFileExists(file: string): Promise<boolean> {
return checkFileExists(file);
}

isDirectory(path: string) {
return isDirectory(path);
}

gitOperation(folder: string): IGitOperation {
return simpleGit(folder);
}
Expand Down
6 changes: 5 additions & 1 deletion eng/tools/typespec-validation/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { access } from "fs/promises";
import { access, stat } from "fs/promises";
import { exec } from "child_process";
import defaultPath, { PlatformPath } from "path";

Expand All @@ -22,6 +22,10 @@ export async function checkFileExists(file: string) {
.catch(() => false);
}

export async function isDirectory(path: string) {
return (await stat(path)).isDirectory();
}

export function normalizePath(folder: string, path: PlatformPath = defaultPath) {
return path
.resolve(folder)
Expand Down
4 changes: 4 additions & 0 deletions eng/tools/typespec-validation/test/tsv-test-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export class TsvTestHost implements TsvHost {
return true;
}

async isDirectory(_path: string): Promise<boolean> {
return true;
}

normalizePath(folder: string): string {
return normalizePath(folder, this.path);
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions specification/maps/data-plane/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ These are the global settings for MapsClient.
``` yaml
title: MapsClient
openapi-type: data-plane
tag: package-stable-2023-07-01
tag: package-stable-2023-06-01
```
### Suppression
Expand All @@ -51,16 +51,16 @@ directive:

```

### Tag: package-stable-2023-07-01
### Tag: package-stable-2023-06-01

These settings apply only when `--tag=package-stable-2023-07-01` is specified on the command line.
These settings apply only when `--tag=package-stable-2023-06-01` is specified on the command line.

```yaml $(tag) == 'package-stable-2023-07-01'
```yaml $(tag) == 'package-stable-2023-06-01'
input-file:
- Common/stable/2023-06-01/common.json
- DataRegistry/stable/2023-06-01/dataregistry.json
- Geolocation/preview/1.0/geolocation.json
- Microsoft.Maps/Data/preview/2.0/data.json
- Creator/preview/2.0/data.json
- Render/stable/2022-08-01/render.json
- Route/preview/1.0/route.json
- Search/stable/2023-06-01/search.json
Expand Down Expand Up @@ -88,6 +88,7 @@ These settings apply only when `--tag=package-deprecated` is specified on the co
``` yaml $(tag) == 'package-deprecated'
input-file:
- Microsoft.Maps/Alias/preview/2.0/alias.json
- Microsoft.Maps/Data/preview/2.0/data.json
- Microsoft.Maps/DEM/preview/1.0/elevation.json
- Microsoft.Maps/Feedback/preview/1.0/feedback.json
- Microsoft.Maps/Geolocation/preview/1.0/geolocation.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Generate all API versions currently shipped for this package
clear-output-folder: true
batch:
- tag: package-passivestamp-2021-11-15
- tag: package-2023-06
- tag: package-2023-04
```
### Tag: package-passivestamp-2021-11-15 and python
Expand All @@ -32,12 +32,12 @@ namespace: azure.mgmt.recoveryservicesbackup.passivestamp
output-folder: $(python-sdks-folder)/recoveryservices/azure-mgmt-recoveryservicesbackup/azure/mgmt/recoveryservicesbackup/passivestamp
```

### Tag: package-2023-06 and python
### Tag: package-2023-04 and python

These settings apply only when `--package-2023-06 --python` is specified on the command line.
These settings apply only when `--package-2023-04 --python` is specified on the command line.
Please also specify `--python-sdks-folder=<path to the root directory of your azure-sdk-for-python clone>`.

``` yaml $(tag) == 'package-2023-06'
``` yaml $(tag) == 'package-2023-04'
namespace: azure.mgmt.recoveryservicesbackup.activestamp
output-folder: $(python-sdks-folder)/recoveryservices/azure-mgmt-recoveryservicesbackup/azure/mgmt/recoveryservicesbackup/activestamp
```
Expand Down

0 comments on commit 38da1bc

Please sign in to comment.