From 7ccadc727ba0df11fa1207dde159f37d7e5a5bea Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Fri, 1 Sep 2017 16:46:07 -0700 Subject: [PATCH] testci (#4) * testci * clear output folder --- .gulp/common.iced | 4 +- .gulp/gulpfile.iced | 26 +- .gulp/regeneration.iced | 1 + package.json | 5 +- .../2015-02-01-preview/Microsoft.Logic.json | 373 ++++++++++++++++++ 5 files changed, 405 insertions(+), 4 deletions(-) create mode 100644 test/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json diff --git a/.gulp/common.iced b/.gulp/common.iced index 6dbeb15..395d137 100644 --- a/.gulp/common.iced +++ b/.gulp/common.iced @@ -368,7 +368,7 @@ module.exports = autorest: (args,done,ignoreexitcode) -> echo info "Queuing up: AutoRest #{args.join(' ')}" - execute "autorest \"--use=#{basefolder}\" #{args.map((a) -> "\"#{a}\"").join(' ')}" , {silent:true, ignoreexitcode: ignoreexitcode || false}, (code,stdout,stderr) -> + execute "#{basefolder}/node_modules/.bin/autorest \"--use=#{basefolder}\" #{args.map((a) -> "\"#{a}\"").join(' ')}" , { silent:true, ignoreexitcode: ignoreexitcode || false }, (code,stdout,stderr) -> return done(code,stdout,stderr) # build task for global build @@ -411,9 +411,9 @@ Import now: moment().format('YYYYMMDD-HHmm') force: argv.force or false threshold: argv.threshold or ((os.cpus().length)-1) or 1 - verbose: argv.verbose or null workdir: "#{process.env.tmp}/gulp/#{module.exports.guid()}" watch: argv.watch or false +global.verbose = argv.verbose or null mkdir "-p", workdir if !test "-d", workdir diff --git a/.gulp/gulpfile.iced b/.gulp/gulpfile.iced index c9ec091..ce5f743 100644 --- a/.gulp/gulpfile.iced +++ b/.gulp/gulpfile.iced @@ -18,7 +18,31 @@ Import task 'init', "" ,(done)-> Fail "YOU MUST HAVE NODEJS VERSION GREATER THAN 7.10.0" if semver.lt( process.versions.node , "7.10.0" ) done() - + + + # Run language-specific tests: task 'test', "more", [], (done) -> done(); + +# CI job +task 'testci', "more", [], (done) -> + # install latest AutoRest + await autorest ["--latest"], defer code, stderr, stdout + + ## TEST SUITE + global.verbose = true + await run "test", defer _ + + ## REGRESSION TEST + global.verbose = false + # regenerate + await run "regenerate", defer _ + # diff ('add' first so 'diff' includes untracked files) + await execute "git add -A", defer code, stderr, stdout + await execute "git diff --staged -w", defer code, stderr, stdout + # eval + echo stderr + echo stdout + throw "Potentially unnoticed regression (see diff above)! Run `npm run regenerate`, then review and commit the changes." if stdout.length + stderr.length > 0 + done() \ No newline at end of file diff --git a/.gulp/regeneration.iced b/.gulp/regeneration.iced index 8a643c2..2a24dbc 100644 --- a/.gulp/regeneration.iced +++ b/.gulp/regeneration.iced @@ -15,6 +15,7 @@ regenExpected = (opts,done) -> swaggerFiles = (if optsMappingsValue instanceof Array then optsMappingsValue[0] else optsMappingsValue).split(";") args = [ "--#{opts.language}", + "--clear-output-folder", "--output-folder=#{outputDir}/#{key}", "--license-header=#{if !!opts.header then opts.header else 'MICROSOFT_MIT_NO_VERSION'}" ] diff --git a/package.json b/package.json index b6f20ce..fbfb624 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,11 @@ "description": "The Azure Resource Schema extension for classic generators in AutoRest.", "scripts": { "start": "dotnet src/bin/netcoreapp2.0/autorest.azureresourceschema.dll --server", - "test": "gulp test", + "test": "gulp testci", + "testci": "gulp testci", "build": "gulp build", "prepare": "gulp build", + "regenerate": "gulp regenerate", "clean": "gulp clean", "nuke": "git clean -xdf" }, @@ -28,6 +30,7 @@ "homepage": "https://github.com/Azure/autorest.azureresourceschema/blob/master/README.md", "devDependencies": { "@microsoft.azure/autorest.modeler": "1.9.6", + "autorest": "^1.9.1", "coffee-script": "^1.11.1", "dotnet-sdk-2.0.0": "^1.1.1", "gulp": "^3.9.1", diff --git a/test/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json b/test/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json new file mode 100644 index 0000000..d657812 --- /dev/null +++ b/test/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json @@ -0,0 +1,373 @@ +{ + "id": "https://schema.management.azure.com/schemas/2015-02-01-preview/Microsoft.Logic.json#", + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Microsoft.Logic", + "description": "Microsoft Logic Resource Types", + "resourceDefinitions": { + "workflows": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "Microsoft.Logic/workflows" + ] + }, + "apiVersion": { + "type": "string", + "enum": [ + "2015-02-01-preview" + ] + }, + "id": { + "type": "string", + "description": "Gets or sets the resource id." + }, + "location": { + "type": "string", + "description": "Gets or sets the resource location." + }, + "tags": { + "oneOf": [ + { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the resource tags." + }, + "properties": { + "oneOf": [ + { + "$ref": "#/definitions/WorkflowProperties" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the workflow properties." + }, + "resources": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/workflows_accessKeys_childResource" + } + ] + } + } + }, + "required": [ + "name", + "type", + "apiVersion", + "properties" + ], + "description": "Microsoft.Logic/workflows" + }, + "workflows_accessKeys": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "Microsoft.Logic/workflows/accessKeys" + ] + }, + "apiVersion": { + "type": "string", + "enum": [ + "2015-02-01-preview" + ] + }, + "id": { + "type": "string", + "description": "Gets or sets the resource id." + }, + "properties": { + "oneOf": [ + { + "$ref": "#/definitions/WorkflowAccessKeyProperties" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the workflow access key properties." + } + }, + "required": [ + "name", + "type", + "apiVersion", + "properties" + ], + "description": "Microsoft.Logic/workflows/accessKeys" + } + }, + "definitions": { + "ContentHash": { + "type": "object", + "properties": { + "algorithm": { + "type": "string", + "description": "Gets or sets the algorithm." + }, + "value": { + "type": "string", + "description": "Gets or sets the value." + } + } + }, + "ContentLink": { + "type": "object", + "properties": { + "uri": { + "type": "string", + "description": "Gets or sets the content link URI." + }, + "contentVersion": { + "type": "string", + "description": "Gets or sets the content version." + }, + "contentSize": { + "oneOf": [ + { + "type": "integer" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the content size." + }, + "contentHash": { + "oneOf": [ + { + "$ref": "#/definitions/ContentHash" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the content hash." + }, + "metadata": { + "description": "Gets or sets the metadata." + } + } + }, + "ResourceReference": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Gets or sets the resource id." + } + } + }, + "Sku": { + "type": "object", + "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "enum": [ + "NotSpecified", + "Free", + "Shared", + "Basic", + "Standard", + "Premium" + ] + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the name." + }, + "plan": { + "oneOf": [ + { + "$ref": "#/definitions/ResourceReference" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the reference to plan." + } + } + }, + "WorkflowAccessKeyProperties": { + "type": "object", + "properties": { + "notBefore": { + "type": "string", + "format": "date-time", + "description": "Gets or sets the not-before time." + }, + "notAfter": { + "type": "string", + "format": "date-time", + "description": "Gets or sets the not-after time." + } + } + }, + "WorkflowParameter": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "NotSpecified", + "String", + "SecureString", + "Int", + "Float", + "Bool", + "Array", + "Object", + "SecureObject" + ], + "description": "Gets or sets the type." + }, + "value": { + "description": "Gets or sets the value." + }, + "metadata": { + "description": "Gets or sets the metadata." + } + } + }, + "WorkflowProperties": { + "type": "object", + "properties": { + "state": { + "oneOf": [ + { + "type": "string", + "enum": [ + "NotSpecified", + "Enabled", + "Disabled", + "Deleted", + "Suspended" + ] + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the state." + }, + "sku": { + "oneOf": [ + { + "$ref": "#/definitions/Sku" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the sku." + }, + "definitionLink": { + "oneOf": [ + { + "$ref": "#/definitions/ContentLink" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the link to definition." + }, + "definition": { + "description": "Gets or sets the definition." + }, + "parametersLink": { + "oneOf": [ + { + "$ref": "#/definitions/ContentLink" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the link to parameters." + }, + "parameters": { + "oneOf": [ + { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/WorkflowParameter" + } + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the parameters." + } + } + }, + "workflows_accessKeys_childResource": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "accessKeys" + ] + }, + "apiVersion": { + "type": "string", + "enum": [ + "2015-02-01-preview" + ] + }, + "id": { + "type": "string", + "description": "Gets or sets the resource id." + }, + "properties": { + "oneOf": [ + { + "$ref": "#/definitions/WorkflowAccessKeyProperties" + }, + { + "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Gets or sets the workflow access key properties." + } + }, + "required": [ + "name", + "type", + "apiVersion", + "properties" + ], + "description": "Microsoft.Logic/workflows/accessKeys" + } + } +}