diff --git a/.devops/azure-pipelines-test-dependent-projects.yml b/.devops/azure-pipelines-test-dependent-projects.yml index ddc7fd2d..a7c314d1 100644 --- a/.devops/azure-pipelines-test-dependent-projects.yml +++ b/.devops/azure-pipelines-test-dependent-projects.yml @@ -1,29 +1,96 @@ +variables: + artifactName: ms-rest-js + msRestJsPackageName: azure-ms-rest-js.tgz + msRestAzureArtifactName: ms-rest-azure-js + msRestAzureJsPackageName: azure-ms-rest-azure-js.tgz + tempDirectory: $(Pipeline.Workspace)/.tmp + vmImage: 'Ubuntu 16.04' + jobs: -- job: Test_dependent_projects +- job: prepare_ms_rest_js + displayName: 'Pack and upload ms-rest-js' pool: - vmImage: 'Ubuntu 16.04' + vmImage: $(vmImage) steps: - - task: Npm@1 - displayName: 'npm install' + - script: 'npm pack' + displayName: 'npm pack' + - script: 'mv azure-ms-rest-js-*.tgz $(msRestJsPackageName)' + displayName: 'rename artifact' + - task: PublishPipelineArtifact@0 inputs: - command: custom - verbose: false - customCommand: install - - task: Npm@1 - displayName: 'Build ms-rest-js' + artifactName: $(artifactName) + targetPath: $(msRestJsPackageName) + +- job: test_ms_rest_azure_js + displayName: 'Test ms-rest-azure-js with PR ms-rest-js' + dependsOn: prepare_ms_rest_js + pool: + vmImage: $(vmImage) + variables: + repoDir: '$(tempDirectory)/ms-rest-azure-js' + steps: + - task: DownloadPipelineArtifact@0 + inputs: + artifactName: $(artifactName) + targetPath: $(System.DefaultWorkingDirectory) + - script: 'mkdir -p $(tempDirectory)' + displayName: 'mkdir -p $(tempDirectory)' + - script: 'git clone https://github.com/Azure/ms-rest-azure-js.git ms-rest-azure-js --depth 1' + workingDirectory: $(tempDirectory) + displayName: "clone ms-rest-azure-js" + - script: 'npm pack' + workingDirectory: $(repoDir) + displayName: 'npm pack' + - script: 'npm install $(Build.SourcesDirectory)/$(msRestJsPackageName)' + workingDirectory: $(repoDir) + displayName: 'npm install @azure/ms-rest-js' + - script: 'npm run test' + workingDirectory: $(repoDir) + displayName: "npm run test" + - script: 'mv azure-ms-rest-azure-js-*.tgz $(msRestAzureJsPackageName)' + workingDirectory: $(repoDir) + displayName: 'rename artifact' + - task: PublishPipelineArtifact@0 inputs: - command: custom - verbose: false - customCommand: 'run build' - - task: Npm@1 - displayName: 'npm run dep:ms-rest-azure-js' + artifactName: $(msRestAzureArtifactName) + targetPath: '$(repoDir)/$(msRestAzureJsPackageName)' + +- job: test_autorest_typescript + displayName: 'Test autorest.typescript with PR ms-rest-js' + dependsOn: [prepare_ms_rest_js, test_ms_rest_azure_js] + pool: + vmImage: $(vmImage) + variables: + repoDir: '$(tempDirectory)/autorest.typescript' + steps: + - task: DownloadPipelineArtifact@0 inputs: - command: custom - verbose: true - customCommand: run dep:ms-rest-azure-js - - task: Npm@1 - displayName: 'npm run dep:autorest.typescript' + artifactName: $(artifactName) + targetPath: $(System.DefaultWorkingDirectory) + - task: DownloadPipelineArtifact@0 inputs: - command: custom - verbose: true - customCommand: run dep:autorest.typescript + artifactName: $(msRestAzureArtifactName) + targetPath: $(System.DefaultWorkingDirectory) + - script: 'mkdir -p $(tempDirectory)' + displayName: 'mkdir -p $(tempDirectory)' + - script: 'git clone https://github.com/Azure/autorest.typescript.git autorest.typescript --recursive --depth 1' + workingDirectory: $(tempDirectory) + displayName: "clone autorest.typescript" + - script: 'npm install $(Build.SourcesDirectory)/$(msRestAzureJsPackageName)' + workingDirectory: $(repoDir) + displayName: 'npm install @azure/ms-rest-azure-js' + - script: 'npm install $(Build.SourcesDirectory)/$(msRestJsPackageName)' + workingDirectory: $(repoDir) + displayName: 'npm install @azure/ms-rest-js' + - script: 'cat package.json' + workingDirectory: $(repoDir) + displayName: "debug" + - script: 'npm install --verbose' + workingDirectory: $(repoDir) + displayName: "npm install" + - script: 'gulp regenerate' + workingDirectory: $(repoDir) + displayName: 'gulp regenerate' + - script: 'gulp test' + workingDirectory: $(repoDir) + displayName: 'gulp test' diff --git a/.scripts/testDependentProjects.ts b/.scripts/testDependentProjects.ts index d7b629ab..e88e182b 100644 --- a/.scripts/testDependentProjects.ts +++ b/.scripts/testDependentProjects.ts @@ -16,7 +16,7 @@ async function execAndLog(executable: string, args?: string[], options?: RunOpti showResult: true, }); - console.log(`\Result of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n"); + console.log(`\nResult of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n"); if (result.exitCode) { console.error(`Error while running "${commandToString(command)}": ${result.error}`); @@ -26,6 +26,32 @@ async function execAndLog(executable: string, args?: string[], options?: RunOpti return Promise.resolve(result); } +async function cloneRepository(projectName: string, projectDirectory: string) { + const gitHubUrl = `https://github.com/Azure/${projectName}.git`; + await execAndLog(`git`, ["clone", gitHubUrl, projectDirectory, "--recursive"]); + await execAndLog(`npm`, [ "install" ], { executionFolderPath: projectDirectory }); +} + +async function buildAndTest(projectDirectory: string) { + await execAndLog(`npm`, [ "run", "build" ], { executionFolderPath: projectDirectory }); + await execAndLog(`npm`, [ "run", "test" ], { executionFolderPath: projectDirectory }); +} + +async function cloneAndRunTest(msRestJsDirectory: string, projectName: string) { + const projectDirectory = path.join(msRestJsDirectory, `../.tmp/${projectName}`); + await cloneRepository(projectName, projectDirectory); + + await execAndLog(`npm`, [ "install", msRestJsDirectory ], { executionFolderPath: projectDirectory }); + + const additionalCommands: string[] = process.argv.slice(3); + for (const command of additionalCommands) { + await execAndLog(command, undefined, { executionFolderPath: projectDirectory }); + } + + await buildAndTest(projectDirectory); + await execAndLog(`rm`, [ "-rf", projectDirectory ]); +} + (async () => { try { console.log(`Passed parameters:\n${process.argv}`); @@ -33,21 +59,7 @@ async function execAndLog(executable: string, args?: string[], options?: RunOpti console.log(`ms-rest-js directory: ${msRestJsDirectory}`); const projectName = process.argv[2]; - const projectDirectory = path.join(msRestJsDirectory, `../.tmp/${projectName}`); - const gitHubUrl = `https://github.com/Azure/${projectName}.git`; - - await execAndLog(`git`, ["clone", gitHubUrl, projectDirectory, "--recursive"]); - await execAndLog(`npm`, [ "install", msRestJsDirectory ], { executionFolderPath: projectDirectory }); - await execAndLog(`npm`, [ "install" ], { executionFolderPath: projectDirectory }); - - const additionalCommands: string[] = process.argv.slice(3); - for (const command of additionalCommands) { - await execAndLog(command, undefined, { executionFolderPath: projectDirectory }); - } - - await execAndLog(`npm`, [ "run", "build" ], { executionFolderPath: projectDirectory }); - await execAndLog(`npm`, [ "run", "test" ], { executionFolderPath: projectDirectory }); - await execAndLog(`rm`, [ "-rf", projectDirectory ]); + await cloneAndRunTest(msRestJsDirectory, projectName); } catch (error) { process.exit(1); } diff --git a/lib/util/constants.ts b/lib/util/constants.ts index e01d0cba..972df557 100644 --- a/lib/util/constants.ts +++ b/lib/util/constants.ts @@ -7,7 +7,7 @@ export const Constants = { * @const * @type {string} */ - msRestVersion: "1.8.10", + msRestVersion: "1.8.11", /** * Specifies HTTP. diff --git a/package.json b/package.json index 2424f058..66dc5063 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "email": "azsdkteam@microsoft.com", "url": "https://github.com/Azure/ms-rest-js" }, - "version": "1.8.10", + "version": "1.8.11", "description": "Isomorphic client Runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest", "tags": [ "isomorphic", @@ -139,7 +139,7 @@ "test:unit": "nyc mocha", "test:karma": "npm run build:test-browser && node ./node_modules/karma/bin/karma start karma.conf.ts --browsers ChromeNoSecurity --single-run ", "test:karma:debug": "npm run build:test-browser && node ./node_modules/karma/bin/karma start karma.conf.ts --log-level debug --browsers ChromeDebugging --debug --auto-watch", - "dep:autorest.typescript": "npx ts-node .scripts/testDependentProjects.ts autorest.typescript 'gulp build' 'gulp regenerate' 'npm run local'", + "dep:autorest-typescript": "npx ts-node .scripts/testDependentProjects.ts autorest.typescript 'gulp build' 'gulp regenerate' 'npm run local'", "dep:ms-rest-azure-js": "npx ts-node .scripts/testDependentProjects.ts ms-rest-azure-js", "publish-preview": "mocha --no-colors && shx rm -rf dist/test && node ./.scripts/publish", "local": "ts-node ./.scripts/local.ts",