Skip to content

Commit

Permalink
Merge branch 'releases/3.x' into users/egor-bryzgalov/set-resource-pa…
Browse files Browse the repository at this point in the history
…th-update
  • Loading branch information
egor-bryzgalov authored Oct 5, 2020
2 parents ad533f0 + 6f0ebf9 commit 1a628db
Show file tree
Hide file tree
Showing 53 changed files with 425 additions and 4,469 deletions.
39 changes: 11 additions & 28 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ jobs:
command: install
workingDir: node

# use node 5
- powershell: |
& "$(build.sourcesDirectory)/res/UseNode5.ps1"
displayName: (azure-pipelines-task-lib) use node 5.10.1
# use node 14
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 14.11.0
inputs:
versionSpec: "14.11.0"

# build/test
- script: |
Expand All @@ -35,12 +36,6 @@ jobs:
workingDirectory: node
displayName: (azure-pipelines-task-lib) node make.js test
# use node 6
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 6.10.3
inputs:
versionSpec: "6.10.3"

# build/test
- script: |
chcp 437
Expand Down Expand Up @@ -83,23 +78,17 @@ jobs:
command: install
workingDir: node

# use node 5
# use node 14
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 5.10.1
displayName: (azure-pipelines-task-lib) use node 14.11.0
inputs:
versionSpec: "5.10.1"
versionSpec: "14.11.0"

# build/test
- script: node make.js test
workingDirectory: node
displayName: (azure-pipelines-task-lib) node make.js test

# use node 6
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 6.10.3
inputs:
versionSpec: "6.10.3"

# build/test
- script: node make.js test
displayName: (azure-pipelines-task-lib) node make.js test
Expand All @@ -124,23 +113,17 @@ jobs:
command: install
workingDir: node

# use node 5
# use node 14
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 5.10.1
displayName: (azure-pipelines-task-lib) use node 14.11.0
inputs:
versionSpec: "5.10.1"
versionSpec: "14.11.0"

# build/test
- script: node make.js test
workingDirectory: node
displayName: (azure-pipelines-task-lib) node make.js test

# use node 6
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 6.10.3
inputs:
versionSpec: "6.10.3"

# build/test
- script: node make.js test
displayName: (azure-pipelines-task-lib) node make.js test
Expand Down
16 changes: 14 additions & 2 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,31 @@ Cross platform tasks are written in TypeScript. It is the preferred way to writ

[![NPM version][npm-lib-image]][npm-lib-url]

Step by Step: [Create Task](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=vsts)
Step by Step: [Create Task](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=vsts)

