Skip to content

Commit

Permalink
Merge pull request #61 from AzureCosmosDB/develop
Browse files Browse the repository at this point in the history
Changes to resolve issues and update Cosmos SDK
  • Loading branch information
bowencode committed May 30, 2023
2 parents 486c5b7 + 510c8a5 commit 532dca1
Show file tree
Hide file tree
Showing 20 changed files with 575 additions and 124 deletions.
19 changes: 11 additions & 8 deletions .github/actions/build-with-plugins/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
runtime:
description: Target platform runtime (win-x64)
required: true
build-version:
description: Build or release version (0.0.1)
required: true
runs:
using: composite
steps:
Expand All @@ -27,7 +30,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Build Cosmos Extension
shell: bash
run: |
Expand All @@ -42,7 +45,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Build JSON Extension
shell: bash
run: |
Expand All @@ -57,7 +60,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Build Azure Table Extension
shell: bash
run: |
Expand All @@ -72,7 +75,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Build Mongo Extension
shell: bash
run: |
Expand All @@ -87,7 +90,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Build SQL Server Extension
shell: bash
run: |
Expand All @@ -102,7 +105,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Build Parquet Extension
shell: bash
run: |
Expand All @@ -117,7 +120,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Build Cognitive Search Extension
shell: bash
run: |
Expand All @@ -132,7 +135,7 @@ runs:
-p:EnableCompressionInSingleFile=true \
-p:PublishReadyToRun=false \
-p:PublishTrimmed=false \
-p:Version=0.0.${{ github.run_number }}
-p:Version=${{ inputs.build-version }}
- name: Upload package
uses: actions/upload-artifact@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/internal-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ jobs:
platform: windows
platform-short: win
runtime: win-x64
build-version: 0.0.${{ github.run_number }}
- name: Execute Action build-with-plugins for MacOS
uses: ./.github/actions/build-with-plugins
id: build-with-plugins-mac
with:
platform: mac
platform-short: mac
runtime: osx-x64
build-version: 0.0.${{ github.run_number }}
- name: Execute Action build-with-plugins for Linux
uses: ./.github/actions/build-with-plugins
id: build-with-plugins-linux
with:
platform: linux
platform-short: linux
runtime: linux-x64
build-version: 0.0.${{ github.run_number }}
15 changes: 9 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ jobs:
path: linux-package
- name: Package output files
run: |
zip -r dmt-${{ github.ref_name }}-win-x64.zip windows-package/*
zip -r dmt-${{ github.ref_name }}-mac-x64.zip mac-package/*
zip -r dmt-${{ github.ref_name }}-linux-x64.zip linux-package/*
zip -r dmt-${{ github.event.release.tag_name }}-win-x64.zip windows-package/*
zip -r dmt-${{ github.event.release.tag_name }}-mac-x64.zip mac-package/*
zip -r dmt-${{ github.event.release.tag_name }}-linux-x64.zip linux-package/*
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
files: |
dmt-${{ github.ref_name }}-win-x64.zip
dmt-${{ github.ref_name }}-mac-x64.zip
dmt-${{ github.ref_name }}-linux-x64.zip
dmt-${{ github.event.release.tag_name }}-win-x64.zip
dmt-${{ github.event.release.tag_name }}-mac-x64.zip
dmt-${{ github.event.release.tag_name }}-linux-x64.zip
build-package:
name: Build self-contained executables
runs-on: ubuntu-latest
Expand All @@ -52,17 +52,20 @@ jobs:
platform: windows
platform-short: win
runtime: win-x64
build-version: ${{ github.event.release.tag_name }}
- name: Execute Action build-with-plugins for MacOS
uses: ./.github/actions/build-with-plugins
id: build-with-plugins-mac
with:
platform: mac
platform-short: mac
runtime: osx-x64
build-version: ${{ github.event.release.tag_name }}
- name: Execute Action build-with-plugins for Linux
uses: ./.github/actions/build-with-plugins
id: build-with-plugins-linux
with:
platform: linux
platform-short: linux
runtime: linux-x64
build-version: ${{ github.event.release.tag_name }}
5 changes: 4 additions & 1 deletion Core/Cosmos.DataTransfer.Core/DataTransferOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
public class DataTransferOptions
{
public string? Source { get; set; }
public string? Sink { get; set; }
private string? _sink;
public string? Sink { get => _sink; set => _sink = value; }
public string? Target { get => _sink; set => _sink = value; }
public string? Destination { get => _sink; set => _sink = value; }
public string? SettingsPath { get; set; }
}
41 changes: 37 additions & 4 deletions Core/Cosmos.DataTransfer.Core/ExtensionManifestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ExtensionManifestBuilder : IExtensionManifestBuilder
{
private readonly ILogger _logger;
private readonly IExtensionLoader _extensionLoader;
private static string? _appVersion;

public ExtensionManifestBuilder(IExtensionLoader extensionLoader, ILogger<ExtensionManifestBuilder> logger)
{
Expand Down Expand Up @@ -45,10 +46,19 @@ public ExtensionManifest BuildManifest(ExtensionDirection direction)
{
extensions.AddRange(GetSinks());
}
var manifest = new ExtensionManifest(extensions
.Select(e => new ExtensionManifestItem(e.DisplayName,
direction,
GetExtensionSettings(e as IExtensionWithSettings))).ToList());
var manifest = new ExtensionManifest(AppVersion, extensions
.Select(e =>
{
var assembly = Assembly.GetAssembly(e.GetType());
var version = assembly != null ? GetAssemblyVersion(assembly) : null;
var assemblyName = assembly?.GetName().Name;
return new ExtensionManifestItem(e.DisplayName,
direction,
version,
assemblyName,
GetExtensionSettings(e as IExtensionWithSettings));
}).ToList());
return manifest;
}

Expand Down Expand Up @@ -132,5 +142,28 @@ private static PropertyType GetPropertyType(Type type)

return PropertyType.String;
}

private static string AppVersion => _appVersion ??= GetAppVersion();

private static string GetAppVersion()
{
var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();

return GetAssemblyVersion(assembly);
}

private static string GetAssemblyVersion(Assembly assembly)
{
var assemblyVersionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

if (assemblyVersionAttribute is null)
{
return assembly.GetName().Version?.ToString() ?? "";
}
else
{
return assemblyVersionAttribute.InformationalVersion;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"SettingsCommand": {
"commandName": "Project",
"commandLineArgs": "settings --sink -e cosmos-nosql"
"commandLineArgs": "settings --sink"
}
}
}
42 changes: 33 additions & 9 deletions Core/Cosmos.DataTransfer.Core/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ public static void AddRunOptions(Command command)
{
var sourceOption = new Option<string?>(
aliases: new[] { "--source", "-from" },
description: "The extension to read data.");
description: "The extension to read data.")
{
ArgumentHelpName = "source"
};
var sinkOption = new Option<string?>(
aliases: new[] { "--sink", "-to" },
description: "The extension to write data.");
aliases: new[] { "--sink", "-to", "--target", "--destination" },
description: "The extension to write data.")
{
ArgumentHelpName = "sink"
};
var settingsOption = new Option<FileInfo?>(
aliases: new[] { "--settings" },
description: "The settings file. (default: migrationsettings.json)");
Expand Down Expand Up @@ -90,7 +96,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
cancellationToken.ThrowIfCancellationRequested();

var sourceConfig = combinedConfig.GetSection("SourceSettings");
var sinkConfig = combinedConfig.GetSection("SinkSettings");
var sinkConfig = GetSinkConfig(combinedConfig);
var operationConfigs = combinedConfig.GetSection("Operations");
var operations = operationConfigs?.GetChildren().ToList();
if (operations?.Any() == true)
Expand All @@ -103,16 +109,16 @@ public async Task<int> InvokeAsync(InvocationContext context)
{
sourceBuilder.AddConfiguration(operationSource);
}
var operationSink = operationConfig.GetSection("SinkSettings");
var operationSink = GetSinkConfig(operationConfig);
var sinkBuilder = new ConfigurationBuilder().AddConfiguration(sinkConfig);
if (operationSink.Exists())
{
sinkBuilder.AddConfiguration(operationSink);
}
await ExecuteDataTransferOperation(source,
sourceBuilder.Build(),
sink,
sinkBuilder.Build(),
await ExecuteDataTransferOperation(source,
sourceBuilder.Build(),
sink,
sinkBuilder.Build(),
cancellationToken);
}
}
Expand All @@ -124,6 +130,24 @@ public async Task<int> InvokeAsync(InvocationContext context)
return 0;
}

private static IConfigurationSection GetSinkConfig(IConfiguration combinedConfig)
{
var config = combinedConfig.GetSection("SinkSettings");
if (config != null && config.Exists())
{
return config;
}

config = combinedConfig.GetSection("TargetSettings");
if (config != null && config.Exists())
{
return config;
}

config = combinedConfig.GetSection("DestinationSettings");
return config;
}

private async Task ExecuteDataTransferOperation(IDataSourceExtension source, IConfiguration sourceConfig, IDataSinkExtension sink, IConfiguration sinkConfig, CancellationToken cancellationToken)
{
_logger.LogDebug("Loaded {SettingCount} settings for source {SourceName}:\n\t\t{SettingList}",
Expand Down

0 comments on commit 532dca1

Please sign in to comment.