Skip to content

Commit

Permalink
Convert from optional package to app extension for source data (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcPMS authored Apr 30, 2020
1 parent dc48bac commit 9858113
Show file tree
Hide file tree
Showing 29 changed files with 261 additions and 139 deletions.
45 changes: 24 additions & 21 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,29 @@ jobs:
/p:AppxBundle=Always
/p:UapAppxPackageBuildMode=StoreUpload'

- task: PowerShell@2
displayName: Install Tests Dependencies
inputs:
targetType: 'inline'
script: |
Add-AppxPackage AppInstallerCLIPackage_0.0.0.2_Test\Dependencies\x86\Microsoft.VCLibs.x86.14.00.Desktop.appx
Add-AppxPackage AppInstallerCLIPackage_0.0.0.2_Test\Dependencies\x64\Microsoft.VCLibs.x64.14.00.Desktop.appx
workingDirectory: $(appxPackageDir)

- task: VisualStudioTestPlatformInstaller@1
displayName: Prepare VSTest for E2E Tests
inputs:
packageFeedSelector: 'nugetOrg'

# TODO: Convert tests to run based on the whether things have worked up to this point

- task: CmdLine@2
displayName: Run Unit Tests Unpackaged x64
inputs:
script: |
AppInstallerCLITests.exe -logto AICLI-Unpackaged-x64.log -s -r junit -o TEST-AppInstallerCLI-Unpackaged-x64.xml
workingDirectory: 'src\x64\Release\AppInstallerCLITests\'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish Unit Tests Unpackaged Log x64
Expand All @@ -96,20 +113,13 @@ jobs:
publishLocation: 'Container'
condition: succeededOrFailed()

- task: PowerShell@2
displayName: Install Tests Dependencies x64
inputs:
targetType: 'inline'
script: |
Add-AppxPackage AppInstallerCLIPackage_0.0.0.2_Test\Dependencies\x64\Microsoft.VCLibs.x64.14.00.Desktop.appx
workingDirectory: $(appxPackageDir)

- task: PowerShell@2
displayName: Run Unit Tests Packaged x64
inputs:
filePath: 'src\AppInstallerCLITests\Run-TestsInPackage.ps1'
arguments: '-Args "~[pips]" -BuildRoot x64\Release -PackageRoot AppInstallerCLIPackage\bin\x64\Release -LogTarget x64\Release\AICLI-Packaged-x64.log -TestResultsTarget x64\Release\TEST-AppInstallerCLI-Packaged-x64.xml -ScriptWait'
workingDirectory: 'src'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish Unit Tests Packaged Log x64
Expand All @@ -133,6 +143,7 @@ jobs:
script: |
AppInstallerCLITests.exe -logto AICLI-Unpackaged-x86.log -s -r junit -o TEST-AppInstallerCLI-Unpackaged-x86.xml
workingDirectory: 'src\x86\Release\AppInstallerCLITests\'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish Unit Tests Unpackaged Log x86
Expand All @@ -150,20 +161,13 @@ jobs:
publishLocation: 'Container'
condition: succeededOrFailed()

- task: PowerShell@2
displayName: Install Tests Dependencies x86
inputs:
targetType: 'inline'
script: |
Add-AppxPackage AppInstallerCLIPackage_0.0.0.2_Test\Dependencies\x86\Microsoft.VCLibs.x86.14.00.Desktop.appx
workingDirectory: $(appxPackageDir)

- task: PowerShell@2
displayName: Run Unit Tests Packaged x86
inputs:
filePath: 'src\AppInstallerCLITests\Run-TestsInPackage.ps1'
arguments: '-Args "~[pips]" -BuildRoot x86\Release -PackageRoot AppInstallerCLIPackage\bin\x86\Release -LogTarget x86\Release\AICLI-Packaged-x86.log -TestResultsTarget x86\Release\TEST-AppInstallerCLI-Packaged-x86.xml -ScriptWait'
workingDirectory: 'src'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish Unit Tests Packaged Log x86
Expand All @@ -189,11 +193,6 @@ jobs:
failTaskOnFailedTests: true
condition: succeededOrFailed()

- task: VisualStudioTestPlatformInstaller@1
displayName: Prepare VSTest for E2E Tests
inputs:
packageFeedSelector: 'nugetOrg'

- task: VSTest@2
displayName: Run E2E Tests Unpackaged x64
inputs:
Expand All @@ -202,6 +201,7 @@ jobs:
runSettingsFile: 'src\AnyCPU\Release\AppInstallerCLIE2ETests\Test.runsettings'
overrideTestrunParameters: '-PackagedContext false
-AICLIPath $(system.defaultWorkingDirectory)\src\x64\Release\AppInstallerCLI\AppInstallerCLI.exe'
condition: succeededOrFailed()

- task: VSTest@2
displayName: Run E2E Tests Packaged x64
Expand All @@ -214,6 +214,7 @@ jobs:
-AICLIPath AppInstallerCLI\AppInstallerCLI.exe
-LooseFileRegistration true
-InvokeCommandInDesktopPackage true'
condition: succeededOrFailed()

- task: VSTest@2
displayName: Run E2E Tests Unpackaged x86
Expand All @@ -223,6 +224,7 @@ jobs:
runSettingsFile: 'src\AnyCPU\Release\AppInstallerCLIE2ETests\Test.runsettings'
overrideTestrunParameters: '-PackagedContext false
-AICLIPath $(system.defaultWorkingDirectory)\src\x86\Release\AppInstallerCLI\AppInstallerCLI.exe'
condition: succeededOrFailed()

- task: VSTest@2
displayName: Run E2E Tests Packaged x86
Expand All @@ -235,6 +237,7 @@ jobs:
-AICLIPath AppInstallerCLI\AppInstallerCLI.exe
-LooseFileRegistration true
-InvokeCommandInDesktopPackage true'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish CLI Binary
Expand Down
14 changes: 14 additions & 0 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,18 @@ namespace AppInstaller::CLI::Execution
Reporter.SetStyle(VisualStyle::Rainbow);
}
}

