Skip to content

Commit

Permalink
Merge branch 'main' into topic/UpdateOpenAIDescriptpr
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh authored Jul 25, 2024
2 parents 6a79e58 + 318340c commit d3922d9
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 23 deletions.
33 changes: 33 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Add 'Documentation' label to any changes within 'docs' folder or any subfolders
documentation:
- changed-files:
- any-glob-to-any-file: docs/**

# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
build-action:
- changed-files:
- any-glob-to-any-file: ['build/**', '.github/workflows/**']
- head-branch: ['^build', 'build']

enhancement:
- changed-files:
- any-glob-to-any-file: ['src/**']

enhancement-classic:
- changed-files:
- any-glob-to-any-file: ['src/MigrationTools/_EngineV1/**', 'src/VstsSyncMigrator*/**']

enhancement-modern:
- changed-files:
- any-glob-to-any-file: ['src/**']
- all-globs-to-all-files: ['!src/MigrationTools/_EngineV1/**', '!src/VstsSyncMigrator*/**']

# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
feature:
- head-branch: ['^feature', 'feature', '^topic', 'topic']

# Add 'bug' label to any PR
bug:
- head-branch: ['^fix', 'fix','^bug', 'bug']


6 changes: 3 additions & 3 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ changelog:
- '*'
exclude:
labels:
- dependencies
- title: 👒 Dependencies
- architecture
- title: 👒 Architecture Improvements
labels:
- dependencies
- architecture
2 changes: 1 addition & 1 deletion .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Review
name: OpenAI - Code Review

