Update to gulp 4 and clean up pipelines (#853)

- Update to gulp 4 to get rid of some npm audit stuff
    - `gulp.task` is [deprecated](https://github.com/gulpjs/gulp/blob/master/docs/getting-started/3-creating-tasks.md), so switch to functions
    - Leverage `ts-node` so that we can use typescript for gulpfile
- Clean up pipelines
    - Use `common/test.yml` for all OS's. I think it's easier to read the steps if they're in the same file. Plus there's less copied code.
    - Always use Node 8. Again - this is just to keep our builds consistent (previously I think macOS was defaulting to Node 6)
This commit is contained in:
Eric Jizba 2018-12-06 11:20:35 -08:00 коммит произвёл GitHub
Родитель 15ecc282df
Коммит e3c2e3c430
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 1608 добавлений и 448 удалений

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

@ -1,5 +0,0 @@
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.6.x'
inputs:
versionSpec: 3.6.x

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

@ -1,4 +1,9 @@
steps:
- task: NodeTool@0
displayName: 'Use Node 8.x'
inputs:
versionSpec: 8.x
- task: Npm@1
displayName: 'npm install'

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

@ -1,7 +0,0 @@
steps:
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '*-results.xml'
testRunTitle: '$(Agent.OS)'
condition: succeededOrFailed()

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

@ -1,13 +1,31 @@
steps:
- template: before-test.yml
- script: |
sudo cp .azure-pipelines/linux/xvfb.init /etc/init.d/xvfb
sudo chmod +x /etc/init.d/xvfb
sudo update-rc.d xvfb defaults
sudo service xvfb start
displayName: 'Start X Virtual Frame Buffer'
condition: eq(variables['Agent.OS'], 'Linux')
- task: Gulp@0
- task: UsePythonVersion@0
displayName: 'Use Python 3.6.x'
inputs:
versionSpec: 3.6.x
- task: Npm@1
displayName: 'Test'
inputs:
targets: 'test'
command: custom
customCommand: test
env:
SERVICE_PRINCIPAL_CLIENT_ID: $(SERVICE_PRINCIPAL_CLIENT_ID)
SERVICE_PRINCIPAL_SECRET: $(SERVICE_PRINCIPAL_SECRET)
SERVICE_PRINCIPAL_DOMAIN: $(SERVICE_PRINCIPAL_DOMAIN)
DISPLAY: :10 # Only necessary for linux tests
- template: publish-test-results.yml
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '*-results.xml'
testRunTitle: '$(Agent.OS)'
condition: succeededOrFailed()

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

@ -1,20 +0,0 @@
steps:
- template: ../common/before-test.yml
- script: |
sudo cp .azure-pipelines/linux/xvfb.init /etc/init.d/xvfb
sudo chmod +x /etc/init.d/xvfb
sudo update-rc.d xvfb defaults
sudo service xvfb start
displayName: 'Start X Virtual Frame Buffer'
- script: |
export DISPLAY=:10
gulp test
displayName: 'Test'
env:
SERVICE_PRINCIPAL_CLIENT_ID: $(SERVICE_PRINCIPAL_CLIENT_ID)
SERVICE_PRINCIPAL_SECRET: $(SERVICE_PRINCIPAL_SECRET)
SERVICE_PRINCIPAL_DOMAIN: $(SERVICE_PRINCIPAL_DOMAIN)
- template: ../common/publish-test-results.yml

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

@ -14,7 +14,7 @@ jobs:
- template: common/build.yml
- template: common/publish-vsix.yml # Only publish vsix from linux build since we use this to release and want to stay consistent
- template: common/lint.yml
- template: linux/test-linux.yml
- template: common/test.yml
- job: macOS
pool:

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

@ -12,3 +12,4 @@ tools/**
.github/**
test-results.xml
.azure-pipelines/**
gulp*

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

@ -3,39 +3,44 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const gulp = require('gulp');
const decompress = require('gulp-decompress');
const download = require('gulp-download');
const path = require('path');
const os = require('os');
const fse = require('fs-extra');
const cp = require('child_process');
const request = require('request');
const chmod = require('gulp-chmod');
const filter = require('gulp-filter');
const glob = require('glob');
// tslint:disable:no-console
// tslint:disable:no-implicit-dependencies (this allows the use of dev dependencies)
gulp.task('test', ['install-azure-account', 'install-func-cli'], (cb) => {
// Grandfathered in
// tslint:disable:typedef
// tslint:disable:no-unsafe-any
import * as cp from 'child_process';
import * as fse from 'fs-extra';
import * as glob from 'glob';
import * as gulp from 'gulp';
import * as chmod from 'gulp-chmod';
import * as decompress from 'gulp-decompress';
import * as download from 'gulp-download';
import * as filter from 'gulp-filter';
import * as os from 'os';
import * as path from 'path';
import * as requestP from 'request-promise';
function test() {
const env = process.env;
env.DEBUGTELEMETRY = 1;
env.MOCHA_timeout = 10 * 1000;
env.DEBUGTELEMETRY = '1';
env.MOCHA_timeout = String(10 * 1000);
env.MOCHA_reporter = 'mocha-junit-reporter';
env.MOCHA_FILE = path.join(__dirname, 'test-results.xml');
const cmd = cp.spawn('node', ['./node_modules/vscode/bin/test'], { stdio: 'inherit', env });
cmd.on('close', (code) => {
cb(code);
});
});
return cp.spawn('node', ['./node_modules/vscode/bin/test'], { stdio: 'inherit', env });
}
/**
* Installs the azure account extension before running tests (otherwise our extension would fail to activate)
* NOTE: The version isn't super important since we don't actually use the account extension in tests
*/
gulp.task('install-azure-account', () => {
function installAzureAccount() {
const version = '0.4.3';
const extensionPath = path.join(os.homedir(), `.vscode/extensions/ms-vscode.azure-account-${version}`);
const existingExtensions = glob.sync(extensionPath.replace(version, '*'));
if (existingExtensions.length === 0) {
// tslint:disable-next-line:no-http-string
return download(`http://ms-vscode.gallery.vsassets.io/_apis/public/gallery/publisher/ms-vscode/extension/azure-account/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`)
.pipe(decompress({
filter: file => file.path.startsWith('extension/'),
@ -47,45 +52,40 @@ gulp.task('install-azure-account', () => {
.pipe(gulp.dest(extensionPath));
} else {
console.log('Azure Account extension already installed.');
}
});
let downloadLink;
gulp.task('get-func-link', (cb) => {
request('https://aka.ms/V00v5v', (error, _response, body) => {
if (error) {
cb(error);
}
const cliFeed = JSON.parse(body);
const version = cliFeed.tags['v2-prerelease'].release;
console.log(`Func cli feed version: ${version}`);
const cliRelease = cliFeed.releases[version].standaloneCli.find((rel) => {
return rel.Architecture === 'x64' && (
matchesCliFeedOS(rel.OperatingSystem) ||
matchesCliFeedOS(rel.OS)
);
});
downloadLink = cliRelease.downloadLink;
console.log(`Func downloadLink: ${downloadLink}`);
cb();
});
});
function matchesCliFeedOS(os) {
switch (process.platform) {
case 'win32':
return os === 'Windows';
case 'darwin':
return os === 'MacOS';
default:
return os === 'Linux';
return Promise.resolve();
}
}
gulp.task('install-func-cli', ['get-func-link'], () => {
let downloadLink;
async function getFuncLink() {
// tslint:disable-next-line:no-any
const body = await <any>requestP('https://aka.ms/V00v5v');
const cliFeed = JSON.parse(body);
const version = cliFeed.tags['v2-prerelease'].release;
console.log(`Func cli feed version: ${version}`);
const cliRelease = cliFeed.releases[version].standaloneCli.find((rel) => {
return rel.Architecture === 'x64' && (
matchesCliFeedOS(rel.OperatingSystem) ||
matchesCliFeedOS(rel.OS)
);
});
downloadLink = cliRelease.downloadLink;
console.log(`Func downloadLink: ${downloadLink}`);
}
function matchesCliFeedOS(platform: string) {
switch (process.platform) {
case 'win32':
return platform === 'Windows';
case 'darwin':
return platform === 'MacOS';
default:
return platform === 'Linux';
}
}
function installFuncCli() {
const funcDir = path.join(os.homedir(), 'tools', 'func');
if (fse.pathExistsSync(funcDir)) {
console.log('Removing old install of func.');
@ -98,5 +98,7 @@ gulp.task('install-func-cli', ['get-func-link'], () => {
.pipe(funcFilter)
.pipe(chmod({ execute: true }))
.pipe(funcFilter.restore)
.pipe(gulp.dest(funcDir))
});
.pipe(gulp.dest(funcDir));
}
exports.test = gulp.series(installAzureAccount, getFuncLink, installFuncCli, test);

1863
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -781,6 +781,9 @@
"devDependencies": {
"@types/clipboardy": "^1.1.0",
"@types/fs-extra": "^4.0.3",
"@types/glob": "^7.1.1",
"@types/gulp": "^4.0.5",
"@types/gulp-filter": "^3.0.33",
"@types/mocha": "^5.2.5",
"@types/node": "^8.0.28",
"@types/opn": "^5.1.0",
@ -793,7 +796,7 @@
"@types/xregexp": "^3.0.29",
"azure-arm-resource": "^3.0.0-preview",
"glob": "^7.1.3",
"gulp": "^3.9.1",
"gulp": "^4.0.0",
"gulp-chmod": "^2.0.0",
"gulp-decompress": "^2.0.1",
"gulp-download": "^0.0.1",
@ -802,6 +805,7 @@
"mocha-junit-reporter": "^1.18.0",
"tslint": "^5.7.0",
"tslint-microsoft-contrib": "5.2.1",
"ts-node": "^7.0.1",
"typescript": "^3.1.3",
"vscode": "^1.0.0",
"vscode-azureextensiondev": "^0.1.1",

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

@ -23,6 +23,7 @@
},
"exclude": [
"node_modules",
".vscode-test"
".vscode-test",
"gulpfile.ts"
]
}