From 17e93ae6ae3a3395e48bb5adba3cc9939e005722 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Thu, 28 Jan 2021 16:25:28 -0800 Subject: [PATCH] Provide a way to demo changes & Fix m4 published version (#3814) --- common/config/rush/command-line.json | 11 +--- common/config/rush/pnpm-lock.yaml | 16 +++-- eng/pipelines/pr.yaml | 27 ++++---- .../resources/tryit-comment-template.md | 31 +++++++++ .../scripts/get-tryit-github-comment.ps1 | 64 +++++++++++++++++++ .../templates/create-tryit-comment.yaml | 9 +++ eng/pipelines/templates/regression-tests.yaml | 42 ++++++++++++ .../extensions/modelerfour/CHANGELOG.json | 26 ++++++-- packages/extensions/modelerfour/CHANGELOG.md | 9 ++- packages/extensions/modelerfour/package.json | 12 ++-- 10 files changed, 208 insertions(+), 39 deletions(-) create mode 100644 eng/pipelines/resources/tryit-comment-template.md create mode 100644 eng/pipelines/scripts/get-tryit-github-comment.ps1 create mode 100644 eng/pipelines/templates/create-tryit-comment.yaml create mode 100644 eng/pipelines/templates/regression-tests.yaml diff --git a/common/config/rush/command-line.json b/common/config/rush/command-line.json index 6a0bd0193..265d48c2a 100644 --- a/common/config/rush/command-line.json +++ b/common/config/rush/command-line.json @@ -29,16 +29,11 @@ "shellCommand": "node .scripts/sync-versions.js" }, { - "commandKind": "global", - "name": "watch", - "summary": "run npm watch on all projects", - "shellCommand": "node .scripts/watch.js" - }, - { - "commandKind": "global", + "commandKind": "bulk", "name": "clean", "summary": "run npm clean on all projects", - "shellCommand": "node .scripts/npm-run.js clean" + "enableParallelism": false, + "ignoreMissingScript": true }, { "commandKind": "bulk", diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 2af6b99d8..074395fb9 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1,7 +1,6 @@ dependencies: '@azure-tools/async-io': 3.0.253 '@azure-tools/autorest-extension-base': 3.1.267 - '@azure-tools/codegen': 2.5.290 '@azure-tools/codegen-csharp': 3.0.263 '@azure-tools/datastore': 4.1.270 '@azure-tools/deduplication': 3.0.267 @@ -123,6 +122,15 @@ packages: dev: false resolution: integrity: sha512-z0uY22Ko7FKqC9L1V/UCAyPKoqyaM8oawRmuVuhjtglds9eIxQ7b6K68a3WYw0NQU/YKhf8LBiTs1hG7nZM3aQ== + /@azure-tools/codegen/2.5.292: + dependencies: + '@azure-tools/async-io': 3.0.253 + '@azure-tools/linq': 3.1.262 + js-yaml: 3.13.1 + semver: 5.7.1 + dev: false + resolution: + integrity: sha512-UU9/OgJfd+br9C/M9R8k2r+pyWtanRfl/u865BvkX3yBbMLbDsj12QP/AcY3MoC40rHpWYUJVTBDB84X3zIiIw== /@azure-tools/codemodel/4.13.349: dependencies: '@azure-tools/autorest-extension-base': 3.1.267 @@ -8767,7 +8775,7 @@ packages: dependencies: '@azure-tools/async-io': 3.0.253 '@azure-tools/autorest-extension-base': 3.1.267 - '@azure-tools/codegen': 2.5.290 + '@azure-tools/codegen': 2.5.292 '@azure-tools/codegen-csharp': 3.0.263 '@azure-tools/codemodel': 4.13.349 '@azure-tools/datastore': 4.1.270 @@ -8790,6 +8798,7 @@ packages: js-yaml: 3.13.1 prettier: 2.2.1 recursive-diff: 1.0.8 + rimraf: 3.0.2 source-map-support: 0.5.19 static-link: 0.3.0 ts-jest: 26.4.4_jest@26.6.3+typescript@3.9.7 @@ -8797,7 +8806,7 @@ packages: dev: false name: '@rush-temp/modelerfour' resolution: - integrity: sha512-lokZcSmnXJ8Lhinh3RPZ7v3vxH24X3VDM+/6qi6tZyG0aPIvJhOCwokzJfCw/K47RUzTP6k7GELsCfnpy9TN/A== + integrity: sha512-Fpn+sfIwI8eDlFc998JwlGPnegZfgyqu3zhQZpEYk75GFQ8CbTDBm9pZhNfef7+XldedKgH+aNhYh2VZqJgw+w== tarball: 'file:projects/modelerfour.tgz' version: 0.0.0 'file:projects/schemas.tgz': @@ -8811,7 +8820,6 @@ registry: '' specifiers: '@azure-tools/async-io': ~3.0.0 '@azure-tools/autorest-extension-base': ~3.1.0 - '@azure-tools/codegen': 2.5.290 '@azure-tools/codegen-csharp': ~3.0.0 '@azure-tools/datastore': ~4.1.0 '@azure-tools/deduplication': ~3.0.266 diff --git a/eng/pipelines/pr.yaml b/eng/pipelines/pr.yaml index 5061f383a..6a8c8f2a8 100644 --- a/eng/pipelines/pr.yaml +++ b/eng/pipelines/pr.yaml @@ -14,28 +14,27 @@ jobs: steps: - template: ./templates/verify-changes.yaml - template: ./templates/build.yaml - + - script: npx @microsoft/rush test:ci -v displayName: Test - script: npx @microsoft/rush lint -v displayName: Lint - - task: UsePythonVersion@0 - inputs: - versionSpec: "3.x" - displayName: Install Python 3 + - script: npx @microsoft/rush publish --publish --pack --include-all + displayName: Pack packages - - script: | - npm install @microsoft.azure/autorest.testserver --no-save - npm install -g @autorest/compare@~0.3.0 - displayName: Install autorest-compare + - publish: $(Build.SourcesDirectory)/common/temp/artifacts/packages + artifact: packages + displayName: Publish packages(.tgz) as pipeline artifacts - - script: autorest-compare --compare:.scripts/regression-compare.yaml --language:python - displayName: Regression Test - @autorest/python + - template: ./templates/create-tryit-comment.yaml - - script: autorest-compare --compare:.scripts/regression-compare.yaml --language:typescript - displayName: Regression Test - @autorest/typescript + - job: regressiontests + displayName: Regression tests + dependsOn: main + steps: + - template: ./templates/regression-tests.yaml - job: lintdocs displayName: Lint docs @@ -43,4 +42,4 @@ jobs: - script: | sudo npm install -g markdown-link-check find docs -name "*.md" -print0 | xargs -0 -n1 markdown-link-check -c ./markdown-link-check-config.json - displayName: Find + displayName: Find diff --git a/eng/pipelines/resources/tryit-comment-template.md b/eng/pipelines/resources/tryit-comment-template.md new file mode 100644 index 000000000..bc6aa6c95 --- /dev/null +++ b/eng/pipelines/resources/tryit-comment-template.md @@ -0,0 +1,31 @@ +You may test this build by running `autorest --reset` and then either: + +
+Add the following CLI flags + +| Pacakge | Flag | Description | +| --------------------- | -------------------------------------------- | ----------------------------- | +| @autorest/core | `--version:{{AUTOREST_CORE_DOWNLOAD_URL}}` | For changes to autorest core. | +| @autorest/modelerfour | `--use:{{AUTOREST_MODELERFOUR_DOWNLOAD_URL}}` | For changes to modelerfour. | + +Or with all + +```bash +autorest --version:{{AUTOREST_CORE_DOWNLOAD_URL}} --use:{{AUTOREST_MODELERFOUR_DOWNLOAD_URL}} +``` + +
+or use the following in your autorest configuration: + +```yaml +# For changes to autorest core +version: "{{AUTOREST_CORE_DOWNLOAD_URL}}" + +# For changes to modelerfour +use-extension: + "@autorest/modelerfour": "{{AUTOREST_MODELERFOUR_DOWNLOAD_URL}}" +``` + +
+If this build is good for you, give this comment a thumbs up. (👍) +And you should run `autorest --reset` again once you're finished testing to remove it. diff --git a/eng/pipelines/scripts/get-tryit-github-comment.ps1 b/eng/pipelines/scripts/get-tryit-github-comment.ps1 new file mode 100644 index 000000000..d679a8d90 --- /dev/null +++ b/eng/pipelines/scripts/get-tryit-github-comment.ps1 @@ -0,0 +1,64 @@ +$root = $env:BUILD_SOURCESDIRECTORY + + +function Get-ArtifactBaseDownloadUrl() { + $url = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI$env:SYSTEM_TEAMPROJECTID/_apis/build/builds/$env:BUILD_BUILDID/artifacts?artifactName=packages&api-version=5.1" + Write-Host "Getting artifact info at: '$url'" + + $buildPipeline= Invoke-RestMethod -Uri $url -Headers @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } -Method Get + $ArtifactDownloadURL= $buildPipeline.resource.downloadUrl + return $ArtifactDownloadURL +} + +function Get-DownloadUrl([string] $baseDownloadUrl, [string] $filename) { + return $baseDownloadUrl -replace "format=zip","format=file&subPath=%2F$filename"; +} + +function Create-TinyUrlForArtifact([string] $baseDownloadUrl, [string] $filename, [string]$outVarName) { + $downloadUrl = Get-DownloadUrl -baseDownloadUrl $baseDownloadUrl -filename $filename + Write-Host "Raw Artifact Url: '$downloadUrl'" + $downurl = (iwr "http://tinyurl.com/api-create.php?url=$( [System.Web.HttpUtility]::UrlEncode($downloadUrl))" ).Content + Write-Host "Tiny Url: '$tinyUrl'" + return $downurl; +} + +function Get-PackageVersion([string] $packageRoot) { + $version = (Get-Content "$packageRoot/package.json") -join "`n" | ConvertFrom-Json | Select -ExpandProperty "version"; + Write-Host "Version for package at $packageRoot is $version" + return $version; +} + +function Format-Comment([string] $coreDownloadUrl, [string] $modelerfourDownloadUrl) { + $template = get-content -raw -encoding utf8 "$root/eng/pipelines/resources/tryit-comment-template.md"; + $AUTOREST_CORE_DOWNLOAD_URL = $coreDownloadUrl + $AUTOREST_MODELERFOUR_DOWNLOAD_URL = $modelerfourDownloadUrl + + return $template ` + -replace "{{AUTOREST_CORE_DOWNLOAD_URL}}", $coreDownloadUrl ` + -replace "{{AUTOREST_MODELERFOUR_DOWNLOAD_URL}}", $modelerfourDownloadUrl +} + +function Run() { + $baseDownloadUrl = Get-ArtifactBaseDownloadUrl + Write-Host "Base download url is $baseDownloadUrl"; + + $coreVersion = Get-PackageVersion -packageRoot $root/packages/extensions/core + $m4Version = Get-PackageVersion -packageRoot $root/packages/extensions/modelerfour + + $coreDownloadUrl = Create-TinyUrlForArtifact -baseDownloadUrl $baseDownloadUrl -filename "autorest-core-$coreVersion.tgz"; + $modelerfourDownloadUrl = Create-TinyUrlForArtifact -baseDownloadUrl $baseDownloadUrl -filename "autorest-modelerfour-$m4Version.tgz"; + + $comment = Format-Comment -coreDownloadUrl $coreDownloadUrl -modelerfourDownloadUrl $modelerfourDownloadUrl + + Write-Host "Github comment content:" + Write-Host "-----------------------" + Write-Host $comment + Write-Host "-----------------------" + + $escapedComment = $comment -replace "`n", "%0D%0A" + Write-Host "$escapedComment" + Write-Host "======================" + Write-Host "##vso[task.setvariable variable=TRYIT_COMMENT]$escapedComment" +} + +Run \ No newline at end of file diff --git a/eng/pipelines/templates/create-tryit-comment.yaml b/eng/pipelines/templates/create-tryit-comment.yaml new file mode 100644 index 000000000..b8313ada6 --- /dev/null +++ b/eng/pipelines/templates/create-tryit-comment.yaml @@ -0,0 +1,9 @@ +steps: + - pwsh: $(Build.SourcesDirectory)/eng/pipelines/scripts/get-tryit-github-comment.ps1 + displayName: "Build Github Comment" + + - task: GitHubComment@0 + inputs: + gitHubConnection: "Azure" + repositoryName: "$(Build.Repository.Name)" + comment: $(TRYIT_COMMENT) \ No newline at end of file diff --git a/eng/pipelines/templates/regression-tests.yaml b/eng/pipelines/templates/regression-tests.yaml new file mode 100644 index 000000000..8351f4746 --- /dev/null +++ b/eng/pipelines/templates/regression-tests.yaml @@ -0,0 +1,42 @@ +# Steps the for regresion test using autorest-compare. +steps: + - download: current + artifact: packages + displayName: Download packages(.tgz) + + - script: | + corePkg="$(find $(Pipeline.Workspace)/packages -type f -iname "autorest-core-*.tgz" )" + modelerfourPkg="$(find $(Pipeline.Workspace)/packages -type f -iname "autorest-modelerfour-*.tgz" )" + + [ -z "$corePkg" ] && echo "Error: Couldn't find autorest core package" && exit 1 + [ -z "$modelerfourPkg" ] && echo "Error: Couldn't find autorest modelerfour package" && exit 1 + + echo "Found core package $corePkg" + echo "Found modelerfour package $modelerfourPkg" + + sed -i "s,--version:../packages/extensions/core,--version:$corePkg," ./.scripts/regression-compare.yaml + sed -i "s,--use:../packages/extensions/modelerfour,--use:$modelerfourPkg," ./.scripts/regression-compare.yaml + displayName: Find packages path + + - script: cat ./.scripts/regression-compare.yaml + + - task: NodeTool@0 + inputs: + versionSpec: "14.x" + displayName: "Install Node.js" + + - task: UsePythonVersion@0 + inputs: + versionSpec: "3.x" + displayName: Install Python 3 + + - script: | + npm install @microsoft.azure/autorest.testserver --no-save + npm install -g @autorest/compare@~0.3.0 + displayName: Install autorest-compare + + - script: autorest-compare --compare:.scripts/regression-compare.yaml --language:python + displayName: Regression Test - @autorest/python + + - script: autorest-compare --compare:.scripts/regression-compare.yaml --language:typescript + displayName: Regression Test - @autorest/typescript diff --git a/packages/extensions/modelerfour/CHANGELOG.json b/packages/extensions/modelerfour/CHANGELOG.json index e79b6fbfe..e6676bf21 100644 --- a/packages/extensions/modelerfour/CHANGELOG.json +++ b/packages/extensions/modelerfour/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@autorest/modelerfour", "entries": [ + { + "version": "4.15.456", + "tag": "@autorest/modelerfour_v4.15.456", + "date": "Thu, 28 Jan 2021 00:22:27 GMT", + "comments": { + "patch": [ + { + "comment": "Fix static linking issue with modelerfour resulting in incompatible dependency." + } + ] + } + }, { "version": "4.15.455", "tag": "@autorest/modelerfour_v4.15.455", @@ -22,22 +34,22 @@ "version": "4.15.x", "comments": { "patch": [ - { + { "comment": "**Fix** Missing description in responses. ([PR 370](https://github.com/Azure/autorest.modelerfour/pull/370))" }, - { + { "comment": "**Feature** Added new flag `always-create-accept-parameter` to enable/disable accept param auto generation. ([PR 366](https://github.com/Azure/autorest.modelerfour/pull/366))" }, - { + { "comment": "**Fix** Allow request with body being a file and `application/json` content-type. ([PR 363](https://github.com/Azure/autorest.modelerfour/pull/363))" }, - { + { "comment": "**Fix** Dictionaries of dictionaries not being modeled as such(`dict[str, object]` instead of `dict[str, dict[str, str]]`). ([PR 372](https://github.com/Azure/autorest.modelerfour/pull/372))" }, - { + { "comment": "**Fix** Issue with sibling models(Model just being a ref of another) causing circular dependency exception. ([PR 375](https://github.com/Azure/autorest.modelerfour/pull/375))" }, - { + { "comment": "**Fix** Issue with duplicates schemas names due to consequtive name duplicate removal. ([PR 374](https://github.com/Azure/autorest.modelerfour/pull/374))" }, { @@ -219,7 +231,7 @@ "version": "4.2.75", "comments": { "patch": [ - { + { "comment": "add `style` to parameters to support collection format " }, { diff --git a/packages/extensions/modelerfour/CHANGELOG.md b/packages/extensions/modelerfour/CHANGELOG.md index 39d4a9d07..1764a3a23 100644 --- a/packages/extensions/modelerfour/CHANGELOG.md +++ b/packages/extensions/modelerfour/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @autorest/modelerfour -This log was last generated on Tue, 26 Jan 2021 22:07:03 GMT and should not be manually modified. +This log was last generated on Thu, 28 Jan 2021 00:22:27 GMT and should not be manually modified. + +## 4.15.456 +Thu, 28 Jan 2021 00:22:27 GMT + +### Patches + +- Fix static linking issue with modelerfour resulting in incompatible dependency. ## 4.15.455 Tue, 26 Jan 2021 21:36:02 GMT diff --git a/packages/extensions/modelerfour/package.json b/packages/extensions/modelerfour/package.json index 0b6cb1efe..e5e38ef80 100644 --- a/packages/extensions/modelerfour/package.json +++ b/packages/extensions/modelerfour/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/modelerfour", - "version": "4.15.455", + "version": "4.15.456", "description": "AutoRest Modeler Version Four (component)", "directories": { "doc": "docs" @@ -11,6 +11,7 @@ "main": "dist/exports.js", "typings": "dist/exports.d.ts", "scripts": { + "clean": "rimraf ./dist", "start": "node --max_old_space_size=4096 ./entrypoints/main.js", "debug": "node --max_old_space_size=4096 --inspect-brk=localhost:9229 ./entrypoints/main.js", "fix": "eslint ./src --fix --ext .ts", @@ -52,7 +53,7 @@ "jest-snapshot": "~26.6.2", "expect": "~26.6.2", "ts-jest": "^26.4.4", - "@azure-tools/codegen": "2.5.290", + "@azure-tools/codegen": "~2.5.292", "@azure-tools/codegen-csharp": "~3.0.0", "@azure-tools/autorest-extension-base": "~3.1.0", "@autorest/codemodel": "~4.14.3", @@ -64,15 +65,16 @@ "chalk": "2.3.0", "recursive-diff": "~1.0.6", "prettier": "~2.2.1", - "eslint-plugin-prettier": "~3.2.0" + "eslint-plugin-prettier": "~3.2.0", + "rimraf": "~3.0.0" }, "static-link": { "entrypoints": [], "dependencies": { - "@azure-tools/codegen": "~2.4.0", + "@azure-tools/codegen": "~2.5.292", "@azure-tools/codegen-csharp": "~3.0.0", "@azure-tools/autorest-extension-base": "~3.1.0", - "@autorest/codemodel": "~4.14.0", + "@autorest/codemodel": "~4.14.3", "@azure-tools/tasks": "~3.0.0", "@azure-tools/openapi": "~3.0.0", "@azure-tools/datastore": "~4.1.0",