void Context::Terminate(HRESULT hr)
{
if (m_isTerminated && m_terminationHR == hr && hr == E_ABORT)
{
// If things aren't terminating fast enough for the user, they will probably press CTRL+C again.
// In that case, we should forcibly terminate.
// Unless we want to spin a separate thread for all work, we have to just exit here.
std::exit(hr);
}

m_isTerminated = true;
m_terminationHR = hr;
}
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ namespace AppInstaller::CLI::Execution
HRESULT GetTerminationHR() const { return m_terminationHR; }

// Set the context to the terminated state.
void Terminate(HRESULT hr) { m_isTerminated = true; m_terminationHR = hr; }
void Terminate(HRESULT hr);

// Adds a value to the context data, or overwrites an existing entry.
// This must be used to create the intial data entry, but Get can be used to modify.
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ namespace AppInstaller::CLI::Workflow
DeploymentOptions deploymentOptions =
DeploymentOptions::ForceApplicationShutdown |
DeploymentOptions::ForceTargetApplicationShutdown;
context.Reporter.ExecuteWithProgress(std::bind(Deployment::RequestAddPackageAsync, uri, deploymentOptions, std::placeholders::_1));
context.Reporter.ExecuteWithProgress(std::bind(Deployment::RequestAddPackage, uri, deploymentOptions, std::placeholders::_1));
}
catch (const wil::ResultException& re)
{
Expand Down
5 changes: 1 addition & 4 deletions src/AppInstallerCLIE2ETests/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public class Constants
public const string AICLIPackageName = "AppInstallerCLI";
public const string AICLIAppId = "AppInst";

// Todo: there's a deployment bug that if the last optional package is removed, the main package is also removed.
// We should remove this when the deployment bug is fixed.
public const string PlaceholderPackageFile = "PlaceholderPackage.msix";
public const string PlaceholderPackageName = "AppInstallerSQLiteIndex-e2etest-placeholder";
public const string TestPackage = "TestPackage.msix";

public class ErrorCode
{
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLIE2ETests/HashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void HashCommands()
Assert.True(result.StdOut.Contains("9b4c49ad7e47afd97d2e666e93347745e1647c55f1a7ebba6d31b7dd5f69ee68"));

// Hash msix
result = TestCommon.RunAICLICommand("hash", TestCommon.GetTestDataFile(Constants.PlaceholderPackageFile) + " -m");
result = TestCommon.RunAICLICommand("hash", TestCommon.GetTestDataFile(Constants.TestPackage) + " -m");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("08917b781939a7796746b5e2349e1f1d83b6c15599b60cd3f62816f15e565fc4"));
Assert.True(result.StdOut.Contains("223b318c4b1154a1fb72b1bc23422810faa5ce899a8e774ba2a02834b2058f00"));
Expand Down
2 changes: 0 additions & 2 deletions src/AppInstallerCLIE2ETests/SetUpFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void Setup()
{
Assert.True(TestCommon.InstallMsix(TestCommon.AICLIPackagePath));
}
Assert.True(TestCommon.InstallMsix(TestCommon.GetTestDataFile(Constants.PlaceholderPackageFile)));
}
}