Documentation: [TypeScript API](docs/azure-pipelines-task-lib.md), [task JSON schema](https://aka.ms/vsts-tasks.schema.json)

Guidance: [Finding Files](docs/findingfiles.md), [Minimum agent version](docs/minagent.md), [Proxy](docs/proxy.md), [Certificate](docs/cert.md)

## Node 14 Upgrade Notice

Azure DevOps is currently working to establish Node 14 as the new preferred runtime for tasks, upgrading from Node 6.
Relevant work is happening in the releases/3.x branch and will be merged into master when we have successfully migrated the majority of our first party tasks.
Any changes should be dual-commited to both `master` and `releases/3.x` until the merge into master occurs.

### Upgrading to Node 14

Upgrading your tasks from Node 6 should be relatively painless, however there are some things to note:
* Typescript has been upgraded to TS 4. Older versions of TS may or may not work with Node 14 or the 3.x branch. We recommend upgrading to TS 4 when upgrading to task-lib 3.x.
* Node has made some changes to `fs` between Node 6 and Node 14. It is worth reviewing and testing your tasks thoroughly before publishing updates to Node 14.

## Reference Examples

The [ShellScript Task](https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks/ShellScriptV2) and the [XCode Task](https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks/XcodeV5) are good examples.

## Contributing

We are accepting contributions and we try to stay on top of issues.
We are accepting contributions and we try to stay on top of issues.

[Contribution Guide](../CONTRIBUTING.md).

Expand Down
2 changes: 1 addition & 1 deletion node/buildutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.getExternals = function () {
// download the same version of node used by the agent
// and add node to the PATH
var nodeUrl = 'https://nodejs.org/dist';
var nodeVersion = 'v6.17.1';
var nodeVersion = 'v14.11.0';
switch (platform) {
case 'darwin':
var nodeArchivePath = downloadArchive(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-darwin-x64.tar.gz');
Expand Down
8 changes: 0 additions & 8 deletions node/dependencies/typings.json

This file was deleted.

2 changes: 0 additions & 2 deletions node/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/// <reference path="typings/index.d.ts" />

import trm = require('./task');
21 changes: 11 additions & 10 deletions node/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export var _vault: vm.Vault;

// async await needs generators in node 4.x+
if (semver.lt(process.versions.node, '4.2.0')) {
this.warning('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later');
_warning('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later');
}

//-----------------------------------------------------
Expand Down Expand Up @@ -140,7 +140,7 @@ function _loadLocStrings(resourceFile: string, culture: string): { [key: string]
/**
* Sets the location of the resources json. This is typically the task.json file.
* Call once at the beginning of the script before any calls to loc.
*
*
* @param path Full path to the json.
* @param ignoreWarnings Won't throw warnings if path already set.
* @returns void
Expand Down Expand Up @@ -177,7 +177,7 @@ export function _setResourcePath(path: string, ignoreWarnings: boolean = false):

/**
* Gets the localized string from the json resource file. Optionally formats with additional params.
*
*
* @param key key of the resources string in the resource file
* @param param additional params for formatting the string
* @returns string
Expand Down Expand Up @@ -224,7 +224,7 @@ export function _loc(key: string, ...param: any[]): string {

/**
* Gets a variable value that is defined on the build/release definition or set at runtime.
*
*
* @param name name of the variable to get
* @returns string
*/
Expand Down Expand Up @@ -301,9 +301,9 @@ export function _debug(message: string): void {

/**
* Returns whether a path exists.
*
*
* @param path path to check
* @returns boolean
* @returns boolean
*/
export function _exist(path: string): boolean {
var exist = false;
Expand All @@ -322,7 +322,7 @@ export function _exist(path: string): boolean {
/**
* Checks whether a path exists.
* If the path does not exist, it will throw.
*
*
* @param p path to check
* @param name name only used in error message to identify the path
* @returns void
Expand All @@ -337,7 +337,7 @@ export function _checkPath(p: string, name: string): void {
/**
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
* If you check and the tool does not exist, it will throw.
*
*
* @param tool name of the tool
* @param check whether to check if tool exists
* @returns string
Expand Down Expand Up @@ -723,10 +723,11 @@ export function _loadData(): void {
}

// store the secret
if (process.env[envvar]) {
var value = process.env[envvar];
if (value) {
++loaded;
_debug('loading ' + envvar);
_vault.storeSecret(envvar, process.env[envvar]);
_vault.storeSecret(envvar, value);
delete process.env[envvar];
}
}
Expand Down
3 changes: 1 addition & 2 deletions node/make.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

require('shelljs/make');
var fs = require('fs');
var path = require('path');
Expand Down Expand Up @@ -28,7 +27,6 @@ target.build = function() {
target.loc();

run('tsc --outDir ' + buildPath);
cp(rp('dependencies/typings.json'), buildPath);
cp(rp('package.json'), buildPath);
cp(rp('package-lock.json'), buildPath);
cp(rp('README.md'), buildPath);
Expand All @@ -48,6 +46,7 @@ target.test = function() {
cp('-Rf', rp('test/scripts'), testPath);
cp('-Rf', rp('test/fakeTasks'), testPath);
process.env['TASKLIB_INPROC_UNITS'] = '1'; // export task-lib internals for internal unit testing
set('+e'); // Don't throw an exception when tests fail
run('mocha ' + testPath);
}

Expand Down
2 changes: 0 additions & 2 deletions node/mock-answer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as path from 'path';
import * as fs from 'fs';
import * as task from './task';

export interface TaskLibAnswerExecResult {
Expand Down
1 change: 0 additions & 1 deletion node/mock-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import ma = require('./mock-answer');
import mockery = require('mockery');
import im = require('./internal');


export class TaskMockRunner {
constructor(taskPath: string) {
this._taskPath = taskPath;
Expand Down
4 changes: 4 additions & 0 deletions node/mock-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ export class FsStats implements fs.Stats {
mtime: Date = new Date();
ctime: Date = new Date();
birthtime: Date = new Date();
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
birthtimeMs: number;

setAnswers(mockResponses: any): void {
this.m_isFile = mockResponses['isFile'] || this.m_isFile;
Expand Down
4 changes: 2 additions & 2 deletions node/mock-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import os = require('os');
import path = require('path');
import cmdm = require('./taskcommand');
import shelljs = require('shelljs');
import syncRequest = require('sync-request');
import syncRequest from 'sync-request';

const COMMAND_TAG = '[command]';
const COMMAND_LENGTH = COMMAND_TAG.length;
const downloadDirectory = path.join(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, 'azure-pipelines-task-lib', '_download');
const downloadDirectory = path.join(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE as string, 'azure-pipelines-task-lib', '_download');

export class MockTestRunner {
constructor(testPath: string, taskJsonPath?: string) {
Expand Down
4 changes: 2 additions & 2 deletions node/mock-toolrunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface IExecOptions extends IExecSyncOptions {

export interface IExecSyncOptions {
cwd?: string;
env?: { [key: string]: string };
env?: { [key: string]: string | undefined };
silent?: boolean;
outStream: NodeJS.WritableStream;
errStream: NodeJS.WritableStream;
Expand Down Expand Up @@ -152,7 +152,7 @@ export class ToolRunner extends events.EventEmitter {
this._debug('tempPath=' + process.env['MOCK_TEMP_PATH']);
if (process.env['MOCK_IGNORE_TEMP_PATH'] === 'true') {
// Using split/join to replace the temp path
cmdString = cmdString.split(process.env['MOCK_TEMP_PATH']).join('');
cmdString = cmdString.split(process.env['MOCK_TEMP_PATH'] || "").join('');
}

return cmdString;
Expand Down
Loading

0 comments on commit 1a628db

Please sign in to comment.