Skip to content

Commit

Permalink
Merge pull request #449 from microsoft/staging
Browse files Browse the repository at this point in the history
Release - 9/17/24
  • Loading branch information
EricJohnson327 authored Sep 16, 2024
2 parents 24b786f + 7474c8d commit eafe7a1
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 151 deletions.
22 changes: 21 additions & 1 deletion build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parameters:
- release

variables:
MSIXVersion: '0.1700'
MSIXVersion: '0.1800'
solution: '**/GitHubExtension.sln'
appxPackageDir: 'AppxPackages'
testOutputArtifactDir: 'TestResults'
Expand All @@ -38,6 +38,12 @@ extends:
sdl:
roslyn:
enabled: true
binskim:
break: false
scanOutputDirectoryOnly: true
policheck:
break: false
severity: Note
arrow:
serviceConnection: DevHome Build VM Generation
baseline:
Expand Down Expand Up @@ -145,6 +151,16 @@ extends:
filePath: 'build/scripts/Build.ps1'
arguments: -Platform "${{ platform }}" -Configuration "${{ configuration }}" -Version $(MSIXVersion) -BuildStep "msix" -AzureBuildingBranch "$(BuildingBranch)" -IsAzurePipelineBuild -ClientId $(GitHubClientId) -ClientSecret $(GitHubClientSecret)

- task: PowerShell@2
displayName: Copy Binaries for Artifact Publishing
inputs:
targetType: inline
script: >-
New-Item -Path '$(Build.ArtifactStagingDirectory)\rawBinaries' -ItemType Directory
Get-ChildItem -Path "$(Build.SourcesDirectory)\buildoutput\*" -Include *.dll,*.exe,*.pdb -Recurse | Copy-Item -Destination "$(Build.ArtifactStagingDirectory)\rawBinaries" -verbose
pwsh: true

- template: ./build/templates/EsrpSigning-Steps.yml@self
parameters:
displayName: Submit *.msix to ESRP for code signing
Expand Down Expand Up @@ -267,6 +283,10 @@ extends:
targetPath: $(appxPackageDir)\${{ configuration }}
sbomPackageName: devhomegithubextension.msixpackage
sbomPackageVersion: $(MSIXVersion)
- output: pipelineArtifact
displayName: 'Publish Binaries'
artifactName: binaries_${{ platform }}_${{ configuration }}
targetPath: $(Build.ArtifactStagingDirectory)\rawBinaries

- stage: Build_MsixBundle
dependsOn: Build_Msix
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/CreateBuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Param(
)

$Major = "0"
$Minor = "17"
$Minor = "18"
$Patch = "99" # default to 99 for local builds

