add azure

This commit is contained in:
Artur Stolear
2019-11-14 16:52:29 +02:00
parent 6aff825e8c
commit 26a2a80323
31 changed files with 7958 additions and 15669 deletions

11
.gitignore vendored
View File

@@ -1,3 +1,10 @@
node_modules/
/*.js
*.js
.taskkey
dist/azure/task/
!dist/azure/task/icon.png
!dist/azure/task/task.json
*.vsix

View File

@@ -14,4 +14,4 @@ outputs:
description: 'The time we greeted you'
runs:
using: node12
main: dist/index.js
main: dist/github/index.js

BIN
dist/azure/images/build-task.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
dist/azure/images/builds.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
dist/azure/images/extension-icon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

6
dist/azure/overview.md vendored Normal file
View File

@@ -0,0 +1,6 @@
Versioning when using Git, solved. GitVersion looks at your Git history and works out the [semantic version](http://semver.org) of the commit being built.
It works with most branching strategies but has been designed mainly around GitFlow and GitHubFlow (pull request workflow). The calculated version numbers can then be accessed through variables such as `$(GitVersion.NuGetVersion)` and `$(GitVersion.SemVer)`. It is also very configurable to allow it to work with most release workflows!
![Build Task](https://raw.githubusercontent.com/GitTools/GitVersion/master/src/GitVersionVsixTask/images/build-task.png)
![Builds](https://raw.githubusercontent.com/GitTools/GitVersion/master/src/GitVersionVsixTask/images/builds.png)

BIN
dist/azure/task/icon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

106
dist/azure/task/task.json vendored Normal file
View File

@@ -0,0 +1,106 @@
{
"id": "dd065e3b-6aef-46af-845c-520195836b35",
"name": "UseGitVersion",
"friendlyName": "GitVersion Task$titleSuffix$",
"description": "Easy Semantic Versioning (http://semver.org) for projects using Git",
"author": "GitVersion Contributors",
"helpMarkDown": "See the [documentation](http://gitversion.readthedocs.org/en/latest/) for help",
"category": "Build",
"demands": [],
"version": {
"Major": "5",
"Minor": "1",
"Patch": "2"
},
"minimumAgentVersion": "2.115.0",
"groups": [
{
"name": "gitversionDetails",
"displayName": "GitVersion details",
"isExpanded": true
},
{
"name": "additional",
"displayName": "Additional Options",
"isExpanded": false
}
],
"instanceNameFormat": "GitVersion",
"inputs": [
{
"name": "versionSpec",
"type": "string",
"label": "The version spec",
"defaultValue": "",
"required": true,
"helpMarkDown": "Required version in the form of 5.x or exact version like 5.0.0"
},
{
"name": "includePrerelease",
"type": "boolean",
"label": "Include pre-release versions",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Include pre-release versions when matching a version"
},
{
"name": "targetPath",
"type": "string",
"label": "Working directory path",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optionally supply the path to the working directory",
"groupName": "gitversionDetails"
},
{
"name": "useConfigFile",
"type": "boolean",
"label": "Specify Configuration file",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to use a custom configuration file"
},
{
"name": "configFilePath",
"type": "filePath",
"label": "Configuration file",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optional path to config file (defaults to GitVersion.yml)",
"visibleRule": "useConfigFile = true"
},
{
"name": "updateAssemblyInfo",
"type": "boolean",
"label": "Update AssemblyInfo files",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to update versions in the AssemblyInfo files"
},
{
"name": "updateAssemblyInfoFilename",
"type": "string",
"label": "Update Assembly File",
"defaultValue": "",
"required": false,
"helpMarkDown": "Update versions in specified file",
"visibleRule": "updateAssemblyInfo = true"
},
{
"name": "additionalArguments",
"type": "string",
"label": "Additional GitVersion arguments",
"defaultValue": "",
"required": false,
"helpMarkDown": "Additional arguments to send to GitVersion",
"groupName": "additional"
}
],
"execution": {
"Node": {
"target": "GitVersion.js",
"argumentFormat": "",
"workingDirectory": "."
}
}
}

71
dist/azure/vss-extension.json vendored Normal file
View File

@@ -0,0 +1,71 @@
{
"manifestVersion": 1,
"id": "usegitversion$idSuffix$",
"name": "UseGitVersion$titleSuffix$",
"publisher": "gittools",
"public": true,
"author": "GitVersion Contributors",
"version": "$version$",
"description": "Build task for easy semantic versioning for projects using Git.",
"targets": [{
"id": "Microsoft.VisualStudio.Services"
}],
"files": [
{ "path": "task" }
],
"categories": [
"Azure Pipelines"
],
"galleryFlags": [
"$visibility$"
],
"icons": {
"default": "images/extension-icon.png"
},
"tags": [
"semver",
"git",
"versioning",
"gitflow",
"githubflow"
],
"links": {
"learn": {
"uri": "http://gitversion.readthedocs.org/en/stable"
},
"getstarted": {
"uri": "http://gitversion.readthedocs.org/en/stable/build-server-support/build-server/tfs-build-vnext/#running-inside-tfs"
},
"license": {
"uri": "https://github.com/GitTools/GitVersion/blob/master/LICENSE"
},
"repository": {
"uri": "https://github.com/GitTools/GitVersion"
},
"support": {
"uri": "https://github.com/GitTools/GitVersion/issues"
}
},
"screenshots": [{
"path": "images/builds.png"
},
{
"path": "images/build-task.png"
}
],
"content": {
"details": {
"path": "overview.md"
}
},
"contributions": [{
"id": "gitversion-task",
"type": "ms.vss-distributed-task.task",
"targets": [
"ms.vss-distributed-task.tasks"
],
"properties": {
"name": "GitVersionTask"
}
}]
}

4677
dist/github/index.js vendored Normal file

File diff suppressed because it is too large Load Diff

15476
dist/index.js vendored

File diff suppressed because one or more lines are too long

2520
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,14 +4,18 @@
"description": "Github Action that installs and uses the GitVersion tool",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build-github": "tsc -p src/github",
"build-azure": "tsc -p src/azure && tsc -p src/azure/tests",
"test-azure": "mocha src/azure/tests/test-suite.js",
"package-github": "ncc build src/github/GitVersion.js -o dist/github",
"package-azure": "ncc build src/github/GitVersion.js -o dist/azure/task && tfx extension create --root dist/azure --manifest-globs vss-extension.json --output-path dist/azure"
},
"repository": {
"type": "git",
"url": "git+https://github.com/GitTools/use-gitversion.git"
},
"keywords": [],
"author": "",
"author": "GitTools",
"license": "MIT",
"bugs": {
"url": "https://github.com/GitTools/use-gitversion/issues"
@@ -20,19 +24,26 @@
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/exec": "^1.0.1",
"@actions/github": "^1.1.0",
"@actions/io": "^1.0.1",
"@actions/tool-cache": "^1.1.2",
"azure-pipelines-task-lib": "2.8.0",
"azure-pipelines-tool-lib": "0.12.0",
"semver": "^6.3.0",
"semver-compare": "^1.0.0",
"typed-rest-client": "1.5.0",
"uuid": "^3.3.3"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.7",
"@types/q": "1.5.2",
"@types/semver": "^6.2.0",
"@types/uuid": "^3.4.6",
"typescript": "^3.6.3"
"@zeit/ncc": "^0.20.5",
"copy-node-modules": "^1.1.1",
"mocha": "^6.2.1",
"mocha-xunit-reporter": "^1.1.0",
"tfx-cli": "0.6.3",
"typescript": "^3.7.2"
}
}

View File

@@ -1,8 +1,9 @@
import * as path from 'path';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as httpm from 'typed-rest-client/HttpClient';
import { IProxy } from './Interfaces';
export class ToolInstaller {

127
src/azure/GitVersion.ts Normal file
View File

@@ -0,0 +1,127 @@
import * as path from 'path';
import * as tl from 'azure-pipelines-task-lib/task';
import * as tr from 'azure-pipelines-task-lib/toolrunner';
import { ToolInstaller } from '../ToolInstaller';
import { Proxy as utils } from './Proxy';
export class GitVersionTask {
execOptions: tr.IExecOptions;
versionSpec: string;
includePrerelease: boolean;
targetPath: string;
useConfigFile: boolean;
configFilePath: string;
updateAssemblyInfo: boolean;
updateAssemblyInfoFilename: string;
additionalArguments: string;
sourcesDirectory: string;
constructor() {
this.versionSpec = tl.getInput('versionSpec', true);
this.includePrerelease = tl.getBoolInput('includePrerelease');
this.targetPath = tl.getInput('targetPath');
this.useConfigFile = tl.getBoolInput('useConfigFile');
this.configFilePath = tl.getInput('configFilePath');
this.updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo');
this.updateAssemblyInfoFilename = tl.getInput('updateAssemblyInfoFilename');
this.additionalArguments = tl.getInput('additionalArguments');
this.sourcesDirectory = tl.getVariable('Build.SourcesDirectory').replace(/\\/g, '/');
this.execOptions = {
cwd: undefined,
env: undefined,
silent: undefined,
failOnStdErr: undefined,
ignoreReturnCode: undefined,
errStream: undefined,
outStream: undefined,
windowsVerbatimArguments: undefined
};
}
public async execute() {
try {
let toolPath = await this.installTool(this.versionSpec, this.includePrerelease);
let workingDirectory = this.getWorkingDirectory(this.targetPath);
let exe = tl.tool('dotnet-gitversion');
exe.arg([
workingDirectory,
"/output",
"buildserver",
"/nofetch"]);
if (this.useConfigFile) {
if (tl.filePathSupplied('configFilePath') && tl.exist(this.configFilePath) && tl.stats(this.configFilePath).isFile()) {
exe.arg(["/config", this.configFilePath]);
}
else {
throw new Error('GitVersion configuration file not found at ' + this.configFilePath);
}
}
if (this.updateAssemblyInfo) {
exe.arg("/updateassemblyinfo");
if (tl.filePathSupplied('updateAssemblyInfoFilename') && tl.exist(this.updateAssemblyInfoFilename) && tl.stats(this.updateAssemblyInfoFilename).isFile()) {
exe.arg(this.updateAssemblyInfoFilename);
}
else {
throw new Error('AssemblyInfoFilename file not found at ' + this.updateAssemblyInfoFilename);
}
}
if (this.additionalArguments) {
exe.line(this.additionalArguments);
}
const result = await exe.exec(this.execOptions);
if (result) {
tl.setResult(tl.TaskResult.Failed, "An error occured during GitVersion execution");
} else {
tl.setResult(tl.TaskResult.Succeeded, "GitVersion executed successfully");
}
}
catch (err) {
tl.debug(err.stack);
tl.setResult(tl.TaskResult.Failed, err, true);
}
}
async installTool(version: string, includePrerelease: boolean): Promise<string> {
let installTool = tl.getVariable("INSTALL_TOOL");
if (installTool === null || installTool === undefined || installTool.toUpperCase() == "TRUE") {
return await new ToolInstaller(utils).downloadAndInstall("GitVersion.Tool", version, false, includePrerelease);
}
}
getWorkingDirectory(targetPath: string) {
let workDir;
if (!targetPath) {
workDir = this.sourcesDirectory;
} else {
if (tl.exist(targetPath) && tl.stats(targetPath).isDirectory()) {
workDir = path.join(this.sourcesDirectory, targetPath);
}
else {
throw new Error('Directory not found at ' + targetPath);
}
}
return workDir.replace(/\\/g, '/');
}
}
var task = new GitVersionTask();
task.execute().catch((reason) => tl.setResult(tl.TaskResult.Failed, reason));

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -0,0 +1,106 @@
{
"id": "dd065e3b-6aef-46af-845c-520195836b35",
"name": "UseGitVersion",
"friendlyName": "GitVersion Task (Preview)",
"description": "Easy Semantic Versioning (http://semver.org) for projects using Git",
"author": "GitVersion Contributors",
"helpMarkDown": "See the [documentation](http://gitversion.readthedocs.org/en/latest/) for help",
"category": "Build",
"demands": [],
"version": {
"Major": "5",
"Minor": "1",
"Patch": "3"
},
"minimumAgentVersion": "2.115.0",
"groups": [
{
"name": "gitversionDetails",
"displayName": "GitVersion details",
"isExpanded": true
},
{
"name": "additional",
"displayName": "Additional Options",
"isExpanded": false
}
],
"instanceNameFormat": "GitVersion",
"inputs": [
{
"name": "versionSpec",
"type": "string",
"label": "The version spec",
"defaultValue": "",
"required": true,
"helpMarkDown": "Required version in the form of 5.x or exact version like 5.0.0"
},
{
"name": "includePrerelease",
"type": "boolean",
"label": "Include pre-release versions",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Include pre-release versions when matching a version"
},
{
"name": "targetPath",
"type": "string",
"label": "Working directory path",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optionally supply the path to the working directory",
"groupName": "gitversionDetails"
},
{
"name": "useConfigFile",
"type": "boolean",
"label": "Specify Configuration file",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to use a custom configuration file"
},
{
"name": "configFilePath",
"type": "filePath",
"label": "Configuration file",
"defaultValue": "",
"required": false,
"helpMarkDown": "Optional path to config file (defaults to GitVersion.yml)",
"visibleRule": "useConfigFile = true"
},
{
"name": "updateAssemblyInfo",
"type": "boolean",
"label": "Update AssemblyInfo files",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to update versions in the AssemblyInfo files"
},
{
"name": "updateAssemblyInfoFilename",
"type": "string",
"label": "Update Assembly File",
"defaultValue": "",
"required": false,
"helpMarkDown": "Update versions in specified file",
"visibleRule": "updateAssemblyInfo = true"
},
{
"name": "additionalArguments",
"type": "string",
"label": "Additional GitVersion arguments",
"defaultValue": "",
"required": false,
"helpMarkDown": "Additional arguments to send to GitVersion",
"groupName": "additional"
}
],
"execution": {
"Node": {
"target": "GitVersion.js",
"argumentFormat": "",
"workingDirectory": "."
}
}
}

23
src/azure/Proxy.ts Normal file
View File

@@ -0,0 +1,23 @@
import { createTempDir, executeDotNet } from './ToolLib';
import { findLocalTool, prependPath, cacheDir, isExplicitVersion, evaluateVersions, cleanVersion } from 'azure-pipelines-tool-lib/tool';
import { debug, setVariable, which } from 'azure-pipelines-task-lib/task';
function _which(tool: string, check?: boolean) : Promise<string> {
return Promise.resolve(which(tool, check));
}
import { IProxy } from '../Interfaces';
export const Proxy: IProxy = {
find: findLocalTool,
debug: debug,
exportVariable: setVariable,
addPath: prependPath,
which: _which,
cacheDir: cacheDir,
isExplicitVersion: isExplicitVersion,
evaluateVersions: evaluateVersions,
cleanVersion: cleanVersion,
createTempDir: createTempDir,
executeDotNet: executeDotNet
}

30
src/azure/ToolLib.ts Normal file
View File

@@ -0,0 +1,30 @@
import * as taskLib from 'azure-pipelines-task-lib/task';
export interface IExecSyncResult {
/** standard output */
stdout: string;
/** error output */
stderr: string;
/** return code */
code: number;
/** Error on failure */
error: Error;
}
export async function createTempDir(): Promise<string> {
let tempDir = taskLib.getVariable('Agent.TempDirectory');
return Promise.resolve(tempDir);
}
export async function executeDotNet(args: string[]): Promise<IExecSyncResult> {
let tr = taskLib.tool("dotnet");
tr.arg(args);
var result = tr.execSync();
return {
code: result.code,
stdout: result.stdout,
stderr: result.stderr,
error: result.error
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
src/azure/images/builds.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

6
src/azure/overview.md Normal file
View File

@@ -0,0 +1,6 @@
Versioning when using Git, solved. GitVersion looks at your Git history and works out the [semantic version](http://semver.org) of the commit being built.
It works with most branching strategies but has been designed mainly around GitFlow and GitHubFlow (pull request workflow). The calculated version numbers can then be accessed through variables such as `$(GitVersion.NuGetVersion)` and `$(GitVersion.SemVer)`. It is also very configurable to allow it to work with most release workflows!
![Build Task](https://raw.githubusercontent.com/GitTools/GitVersion/master/src/GitVersionVsixTask/images/build-task.png)
![Builds](https://raw.githubusercontent.com/GitTools/GitVersion/master/src/GitVersionVsixTask/images/builds.png)

View File

@@ -0,0 +1,82 @@
import * as path from 'path';
import * as ma from 'azure-pipelines-task-lib/mock-answer';
import * as tmrm from 'azure-pipelines-task-lib/mock-run';
import * as shared from './test-shared';
let taskDir = path.join(__dirname, '..');
let taskPath = path.join(taskDir, 'GitVersion.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
process.env['BUILD_SOURCESDIRECTORY'] = shared.SharedValues.BUILD_SOURCESDIRECTORY;
process.env["INSTALL_TOOL"] = 'false';
tmr.setInput('versionSpec', process.env[shared.TestEnvVars.versionSpec] || '5.x');
tmr.setInput('includePrerelease', process.env[shared.TestEnvVars.includePrerelease] || 'false');
tmr.setInput('targetPath', process.env[shared.TestEnvVars.targetPath] || '');
tmr.setInput('useConfigFile', process.env[shared.TestEnvVars.useConfigFile] || 'false');
tmr.setInput('configFilePath', process.env[shared.TestEnvVars.configFilePath] || '');
tmr.setInput('updateAssemblyInfo', process.env[shared.TestEnvVars.updateAssemblyInfo] || 'false');
tmr.setInput('updateAssemblyInfoFilename', process.env[shared.TestEnvVars.updateAssemblyInfoFilename] || '');
tmr.setInput('additionalArguments', process.env[shared.TestEnvVars.additionalArguments] || '');
console.log("Inputs have been set");
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"which": { "dotnet-gitversion": "dotnet-gitversion" },
"checkPath": { "dotnet-gitversion": true },
"exec": {},
"exist": {
"src": true,
"customConfig.yml" : true,
"GlobalAssemblyInfo.cs" : true
},
"stats": {
"src" : {
"isDirectory" : true
},
"customConfig.yml" : {
"isFile": true
},
"GlobalAssemblyInfo.cs" : {
"isFile": true
}
}
};
a.exec["dotnet-gitversion " + shared.SharedValues.BUILD_SOURCESDIRECTORY + " /output buildserver /nofetch"] = {
"code": 0,
"stdout": "GitVersion run successfully with defaults",
"stderr": ""
};
a.exec["dotnet-gitversion " + shared.SharedValues.BUILD_SOURCESDIRECTORY + "/src /output buildserver /nofetch"] = {
"code": 0,
"stdout": "GitVersion run successfully with custom targetPath",
"stderr": ""
};
a.exec["dotnet-gitversion " + shared.SharedValues.BUILD_SOURCESDIRECTORY + " /output buildserver /nofetch /config customConfig.yml"] = {
"code": 0,
"stdout": "GitVersion run successfully with custom config",
"stderr": ""
};
a.exec["dotnet-gitversion " + shared.SharedValues.BUILD_SOURCESDIRECTORY + " /output buildserver /nofetch /updateassemblyinfo GlobalAssemblyInfo.cs"] = {
"code": 0,
"stdout": "GitVersion run successfully with custom assembly info",
"stderr": ""
};
var mt = require('azure-pipelines-task-lib/mock-task');
mt.assertAgent = (minimum: string) =>
{
};
tmr.registerMockExport('mt', mt);
tmr.setAnswers(a);
tmr.run();

View File

@@ -0,0 +1,14 @@
export let TestEnvVars = {
versionSpec: "__versionSpec__",
includePrerelease: "__includePrerelease__",
targetPath: "__targetPath__",
useConfigFile: "__useConfigFile__",
configFilePath: "__configFilePath__",
updateAssemblyInfo: "__updateAssemblyInfo__",
updateAssemblyInfoFilename: "__updateAssemblyInfoFilename__",
additionalArguments: "__additionalArguments__"
}
export let SharedValues = {
BUILD_SOURCESDIRECTORY: "/user/build"
}

View File

@@ -0,0 +1,246 @@
import * as path from 'path';
import * as assert from 'assert';
import * as ttm from 'azure-pipelines-task-lib/mock-test';
import * as shared from './test-shared';
function runValidations(validator: () => void, tr: ttm.MockTestRunner, done: MochaDone) {
try {
validator();
console.log(tr.succeeded);
done();
}
catch (error) {
console.log("STDERR", tr.stderr);
console.log("STDOUT", tr.stdout);
done(error);
}
}
describe('GitVersion Vsix Task tests', function () {
beforeEach(() => {
delete process.env[shared.TestEnvVars.useConfigFile];
delete process.env[shared.TestEnvVars.configFilePath];
delete process.env[shared.TestEnvVars.updateAssemblyInfo];
delete process.env[shared.TestEnvVars.updateAssemblyInfoFilename];
delete process.env[shared.TestEnvVars.additionalArguments];
delete process.env[shared.TestEnvVars.targetPath];
});
after(() => {
});
it('Succeeds: Runs GitVersion default configurations', function (done: MochaDone) {
this.timeout(1000);
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.succeeded, 'should have succeeded');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 0, "should have no errors");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 1, 'should have invoked tool one time. actual: ' + tr.invokedToolCount);
assert(tr.ran("dotnet-gitversion /user/build /output buildserver /nofetch"));
assert(tr.stdOutContained('GitVersion run successfully with defaults'), "should display 'GitVersion run successfully with defaults'");
}, tr, done);
});
it('Fails: Runs GitVersion with wrong targetPath', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.targetPath] = 'wrongPath';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.failed, 'should have failed');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 1, "should have thrown an error");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 0, 'should not have invoked tool. actual: ' + tr.invokedToolCount);
assert(tr.stdOutContained('Directory not found'), "should display 'Directory not found'");
}, tr, done);
});
it('Succeeds: Runs GitVersion with correct target', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.targetPath] = 'src';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.succeeded, 'should have succeeded');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 0, "should have no errors");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 1, 'should have invoked tool one time. actual: ' + tr.invokedToolCount);
assert(tr.ran("dotnet-gitversion /user/build/src /output buildserver /nofetch"));
assert(tr.stdOutContained('GitVersion run successfully with custom targetPath'), "should display 'GitVersion run successfully with custom targetPath'");
}, tr, done);
});
it('Fails: Runs GitVersion with no configuration file specified', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.useConfigFile] = 'true';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert.equal(tr.succeeded, false, 'should have failed');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 1, "should have thrown an error");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 0, 'should not have invoked tool. actual: ' + tr.invokedToolCount);
assert(tr.stdOutContained('GitVersion configuration file not found'), "should display 'GitVersion configuration file not found'");
}, tr, done);
});
it('Fails: Runs GitVersion with wrong configuration file specified', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.useConfigFile] = 'true';
process.env[shared.TestEnvVars.configFilePath] = 'wronfConfig.yml';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.failed, 'should have failed');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 1, "should have thrown an error");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 0, 'should not have invoked tool. actual: ' + tr.invokedToolCount);
assert(tr.stdOutContained('GitVersion configuration file not found'), "should display 'GitVersion configuration file not found'");
}, tr, done);
});
it('Succeeds: Runs GitVersion with correct custom configuration file specified', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.useConfigFile] = 'true';
process.env[shared.TestEnvVars.configFilePath] = 'customConfig.yml';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.succeeded, 'should have succeeded');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 0, "should have no error");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 1, 'should have invoked tool one time. actual: ' + tr.invokedToolCount);
assert(tr.ran("dotnet-gitversion /user/build /output buildserver /nofetch /config customConfig.yml"));
assert(tr.stdOutContained('GitVersion run successfully with custom config'), "should display 'GitVersion run successfully with custom config'");
}, tr, done);
});
it('Fails: Runs GitVersion with no assembly info file specified', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.updateAssemblyInfo] = 'true';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.failed, 'should have failed');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 1, "should have thrown an error");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 0, 'should not have invoked tool. actual: ' + tr.invokedToolCount);
assert(tr.stdOutContained('AssemblyInfoFilename file not found'), "should display 'AssemblyInfoFilename file not found'");
}, tr, done);
});
it('Fails: Runs GitVersion with wrong assembly info file specified', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.updateAssemblyInfo] = 'true';
process.env[shared.TestEnvVars.updateAssemblyInfoFilename] = 'wrongAssemblyInfo.cs';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.failed, 'should have failed');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 1, "should have thrown an error");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 0, 'should not have invoked tool. actual: ' + tr.invokedToolCount);
assert(tr.stdOutContained('AssemblyInfoFilename file not found'), "should display 'AssemblyInfoFilename file not found'");
}, tr, done);
});
it('Succeeds: Runs GitVersion with correct custom assembly info file specified', function (done: MochaDone) {
this.timeout(1000);
process.env[shared.TestEnvVars.updateAssemblyInfo] = 'true';
process.env[shared.TestEnvVars.updateAssemblyInfoFilename] = 'GlobalAssemblyInfo.cs';
let tp = path.join(__dirname, 'test-setup.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();
runValidations(() => {
assert(tr.succeeded, 'should have succeeded');
assert(tr.warningIssues.length == 0, "should have no warnings");
assert(tr.errorIssues.length == 0, "should have no errors");
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount == 1, 'should have invoked tool one time. actual: ' + tr.invokedToolCount);
assert(tr.ran("dotnet-gitversion /user/build /output buildserver /nofetch /updateassemblyinfo GlobalAssemblyInfo.cs"));
assert(tr.stdOutContained('GitVersion run successfully with custom assembly info'), "should display 'GitVersion run successfully with custom assembly info'");
}, tr, done);
});
});

