Move testing dependent projects from a script to Azure Devops Pipeline (#357)

* Disable ms-rest-azure-js tests

* Refactor script

* Add debug statement

* Change test command

* Remove command line arguments

* Rename command

* Split the script

* Add directory creation

* Combine jobs

* Refactor script

* Remove workdir

* Add pwd script

* Change variable name

* Split jobs

* Add additional logging

* Add additional logging

* Add ls -a

* Combine jobs

* Add copying artifacts

* Move artifact to a folder

* Move artifact to a folder

* Rename artifact

* Add npm pack

* Add ls -a

* Fix path

* Add predefined variable

* Introduce variables

* Fix missing variable

* Add autorest.typescript testing

* Add ms-rest-azure-js publishing

* Add working directory parameter

* Fix dependent tasks

* Add debug statement

* Flip order of gulp build

* Bump the version

* Update Constants

* Add friendly job names

* Cleanup debug statements
This commit is contained in:
Kamil Pajdzik 2019-06-06 09:35:57 -07:00 коммит произвёл GitHub
Родитель 8c76e217ec
Коммит 4273b5122e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 120 добавлений и 41 удалений

Просмотреть файл

@ -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:
command: custom
verbose: false
customCommand: 'run build'
- task: Npm@1
displayName: 'npm run dep:ms-rest-azure-js'
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: true
customCommand: run dep:ms-rest-azure-js
- task: Npm@1
displayName: 'npm run dep:autorest.typescript'
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:autorest.typescript
artifactName: $(artifactName)
targetPath: $(System.DefaultWorkingDirectory)
- task: DownloadPipelineArtifact@0
inputs:
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'

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -7,7 +7,7 @@ export const Constants = {
* @const
* @type {string}
*/
msRestVersion: "1.8.10",
msRestVersion: "1.8.11",
/**
* Specifies HTTP.

Просмотреть файл

@ -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",