$versionSplit = $Version.Split(".");
Expand Down
16 changes: 16 additions & 0 deletions src/GitHubExtension/DataManager/GitHubDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ private async Task UpdateDataStoreAsync(DataStoreOperationParameters parameters,
PruneObsoleteData();
SetLastUpdatedInMetaData();
}
catch (HttpRequestException httpEx)
{
// HttpRequestExceptions can happen when internet connection is
// down or various other network issues.
_log.Warning($"Http Request Exception: {httpEx.Message}");
tx.Rollback();

// Rethrow so clients can catch/display appropriate UX.
throw;
}
catch (Exception ex)
{
_log.Error(ex, $"Failed Updating DataStore for: {parameters}");
Expand Down Expand Up @@ -331,6 +341,12 @@ private async Task UpdateDataForRepositoryAsync(DataStoreOperationParameters par
PruneObsoleteData();
SetLastUpdatedInMetaData();
}
catch (HttpRequestException)
{
// Higher layer will catch and log this. Suppress logging an error for this to keep log clean.
tx.Rollback();
throw;
}
catch (Exception ex)
{
// This is for catching any other unexpected error as well as any we throw.
Expand Down
9 changes: 9 additions & 0 deletions src/GitHubExtension/DataManager/GitHubDataManagerUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public static async Task Update()
{
await UpdateDeveloperPullRequests();
}
catch (HttpRequestException httpEx)
{
// HttpRequestExceptions can happen when internet connection is
// down or various other network issues unrelated to this update.
// This is not an error in the extension or anything we can
// address. Log a warning so it is understood why the update did
// not occur, but otherwise keep the log clean.
_log.Warning($"Http Request Exception: {httpEx.Message}");
}
catch (Exception ex)
{
_log.Error(ex, "Update failed unexpectedly.");
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubIssuesWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public override void LoadContentData()

issuesData.Add("issues", issuesArray);
issuesData.Add("selected_repo", repository?.FullName ?? string.Empty);
issuesData.Add("widgetTitle", WidgetTitle);
issuesData.Add("widgetTitle", GetActualTitle());
issuesData.Add("is_loading_data", DataState == WidgetDataState.Unknown);
issuesData.Add("issues_icon_data", _issuesIconData);

Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubPullsWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void LoadContentData()

pullsData.Add("pulls", pullsArray);
pullsData.Add("selected_repo", repository?.FullName ?? string.Empty);
pullsData.Add("widgetTitle", WidgetTitle);
pullsData.Add("widgetTitle", GetActualTitle());
pullsData.Add("is_loading_data", DataState == WidgetDataState.Unknown);
pullsData.Add("pulls_icon_data", _pullsIconData);

Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubReleasesWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public override void LoadContentData()

releasesData.Add("releases", releasesArray);
releasesData.Add("selected_repo", repository?.FullName ?? string.Empty);
releasesData.Add("widgetTitle", WidgetTitle);
releasesData.Add("widgetTitle", GetActualTitle());
releasesData.Add("is_loading_data", DataState == WidgetDataState.Unknown);
releasesData.Add("releases_icon_data", _releasesIconData);

Expand Down
110 changes: 41 additions & 69 deletions src/GitHubExtension/Widgets/GitHubRepositoryWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Text.Json.Nodes;
using GitHubExtension.Client;
using GitHubExtension.DataManager;
using GitHubExtension.Helpers;
using GitHubExtension.Widgets.Enums;
using Microsoft.Windows.Widgets.Providers;

Expand All @@ -15,6 +14,8 @@ public abstract class GitHubRepositoryWidget : GitHubWidget
{
protected string RepositoryUrl { get; set; } = string.Empty;

private string? _message;

public GitHubRepositoryWidget()
: base()
{
Expand Down Expand Up @@ -66,14 +67,14 @@ public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs)

switch (verb)
{
case WidgetAction.CheckUrl:
HandleCheckUrl(actionInvokedArgs);
break;

case WidgetAction.Save:
UpdateTitle(JsonNode.Parse(actionInvokedArgs.Data));
base.OnActionInvoked(actionInvokedArgs);
CorrectUrl();
if (HandleCheckUrl(actionInvokedArgs))
{
UpdateTitle(JsonNode.Parse(actionInvokedArgs.Data));
base.OnActionInvoked(actionInvokedArgs);
CorrectUrl();
}

break;

default:
Expand Down Expand Up @@ -142,10 +143,11 @@ private void UpdateTitle(JsonNode? dataObj)
}

GetTitleFromDataObject(dataObj);
if (string.IsNullOrEmpty(WidgetTitle))
{
WidgetTitle = GetRepositoryFromUrl(RepositoryUrl).FullName;
}
}

protected string GetActualTitle()
{
return string.IsNullOrEmpty(WidgetTitle) ? GetRepositoryFromUrl(RepositoryUrl).FullName : WidgetTitle;
}

protected override void ResetWidgetInfoFromState()
Expand Down Expand Up @@ -207,7 +209,7 @@ public override void OnCustomizationRequested(WidgetCustomizationRequestedArgs c
base.OnCustomizationRequested(customizationRequestedArgs);
}

private void HandleCheckUrl(WidgetActionInvokedArgs args)
private bool HandleCheckUrl(WidgetActionInvokedArgs args)
{
// Set loading page while we fetch data from GitHub.
Page = WidgetPageState.Loading;
Expand All @@ -223,7 +225,19 @@ private void HandleCheckUrl(WidgetActionInvokedArgs args)
RepositoryUrl = dataObject["url"]?.GetValue<string>() ?? string.Empty;
UpdateTitle(dataObject);

ConfigurationData = data;
var isGoodToSave = true;

try
{
GetRepositoryFromUrl(RepositoryUrl);
ConfigurationData = data;
_message = null;
}
catch (Exception ex)
{
_message = ex.Message;
isGoodToSave = false;
}

var updateRequestOptions = new WidgetUpdateRequestOptions(Id)
{
Expand All @@ -233,71 +247,29 @@ private void HandleCheckUrl(WidgetActionInvokedArgs args)
};

WidgetManager.GetDefault().UpdateWidget(updateRequestOptions);

// Already shown error message while updating above,
// can reset it to null here.
_message = null;
return isGoodToSave;
}

UpdateWidget();

return false;
}

public string GetConfiguration(string dataUrl)
{
var configurationData = new JsonObject
{
{ "submitIcon", IconLoader.GetIconAsBase64("arrow.png") },
{ "widgetTitle", WidgetTitle },
{ "url", dataUrl },
{ "savedRepositoryUrl", SavedConfigurationData },
{ "errorMessage", _message },
};

if (dataUrl == string.Empty)
{
configurationData.Add("hasConfiguration", false);
var repositoryData = new JsonObject
{
{ "url", string.Empty },
};

configurationData.Add("configuration", repositoryData);
configurationData.Add("savedRepositoryUrl", SavedConfigurationData);
configurationData.Add("saveEnabled", false);

return configurationData.ToString();
}
else
{
try
{
var repository = GetRepositoryFromUrl(dataUrl);
var repositoryData = new JsonObject
{
{ "name", repository.FullName },
{ "label", repository.Name },
{ "owner", repository.Owner.Login },
{ "milestone", string.Empty },
{ "project", repository.Description },
{ "url", RepositoryUrl },
{ "query", GetUnescapedIssueQuery() },
};

configurationData.Add("hasConfiguration", true);
configurationData.Add("configuration", repositoryData);
configurationData.Add("savedRepositoryUrl", SavedConfigurationData);
configurationData.Add("saveEnabled", true);
}
catch (Exception ex)
{
Log.Error(ex, $"Failed getting configuration information for input url: {dataUrl}");
configurationData.Add("hasConfiguration", false);

var repositoryData = new JsonObject
{
{ "url", RepositoryUrl },
};

configurationData.Add("errorMessage", ex.Message);
configurationData.Add("configuration", repositoryData);
configurationData.Add("saveEnabled", false);

return configurationData.ToString();
}

return configurationData.ToJsonString();
}
return configurationData.ToJsonString();
}

public override string GetData(WidgetPageState page)
Expand Down
53 changes: 4 additions & 49 deletions src/GitHubExtension/Widgets/GitHubReviewWidget.cs
Original file line number Diff line number Diff line change
@@ -1,70 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Text.Json.Nodes;
using GitHubExtension.DataManager;
using GitHubExtension.Helpers;
using Microsoft.Windows.Widgets.Providers;
using Octokit;

namespace GitHubExtension.Widgets;

internal sealed class GitHubReviewWidget : GitHubUserWidget
{
public GitHubReviewWidget()
: base()
{
// This widget does not allow customization, so this value will not change.
ShowCategory = SearchCategory.PullRequests;
}

public override void RequestContentData()
{
var request = new SearchIssuesRequest($"review-requested:{UserName}");

RequestContentData(request);
}
protected override string DefaultShowCategory => "PullRequests";

protected override string GetTitleIconData()
{
return IconLoader.GetIconAsBase64("pulls.png");
}

// This widget does not have "ShowCategory" as a variable.
// So we override this method to not care about this data.
protected override void ResetWidgetInfoFromState()
{
base.ResetWidgetInfoFromState();
ShowCategory = SearchCategory.PullRequests;
}

// Overriding this method because this widget only cares about the account.
public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs)
public override void RequestContentData()
{
if (actionInvokedArgs.Verb == "Submit")
{
var data = actionInvokedArgs.Data;
var dataObject = JsonNode.Parse(data);

if (dataObject == null)
{
return;
}

DeveloperLoginId = dataObject["account"]?.GetValue<string>() ?? string.Empty;
UpdateTitle(dataObject);

ConfigurationData = data;
var request = new SearchIssuesRequest($"review-requested:{UserName}");

// If we got here during the customization flow, we need to LoadContentData again
// so we can show the loading page rather than stale data.
LoadContentData();
UpdateActivityState();
}
else
{
base.OnActionInvoked(actionInvokedArgs);
}
RequestContentData(request);
}

public override string GetTemplatePath(WidgetPageState page)
Expand Down
Loading

0 comments on commit eafe7a1

Please sign in to comment.