View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"target": "es6",
"sourceMap": false,
"inlineSourceMap": true,
"declaration": false
}
}

13
src/azure/tsconfig.json Normal file
View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"target": "es6",
"sourceMap": false,
"inlineSourceMap": true
},
"exclude": ["tests"]
}

View File

@@ -0,0 +1,71 @@
{
"manifestVersion": 1,
"id": "usegitversion-preview",
"name": "UseGitVersion (Preview)",
"publisher": "gittools",
"public": true,
"author": "GitVersion Contributors",
"version": "5.1.3.1911100642",
"description": "Build task for easy semantic versioning for projects using Git.",
"targets": [{
"id": "Microsoft.VisualStudio.Services"
}],
"files": [
{ "path": "GitVersionTask" }
],
"categories": [
"Azure Pipelines"
],
"galleryFlags": [
"Preview"
],
"icons": {
"default": "images/extension-icon.png"
},
"tags": [
"semver",
"git",
"versioning",
"gitflow",
"githubflow"
],
"links": {
"learn": {
"uri": "http://gitversion.readthedocs.org/en/stable"
},
"getstarted": {
"uri": "http://gitversion.readthedocs.org/en/stable/build-server-support/build-server/tfs-build-vnext/#running-inside-tfs"
},
"license": {
"uri": "https://github.com/GitTools/GitVersion/blob/master/LICENSE"
},
"repository": {
"uri": "https://github.com/GitTools/GitVersion"
},
"support": {
"uri": "https://github.com/GitTools/GitVersion/issues"
}
},
"screenshots": [{
"path": "images/builds.png"
},
{
"path": "images/build-task.png"
}
],
"content": {
"details": {
"path": "overview.md"
}
},
"contributions": [{
"id": "gitversion-task",
"type": "ms.vss-distributed-task.task",
"targets": [
"ms.vss-distributed-task.tasks"
],
"properties": {
"name": "GitVersionTask"
}
}]
}

View File

@@ -1,5 +1,4 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import { ToolInstaller } from '../ToolInstaller';
import { Proxy as utils } from './Proxy';
try {
@@ -11,8 +10,6 @@ try {
const time = (new Date()).toTimeString();
core.setOutput("time", time);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);
} catch (error) {
core.setFailed(error.message);
}

View File

@@ -9,5 +9,5 @@
"sourceMap": false,
"inlineSourceMap": true,
"declaration": false
},
}
}