Skip to content

Node execution engine and build tooling #1139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,18 @@ site/
# Visual Studio Code
####################

.vscode
.vscode

###################
# VSTS Task
###################
src/GitVersionTfsTask/Tests/**/*.js
src/GitVersionTfsTask/Tests/**/*.js.map
src/GitVersionTfsTask/Tests/**/*.d.ts
src/GitVersionTfsTask/Tasks/**/*.js
src/GitVersionTfsTask/Tasks/**/*.js.map
src/GitVersionTfsTask/Tasks/**/*.d.ts
src/GitVersionTfsTask/Tasks/*/common/**/*.*

src/GitVersionTfsTask/.BuildOutput
src/GitVersionTfsTask/**/node_modules
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ configuration:
build_script:
- cmd: nuget restore src/GitVersion.sln
- cmd: npm i -g tfx-cli
- cmd: npm i -g typescript

- cmd: msbuild src/GitVersion.sln "/p:Configuration=%CONFIGURATION%;Platform=%PLATFORM%"
- ps: .\build\NuGetCommandLineBuild\tools\GitVersion.exe /l console /output buildserver /updateAssemblyInfo
Expand Down
24 changes: 24 additions & 0 deletions src/GitVersionTfsTask/Configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"environments": [
{
"Name": "production",
"VssExtensionIdSuffix": "",
"VssExtensionGalleryFlags": [
"Public"
],
"DisplayNamesSuffix": "",
"TaskIds": {
"GitVersion" : "e5983830-3f75-11e5-82ed-81492570a08e"
}
},
{
"Name": "dev",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a requirement, I would prefer prerelease or something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can change it or remove it.

"VssExtensionIdSuffix": "-dev",
"VssExtensionGalleryFlags": [],
"DisplayNamesSuffix": " (Development)",
"TaskIds": {
"GitVersion" : "f402bc4f-87b9-402a-a018-33aa296c2681"
}
}
]
}
5 changes: 4 additions & 1 deletion src/GitVersionTfsTask/Create-Vsix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ param (
Push-Location $taskFolder
Try
{
& tfx extension create --manifest-globs manifest.json
& npm install
& npm run clean
& npm run build
& npm run package -- --version "$Env:GitVersion_SemVer" --noversiontransform
}
Finally
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"manifestVersion": 1,
"id": "gitversion",
"id": "gl-gitversion",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll revert it when it's ready, meanwhile it allows me to publish a prerelease version of it without any conflicts :)

"name": "GitVersion",
"publisher": "gittools",
"public": true,
"publisher": "geeklearningio",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one

"author": "GitVersion Contributors",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove public?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our tooling allows you to build different version of the same extension. In order to do that we use the extension flags instead and they are configured in configuration.json.

"version": "$version$",
"description": "Build task for easy semantic versioning for projects using Git.",
Expand All @@ -14,7 +13,7 @@
],
"files": [
{
"path": "GitVersionTask"
"path": "Tasks"
}
],
"categories": [
Expand Down Expand Up @@ -46,27 +45,15 @@
},
"screenshots": [
{
"path": "img/builds.png"
"path": "builds.png"
},
{
"path": "img/build-task.png"
"path": "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"
}
}
]
}
}
Binary file not shown.
Binary file not shown.
79 changes: 79 additions & 0 deletions src/GitVersionTfsTask/Tasks/GitVersion/GitVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import tl = require('vsts-task-lib/task');
import { IExecOptions, ToolRunner } from 'vsts-task-lib/toolrunner';
import path = require('path');
import q = require('q');
import os = require('os');

var updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo');
var updateAssemblyInfoFilename = tl.getInput('updateAssemblyInfoFilename');
var additionalArguments = tl.getInput('additionalArguments');
var gitVersionPath = tl.getInput('gitVersionPath');
var preferBundledVersion = tl.getBoolInput('preferBundledVersion');

var currentDirectory = __dirname;

var sourcesDirectory = tl.getVariable("Build.SourcesDirectory")

if (!gitVersionPath) {
gitVersionPath = tl.which("GitVersion.exe");
if (preferBundledVersion || !gitVersionPath) {
gitVersionPath = path.join(currentDirectory, "GitVersion.exe");
}
}

(async function execute() {
try {

var execOptions: IExecOptions = {
cwd: undefined,
env: undefined,
silent: undefined,
failOnStdErr: undefined,
ignoreReturnCode: undefined,
errStream: undefined,
outStream: undefined
};

var toolRunner: ToolRunner;

var isWin32 = os.platform() == "win32";

if (isWin32) {
toolRunner = tl.tool(gitVersionPath);
} else {
toolRunner = tl.tool("mono");
toolRunner.arg(gitVersionPath);
}

toolRunner.arg([
sourcesDirectory,
"/output",
"buildserver",
"/nofetch"
]);

if (updateAssemblyInfo) {
toolRunner.arg("/updateassemblyinfo")
if (updateAssemblyInfoFilename) {
toolRunner.arg(updateAssemblyInfoFilename);
} else {
toolRunner.arg("true");
}
}

if (additionalArguments) {
toolRunner.line(additionalArguments);
}

var result = await toolRunner.exec(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);
}
})();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions src/GitVersionTfsTask/Tasks/GitVersion/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "gitversion",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"vsts-task-lib": "0.9.20",
"q" : "1.4.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not native promises?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vsts-task-lib depends on q. I guess this is related to the fact that some agents are running older versions of node which won't provide native Promises.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@
"required": false,
"helpMarkDown": "Optionally supply the path to GitVersion.exe",
"groupName": "additional"
},
{
"name": "preferBundledVersion",
"type": "boolean",
"label": "Prefer bundled GiVersion.exe",
"required": false,
"helpMarkDown": "If checked it will prefer the bundled version over a version found in path",
"groupName": "additional"
}
],
"execution": {
"PowerShell": {
"target": "$(currentDirectory)\\GitVersion.ps1",
"Node": {
"target": "GitVersion.js",
"argumentFormat": "",
"workingDirectory": ""
}
Expand Down
24 changes: 24 additions & 0 deletions src/GitVersionTfsTask/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "git-version-tfs-task",
"version": "1.0.0",
"description": "",
"private": true,
"main": "index.js",
"author": "",
"license": "MIT",
"scripts": {
"clean": "vsts-build-tools-clean",
"postinstall": "vsts-build-tools-install",
"prebuild": "vsts-build-tools-prebuild",
"build": "tsc",
"package": "vsts-build-tools-package"
},
"devDependencies": {
"@types/minimatch": "^2.0.29",
"@types/node": "^7.0.5",
"@types/q": "0.0.32",
"async": "^2.0.1",
"gl-vsts-tasks-build-scripts": "0.2.0-alpha.5",
"npm-run-all": "2.3.0"
}
}
25 changes: 25 additions & 0 deletions src/GitVersionTfsTask/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"target": "es6",
"sourceMap": false,
"inlineSourceMap": true,
"declaration": true
},
"filesGlob": [
"./Tasks/*.ts",
"./Tests/*.ts",
"./typings/index.d.ts",
"./Common/Node/*.d.ts"
],
"exclude":[
"node_modules",
"Tasks/GitVersion/node_modules",
"Common",
".BuildOutput"
]
}