Expand All @@ -92,7 +91,6 @@ public void TearDown()

if (TestCommon.PackagedContext)
{
TestCommon.RemoveMsix(Constants.PlaceholderPackageName);
TestCommon.RemoveMsix(Constants.AICLIPackageName);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLIE2ETests/SourceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void SourceCommands()
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("SourceTestSource"));
Assert.True(result.StdOut.Contains("https://winget-int.azureedge.net/cache"));
Assert.True(result.StdOut.Contains("AppInstallerSQLiteIndex-int"));
Assert.True(result.StdOut.Contains("Microsoft.Winget.Source.int"));
Assert.True(result.StdOut.Contains("Updated"));

// List when source name does not match
Expand Down
5 changes: 5 additions & 0 deletions src/AppInstallerCLIE2ETests/TestCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public static RunCommandResult RunAICLICommandViaInvokeCommandInDesktopPackage(s
waitedTime += 1000;
}

if (waitedTime >= timeOut)
{
throw new TimeoutException("Command run timed out.");
}

RunCommandResult result = new RunCommandResult();

result.ExitCode = File.Exists(exitCodeFile) ? int.Parse(File.ReadAllText(exitCodeFile).Trim()) : unchecked((int)0x80004005);
Expand Down
22 changes: 18 additions & 4 deletions src/AppInstallerCLIE2ETests/TestData/IndexPackageManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,33 @@
Version="1.0.0.0" />

<Properties>
<DisplayName>AppInstallerSQLiteIndex for AppInstallerCLI.</DisplayName>
<DisplayName>Microsoft WinGet Source</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\AppPackageStoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.16299.0" MaxVersionTested="10.0.18287.0" />
<uap4:MainPackageDependency Name="Microsoft.DesktopAppInstaller" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
<uap4:MainPackageDependency Name="AppInstallerCLI" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
</Dependencies>

<Applications>
<Application Id="SourceData">
<uap:VisualElements DisplayName="Source data for Microsoft WinGet" Square150x150Logo="Assets\AppPackageStoreLogo.scale-150.png" Square44x44Logo="Assets\AppPackageStoreLogo.scale-100.png" Description="Source data for Microsoft WinGet." BackgroundColor="#0078d7" AppListEntry="none" />
<Extensions>
<uap3:Extension Category="windows.appExtension">
<uap3:AppExtension Name="com.microsoft.winget.source"
Id="IndexDB"
DisplayName="Source data for Microsoft WinGet"
Description="Source data for Microsoft WinGet"
PublicFolder="Public">
</uap3:AppExtension>
</uap3:Extension>
</Extensions>
</Application>
</Applications>

<Resources>
<Resource Language="en-US" />
<Resource Language="und" />
</Resources>

