Skip to content

Commit

Permalink
scripts (#5213)
Browse files Browse the repository at this point in the history
* scripts

* TRAVIS_PULL_REQUEST

* another try

* TRAVIS_PULL_REQUEST_SLUG

* TRAVIS_REPO_SLUG

* Swagger to SDK

* linter and ruby

* not really a slug

* pool

* indent

* strange

* URI

* env vars

* uri

* env var

* TRAVIS_PULL_REQUEST_SLUG

* matrix

* Azure OpenAPI name

* linter: autorest fix

* error handling and PR_ONLY = true

* syntax

* pipelines.

* job name

* job name

* Names

* params, no getStatus.js

* No CI, only PR validations.

* displayName

* revert back

* no need to show vars
  • Loading branch information
sergey-shandar authored Feb 21, 2019
1 parent 29f93fd commit 90f6af0
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 147 deletions.
91 changes: 84 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,86 @@
pool:
vmImage: 'Ubuntu 16.04'
name: "Azure OpenAPI"

steps:
trigger: none

- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
variables:
TRAVIS: 'true'
TRAVIS_PULL_REQUEST: $(System.PullRequest.PullRequestId)
TRAVIS_REPO_SLUG: $(Build.Repository.Name)
TRAVIS_PULL_REQUEST_SLUG: $(Build.Repository.Name)
TRAVIS_PULL_REQUEST_SHA: $(Build.SourceVersion)
PR_ONLY: 'true'

jobs:

- job: "Syntax"
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
- script: 'npm test -- test/syntax.js'

- job: "Semantic"
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
- script: 'node scripts/semanticValidation.js'

- job: "ModelValidation"
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
- script: 'node scripts/modelValidation.js'

- job: "BreakingChange"
pool:
vmImage: 'Ubuntu 16.04'
steps:
- script: 'scripts/install-dotnet.sh'
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
- script: 'node scripts/breaking-change.js'

- job: "LintDiff"
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
- script: 'scripts/install-dotnet.sh'
- script: 'node scripts/momentOfTruth.js && node scripts/momentOfTruthPostProcessing.js'

- job: "SDK"
strategy:
matrix:
ruby:
AZURE_SDK_REPO: azure-sdk-for-ruby
java:
AZURE_SDK_REPO: azure-sdk-for-java
javascript:
AZURE_SDK_REPO: azure-sdk-for-js
node:
AZURE_SDK_REPO: azure-sdk-for-node
python:
AZURE_SDK_REPO: azure-sdk-for-python
go:
AZURE_SDK_REPO: azure-sdk-for-go
AZURE_SDK_PARAMS: '-o latest'
pool:
vmImage: 'Ubuntu 16.04'
steps:
- script: "scripts/swagger-to-sdk.sh Azure/$(AZURE_SDK_REPO) -v $(AZURE_SDK_PARAMS)"
135 changes: 0 additions & 135 deletions scripts/getStatus.js

This file was deleted.

14 changes: 9 additions & 5 deletions scripts/momentOfTruth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const exec = require('child_process').exec,

let configsToProcess = utils.getConfigFilesChangedInPR();
let pullRequestNumber = utils.getPullRequestNumber();
let linterCmd = `npx autorest@2.0.4302 --validation --azure-validator --message-format=json `;
let linterCmd = `npx autorest --validation --azure-validator --message-format=json `;
var filename = `${pullRequestNumber}.json`;
var logFilepath = path.join(getLogDir(), filename);
var finalResult = {};
Expand Down Expand Up @@ -59,12 +59,16 @@ async function getLinterResult(swaggerPath) {
(err, stdout, stderr) => res({ err: err, stdout: stdout, stderr: stderr })));

if (err && stderr.indexOf("Process() cancelled due to exception") !== -1) {
console.log(`AutoRest exited with code ${err.code}`);
console.log(stderr);
console.error(`AutoRest exited with code ${err.code}`);
console.error(stderr);
throw new Error("AutoRest failed");
}

let resultString = stdout + stderr;
if (stderr !== "") {
console.error(`Error: ${stderr}`)
process.exit(1)
}
let resultString = stdout;
if (resultString.indexOf('{') !== -1) {
resultString = resultString.replace(/Processing batch task - {.*} \.\n/g, "");
resultString = "[" + resultString.substring(resultString.indexOf('{')).trim().replace(/\}\n\{/g, "},\n{") + "]";
Expand All @@ -76,7 +80,7 @@ async function getLinterResult(swaggerPath) {
//console.dir(resultObject, {depth: null, colors: true});
return jsonResult;
} catch (e) {
console.log(`An error occurred while executing JSON.parse() on the linter output for ${swaggerPath}:`);
console.error(`An error occurred while executing JSON.parse() on the linter output for ${swaggerPath}:`);
console.dir(resultString);
console.dir(e, { depth: null, colors: true });
process.exit(1)
Expand Down

0 comments on commit 90f6af0

Please sign in to comment.