permissions:
contents: read
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Pull Request Labeler"
on:
- pull_request_target

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
sync-labels: true
23 changes: 22 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
HasChanged_docs: ${{ steps.filter.outputs.docs }}
HasChanged_automation: ${{ steps.filter.outputs.automation }}
nkdAgility_Ring: ${{ steps.nkdagility.outputs.Ring }}
nkdAgility_WingetApplicationId: ${{ steps.nkdagility.outputs.WingetApplicationId }}
nkdAgility_IsBuildEditBranch: ${{ steps.nkdagility.outputs.IsBuildEditBranch }}
steps:
- name: Checkout
Expand Down Expand Up @@ -71,19 +72,25 @@ jobs:
id: nkdagility
run: |
$Ring = "Canary"
$WingetApplicationId = "nkdagility.azure-devops-migration-tools"
switch ($Env:GitVersion_PreReleaseLabel) {
"" {
$Ring = "Release";
$WingetApplicationId = "nkdagility.azure-devops-migration-tools";
}
"Preview" {
$Ring = "Preview";
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Preview";
}
default {
$Ring = "Canary";
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Canary";
}
}
Write-Output "We are running for the $Ring Ring!"
echo "Ring=$Ring" >> $env:GITHUB_OUTPUT
Write-Output "We are focused on Winget ID $WingetApplicationId!"
echo "Ring=$Ring" >> $env:GITHUB_OUTPUT
echo "WingetApplicationId=$WingetApplicationId" >> $env:GITHUB_OUTPUT
$IsBuildEditBranch = $false;
if (("${{ github.ref_name }}").contains("build/")) {
Expand All @@ -108,6 +115,7 @@ jobs:
### NKDAgility
- nkdAgility_Ring: ${{needs.Setup.outputs.nkdAgility_Ring}}
- nkdAgility_IsBuildEditBranch: ${{needs.Setup.outputs.nkdAgility_IsBuildEditBranch}}
- nkdAgility_WingetApplicationId: ${{needs.Setup.outputs.nkdAgility_WingetApplicationId}}
### GitVersion
- GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}}
- GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}}
Expand Down Expand Up @@ -271,6 +279,7 @@ jobs:
if ($Env:nkdAgility_Ring -ne 'Canary' && ($Env:HasChanged_src || $Env:HasChanged_docs )) {
echo "discussion_category_name=Anouncement" >> $env:GITHUB_OUTPUT
}
- name: Release
uses: softprops/action-gh-release@v2
with:
Expand All @@ -285,6 +294,18 @@ jobs:
prerelease: ${{ needs.Setup.outputs.nkdAgility_Ring != 'Release' }}
discussion_category_name: ${{ steps.release-options.outputs.discussion_category_name }}
draft: ${{ needs.Setup.outputs.nkdAgility_Ring == 'Canary' }}
body: |
## Azure DevOps Migration Tools v${{ needs.Setup.outputs.GitVersion_SemVer }}
Version: ${{ needs.Setup.outputs.GitVersion_SemVer }}
Ring: (${{ needs.Setup.outputs.nkdAgility_Ring }})
## Get the tools
- Download the [MigrationTools-${{ needs.Setup.outputs.GitVersion_SemVer }}.zip](https://github.com/nkdAgility/azure-devops-migration-tools/releases/download/v${{ needs.Setup.outputs.GitVersion_SemVer }}/MigrationTools-${{ needs.Setup.outputs.GitVersion_SemVer }}.zip) file below
- Install with Winget with `winget install ${{needs.Setup.outputs.nkdAgility_WingetApplicationId}} --version ${{ needs.Setup.outputs.GitVersion_SemVer }}` . There is a delay for aprovals on the winget store, so you may need to wait a few days before this is available.
- Install with Chocolatey with `choco install nkdagility.azure-devops-migration-tools --version ${{ needs.Setup.outputs.GitVersion_NuGetVersion }}`. There is a delay for aprovals on the chocolatey store, so you may need to wait a few hours before this is available.
append_body: true

# ElmahDeployment
ElmahDeployemnt:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/open-pr-describer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: OpenAI PR Description Generator
name: "OpenAI - PR Description Generator"

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/opencommit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'OpenCommit AI'
name: 'OpenAI - OpenCommit AI'

permissions:
contents: write
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Client;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;
Expand Down Expand Up @@ -155,6 +156,13 @@ private TfsTeamProjectCollection GetDependantTfsCollection(NetworkCredential cre
Log.Information("Access granted to {CollectionUrl} for {Name} ({Account})", TfsConfig.Collection, y.AuthorizedIdentity.DisplayName, y.AuthorizedIdentity.UniqueName);
_Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", TfsConfig.Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "200", true));
}
catch (TeamFoundationServerUnauthorizedException ex)
{
timer.Stop();
_Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", TfsConfig.Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "401", false));
Log.Error(ex, "Unable to configure store: Check persmissions and credentials for {AuthenticationMode}!", _config.AuthenticationMode);
Environment.Exit(-1);
}
catch (Exception ex)
{
timer.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public override WorkItemData GetWorkItem(int id)
}
var startTime = DateTime.UtcNow;
var timer = System.Diagnostics.Stopwatch.StartNew();
WorkItem y;
WorkItem y = null ;
try
{
Log.Debug("TfsWorkItemMigrationClient::GetWorkItem({id})", id);
Expand All @@ -167,13 +167,15 @@ public override WorkItemData GetWorkItem(int id)
{
Telemetry.TrackException(ex,
new Dictionary<string, string> {
{ "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() }
{ "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() },
{ "Project", MigrationClient.Config.AsTeamProjectConfig().Project.ToString() },
{ "WorkItem", id.ToString() }
},
new Dictionary<string, double> {
{ "Time",timer.ElapsedMilliseconds }
});
Log.Error(ex, "Unable to GetWorkItem with id[{id}]", id);
throw;
Environment.Exit(-1);
} finally
{
timer.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ private IList<WorkItem> GetWorkItemsFromQuery(TfsWorkItemMigrationClient wiClien
timer.Stop();
Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItemsFromQuery", null, startTime, timer.Elapsed, "200", true));
}
catch (ValidationException ex)
{
timer.Stop();
Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItemsFromQuery", null, startTime, timer.Elapsed, "500", false));
Log.Error(ex, " Error running query");
Environment.Exit(-1);
}
catch (Exception ex)
{
timer.Stop();
Expand Down
37 changes: 29 additions & 8 deletions src/MigrationTools/Services/TelemetryClientAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Security.Principal;
using System.Text.RegularExpressions;
using Elmah.Io.Client;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
Expand All @@ -19,7 +22,7 @@ public TelemetryClientAdapter(TelemetryClient telemetryClient)
telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
if (!(System.Reflection.Assembly.GetEntryAssembly() is null))
{
telemetryClient.Context.Component.Version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
telemetryClient.Context.Component.Version = GetRunningVersion().versionString;
}
_telemetryClient = telemetryClient;

Expand All @@ -28,7 +31,7 @@ public TelemetryClientAdapter(TelemetryClient telemetryClient)
Timeout = TimeSpan.FromSeconds(30),
UserAgent = "Azure-DevOps-Migration-Tools",
});
elmahIoClient.Messages.OnMessage += (sender, args) => args.Message.Version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
elmahIoClient.Messages.OnMessage += (sender, args) => args.Message.Version = GetRunningVersion().versionString;

}

Expand Down Expand Up @@ -84,18 +87,27 @@ public void TrackException(Exception ex, IDictionary<string, string> properties,
Application = "Azure-DevOps-Migration-Tools",
ServerVariables = new List<Item>
{
new Item("User-Agent", $"X-ELMAHIO-APPLICATION; OS={Environment.OSVersion.Platform}; OSVERSION={Environment.OSVersion.Version}; ENGINE=Azure-DevOps-Migration-Tools"),
new Item("User-Agent", $"X-ELMAHIO-APPLICATION; OS={Environment.OSVersion.Platform}; OSVERSION={Environment.OSVersion.Version}; ENGINEVERSION={GetRunningVersion().versionString}; ENGINE=Azure-DevOps-Migration-Tools"),
}
};
foreach (var property in properties)
createMessage.Data.Add(new Item("SessionId", SessionId));
createMessage.Data.Add(new Item("Version", GetRunningVersion().versionString));

if (properties != null)
{
createMessage.Data.Add(new Item(property.Key, property.Value));
foreach (var property in properties)
{
createMessage.Data.Add(new Item(property.Key, property.Value));
}

}
foreach (var measurement in measurements)
if (measurements != null)
{
createMessage.Data.Add(new Item(measurement.Key, measurement.Value.ToString()));
foreach (var measurement in measurements)
{
createMessage.Data.Add(new Item(measurement.Key, measurement.Value.ToString()));
}
}

var result = elmahIoClient.Messages.CreateAndNotify(new Guid("24086b6d-4f58-47f4-8ac7-68d8bc05ca9e"), createMessage);
Console.WriteLine($"Error logged to Elmah.io");
}
Expand All @@ -104,5 +116,14 @@ public void TrackRequest(string name, DateTimeOffset startTime, TimeSpan duratio
{
_telemetryClient.TrackRequest(name, startTime, duration, responseCode, success);
}

public static (Version version, string PreReleaseLabel, string versionString) GetRunningVersion()
{
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()?.Location);
var matches = Regex.Matches(myFileVersionInfo.ProductVersion, @"^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<build>0|[1-9]\d*)(?:-((?<label>:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<fullEnd>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$");
Version version = new Version(myFileVersionInfo.FileVersion);
string textVersion = version.Major + "." + version.Minor + "." + version.Build + "-" + matches[0].Groups[1].Value;
return (version, matches[0].Groups[1].Value, textVersion);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using MigrationTools.DataContracts.Pipelines;
using MigrationTools.Enrichers;
using VstsSyncMigrator.Engine.ComponentContext;
using Environment = System.Environment;

namespace VstsSyncMigrator.Engine
{
Expand Down Expand Up @@ -633,6 +634,11 @@ private ITestPlan FindTestPlan(string planName, int sourcePlanId)
//Get Target ReflectedWorkItemId
var targetWI = Engine.Target.WorkItems.GetWorkItem(testPlan.Id.ToString());
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan::TargetWorkItem[{workItemId]", targetWI.Id);
if (!targetWI.Fields.ContainsKey(Engine.Target.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName))
{
Log.LogError("TestPlansAndSuitesMigrationContext::FindTestPlan::TargetWorkItem[{workItemId} does not have ReflectedWorkItemId field {ReflectedWorkItemIDFieldName}", targetWI.Id, Engine.Target.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName);
Environment.Exit(-1);
}
string workItemReflectedId = (string)targetWI.Fields[Engine.Target.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName].Value;
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan::TargetWorkItem[{workItemId] [{ReflectedWorkItemId]", targetWI.Id, workItemReflectedId);
//Compaire
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,16 @@ private void ValidateAllNodesExistOrAreMapped(List<WorkItemData> sourceWorkItems
contextLog.Information("Validating::Check that all Area & Iteration paths from Source have a valid mapping on Target");
if (!_nodeStructureEnricher.Options.Enabled && Engine.Target.Config.AsTeamProjectConfig().Project != Engine.Source.Config.AsTeamProjectConfig().Project)
{
throw new ConfigException("Source and Target projects have different names, but NodeStructureEnricher is not enabled. Cant continue... please enable nodeStructureEnricher in the config and restart.");
Log.LogError("Source and Target projects have different names, but NodeStructureEnricher is not enabled. Cant continue... please enable nodeStructureEnricher in the config and restart.");
Environment.Exit(-1);
}
if ( _nodeStructureEnricher.Options.Enabled)
{
List<NodeStructureItem> nodeStructureMissingItems = _nodeStructureEnricher.GetMissingRevisionNodes(sourceWorkItems);
if (_nodeStructureEnricher.ValidateTargetNodesExist(nodeStructureMissingItems))
{
throw new Exception("Missing Iterations in Target preventing progress, check log for list. To continue you MUST configure IterationMaps or AreaMaps that matches the missing paths..");
Log.LogError("Missing Iterations in Target preventing progress, check log for list. To continue you MUST configure IterationMaps or AreaMaps that matches the missing paths..");
Environment.Exit(-1);
}
} else
{
Expand All @@ -330,7 +332,7 @@ private void ValidateAllWorkItemTypesHaveReflectedWorkItemIdField(List<WorkItemD
var ex = new InvalidFieldValueException(
"Not all work items in scope contain a valid ReflectedWorkItemId Field!");
Log.LogError(ex, "Not all work items in scope contain a valid ReflectedWorkItemId Field!");
throw ex;
Environment.Exit(-1);
}
}

Expand Down Expand Up @@ -370,7 +372,7 @@ private void ValiddateWorkItemTypesExistInTarget(List<WorkItemData> sourceWorkIt
var ex = new Exception(
"Not all WorkItemTypes present in the Source are present in the Target or mapped! Filter them from the query, or map the to target types.");
Log.LogError(ex, "Not all WorkItemTypes present in the Source are present in the Target or mapped using `WorkItemTypeDefinition` in the config.");
throw ex;
Environment.Exit(-1);
}
}
}
Expand All @@ -385,7 +387,7 @@ private void ValidatePatTokenRequirement()
{
var ex = new InvalidOperationException("Missing PersonalAccessToken from Target");
Log.LogError(ex, "When you are migrating to Azure DevOps you MUST provide an PAT so that we can call the REST API for certain actions. For example we would be unable to deal with a Work item Type change.");
throw ex;
Environment.Exit(-1);
}
}
}
Expand Down

0 comments on commit d3922d9

Please sign in to comment.