</Package>
8 changes: 7 additions & 1 deletion src/AppInstallerCLIPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap5 rescap">
IgnorableNamespaces="uap uap3 uap5 rescap">
<Identity Name="AppInstallerCLI" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="0.0.0.2" />
<Properties>
<DisplayName>App Installer CLI</DisplayName>
Expand All @@ -23,6 +24,11 @@
<Application Id="AppInst" Executable="AppInstallerCLI\AppInstallerCLI.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="App Installer Client" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png" Description="The App Installer client application." BackgroundColor="#0078d7" AppListEntry="none" />
<Extensions>
<uap3:Extension Category="windows.appExtensionHost">
<uap3:AppExtensionHost>
<uap3:Name>com.microsoft.winget.source</uap3:Name>
</uap3:AppExtensionHost>
</uap3:Extension>
<uap5:Extension Category="windows.appExecutionAlias">
<uap5:AppExecutionAlias>
<uap5:ExecutionAlias Alias="AppInst.exe" />
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLITests/MsixInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TEST_CASE("MsixInfo_WriteFile", "[msixinfo]")
TempFile file{ "msixtest_file"s, ".bin"s };
ProgressCallback callback;

msix.WriteToFile("index.db", file, callback);
msix.WriteToFile("Public\\index.db", file, callback);

REQUIRE(1 == std::filesystem::file_size(file));
}
2 changes: 1 addition & 1 deletion src/AppInstallerCLITests/PreIndexedPackageSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ constexpr std::string_view s_MsixFile_1 = "index.1.0.0.0.msix";
constexpr std::string_view s_MsixFile_2 = "index.2.0.0.0.msix";
constexpr std::string_view s_Msix_FamilyName = "AppInstallerCLITestsFakeIndex_125rzkzqaqjwj";
constexpr std::string_view s_AppxManifestFileName = "AppxManifest.xml"sv;
constexpr std::string_view s_IndexMsixName = "index.msix"sv;
constexpr std::string_view s_IndexMsixName = "source.msix"sv;
constexpr std::string_view s_IndexFileName = "index.db"sv;

void CopyIndexFileToDirectory(const fs::path& from, const fs::path& to)
Expand Down
Binary file modified src/AppInstallerCLITests/TestData/index.1.0.0.0.msix
Binary file not shown.
Binary file modified src/AppInstallerCLITests/TestData/index.2.0.0.0.msix
Binary file not shown.
2 changes: 2 additions & 0 deletions src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
<ClInclude Include="Public\AppInstallerLogging.h" />
<ClInclude Include="Public\AppInstallerArchitecture.h" />
<ClInclude Include="Public\AppInstallerVersions.h" />
<ClInclude Include="Public\winget\ExtensionCatalog.h" />
<ClInclude Include="Telemetry\MicrosoftTelemetry.h" />
<ClInclude Include="Telemetry\TraceLogging.h" />
<ClInclude Include="Telemetry\WinEventLogLevels.h" />
Expand All @@ -203,6 +204,7 @@
<ClCompile Include="Deployment.cpp" />
<ClCompile Include="Downloader.cpp" />
<ClCompile Include="Errors.cpp" />
<ClCompile Include="ExtensionCatalog.cpp" />
<ClCompile Include="FileLogger.cpp" />
<ClCompile Include="HttpStream\HttpClientWrapper.cpp" />
<ClCompile Include="HttpStream\HttpLocalCache.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<Filter Include="HttpStream">
<UniqueIdentifier>{a9c14af9-ca74-4945-a19c-9e99df23a5ae}</UniqueIdentifier>
</Filter>
<Filter Include="Public\winget">
<UniqueIdentifier>{41035fd6-dc74-4464-b9b1-4ffe95d6789c}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
Expand Down Expand Up @@ -93,6 +96,9 @@
<ClInclude Include="Public\AppInstallerVersions.h">
<Filter>Public</Filter>
</ClInclude>
<ClInclude Include="Public\winget\ExtensionCatalog.h">
<Filter>Public\winget</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -152,6 +158,9 @@
<ClCompile Include="Errors.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ExtensionCatalog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCommonCore/AppInstallerLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace AppInstaller::Logging
case Channel::SQL: return "SQL";
case Channel::Repo: return "REPO";
case Channel::YAML: return "YAML";
case Channel::Core: return "CORE";
case Channel::Test: return "TEST";
default: return "NONE";
}
Expand Down
Loading

0 comments on commit 9858113

Please sign in to comment.