Pauld/add ostype to build output dir (#1451)

* add functionality to copy ostype file to same directory as manifest file, upon oryx build. Added tests for this functionality

* added OS_TYPE_SOURCE_DIR instead of duplicating path

* fix build errors and unused variables
This commit is contained in:
Paul Dorsch 2022-06-29 17:48:15 -04:00 коммит произвёл GitHub
Родитель 7c17421b2a
Коммит 2664d28fd1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 58 добавлений и 2 удалений

Просмотреть файл

@ -6,6 +6,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common
{
public const string CompressedOutputFileName = "oryx_output.tar.gz";
public const string BuildManifestFileName = "oryx-manifest.toml";
public const string OsTypeFileName = ".ostype";
public const string BuildCommandsFileName = "oryx-build-commands.txt";
public const string RunScriptGeneratorDir = "/opt/startupcmdgen";
public const string NodeAppInsightsLoaderFileName = "applicationinsights/out/Bootstrap/Oryx.js";

Просмотреть файл

@ -216,6 +216,15 @@ echo "Manifest file created."
{{ end }}
{{ end }}
OS_TYPE_SOURCE_DIR="/opt/oryx/.ostype"
if [ -f "$OS_TYPE_SOURCE_DIR" ]
then
echo "Copying .ostype to manifest output directory."
cp "$OS_TYPE_SOURCE_DIR" "$MANIFEST_DIR/.ostype"
else
echo "File $OS_TYPE_SOURCE_DIR does not exist. Cannot copy to manifest directory."
fi
TOTAL_EXECUTION_ELAPSED_TIME=$(($SECONDS - $TOTAL_EXECUTION_START_TIME))
echo
echo "Done in $TOTAL_EXECUTION_ELAPSED_TIME sec(s)."

Просмотреть файл

@ -51,6 +51,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = "/tmp/output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand(
@ -58,6 +59,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
$"--platform {DotNetCoreConstants.PlatformName} --platform-version {runtimeVersion}")
.AddFileExistsCheck($"{appOutputDir}/{appName}.dll")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
var majorPart = runtimeVersion.Split('.')[0];
@ -169,6 +171,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
Path.Combine(volume.MountedHostDir, DotNetCoreConstants.GlobalJsonFileName),
globalJsonContent);
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand(
@ -176,6 +179,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
$"--platform {DotNetCoreConstants.PlatformName} --platform-version {runtimeVersion} --log-file log.txt")
.AddFileExistsCheck($"{appOutputDir}/{appName}.dll")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -231,11 +235,13 @@ namespace Microsoft.Oryx.BuildImage.Tests
Path.Combine(volume.MountedHostDir, DotNetCoreConstants.GlobalJsonFileName),
globalJsonContent);
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand($"{appDir} -i /tmp/int -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{appName}.dll")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -290,11 +296,13 @@ namespace Microsoft.Oryx.BuildImage.Tests
globalJsonContent);
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand($"{appDir} -i /tmp/int -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{appName}.dll")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -387,6 +395,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
Path.Combine(volume.MountedHostDir, DotNetCoreConstants.GlobalJsonFileName),
globalJsonContent);
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand(
@ -395,6 +404,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
$"{expectedDynamicInstallRootDir}/{DotNetCoreConstants.PlatformName}/{expectedSdkVersion}")
.AddFileExistsCheck($"{appOutputDir}/{appName}.dll")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -436,6 +446,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = "/tmp/output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var preInstalledSdkLink = $"/home/codespace/.dotnet/sdk";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
@ -450,6 +461,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
.AddDirectoryExistsCheck($"/opt/dotnet/{sdkVersion}")
.AddLinkExistsCheck($"{preInstalledSdkLink}/{sdkVersion}")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.AddCommand("/home/codespace/.dotnet/dotnet --list-sdks")
.ToString();

Просмотреть файл

@ -66,10 +66,12 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = "/tmp/aspnetcore10-output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -o {appOutputDir} --platform dotnet --platform-version 1.1.13")
.AddFileExistsCheck($"{appOutputDir}/app.dll")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -113,6 +115,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
.AddBuildCommand($"{appDir} -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{appName}.dll")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.ToString();
// Act
@ -147,6 +150,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
.AddBuildCommand($"{appDir} -o {appOutputDir} --platform dotnet --platform-version 2.1.22")
.AddFileExistsCheck($"{appOutputDir}/app.dll")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.ToString();
// Act
@ -712,7 +716,10 @@ namespace Microsoft.Oryx.BuildImage.Tests
.AddBuildCommand($"{appDir} -o {appOutputDir} --platform dotnet --platform-version 2.1.22")
.AddFileExistsCheck($"{appOutputDir}/bin/{appName}.dll")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddStringExistsInFileCheck($"{ManifestFilePropertyKeys.PlatformName}=\"{DotNetCoreConstants.PlatformName}\"", $"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck(
$"{ManifestFilePropertyKeys.PlatformName}=\"{DotNetCoreConstants.PlatformName}\"",
$"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.ToString();
// Act
@ -749,6 +756,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
$"{appDir} -o {appOutputDir} --platform dotnet " +
$"--platform-version 5.0.0")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck(
ManifestFilePropertyKeys.PlatformName, $"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.ToString();
@ -789,6 +797,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
$"{appDir} -o {appOutputDir} --apptype {Constants.StaticSiteApplications} " +
$"--platform dotnet --platform-version 3.1.8")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck(ManifestFilePropertyKeys.PlatformName, $"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.ToString();
@ -828,6 +837,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
$"{appDir}/MessageFunction -o {appOutputDir} --apptype functions --platform dotnet " +
$"--platform-version 3.1")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.ToString();
// Act
@ -867,6 +877,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
.AddBuildCommand(
$"{appDir}/ -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck($"{ManifestFilePropertyKeys.OutputType}=\"Exe\"", $"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.ToString();
@ -1047,6 +1058,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck($"{ManifestFilePropertyKeys.PlatformName}=\"{DotNetCoreConstants.PlatformName}\"", $"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.ToString();
@ -1084,6 +1096,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck($"{ManifestFilePropertyKeys.PlatformName}=\"{DotNetCoreConstants.PlatformName}\"", $"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.ToString();
@ -1121,6 +1134,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck($"{ManifestFilePropertyKeys.PlatformName}=\"{DotNetCoreConstants.PlatformName}\"", $"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.ToString();

Просмотреть файл

@ -40,6 +40,7 @@ namespace Oryx.BuildImage.Tests.Node
var appOutputDir = "/tmp/output";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -i /tmp/int -o {appOutputDir}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck(
$"{NodeManifestFilePropertyKeys.OutputDirPath}=\"{expectedOutputDirPath}\"",
$"{appOutputDir}/{FilePaths.BuildManifestFileName}")

Просмотреть файл

@ -324,9 +324,11 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = "/tmp/webfrontend-output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -i /tmp/int -o {appOutputDir} --platform {NodeConstants.PlatformName} --platform-version {version}")
.AddDirectoryExistsCheck($"{appOutputDir}/node_modules")
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -625,6 +627,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
var buildScript = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -i /tmp/int -o {appOutputDir} -p compress_node_modules=zip")
.AddFileExistsCheck($"{appOutputDir}/node_modules.zip")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddDirectoryDoesNotExistCheck($"{appOutputDir}/node_modules")
.AddStringExistsInFileCheck(
"compressedNodeModulesFile=\"node_modules.zip\"",

Просмотреть файл

@ -109,11 +109,13 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = "/tmp/output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddCommand($"rm {appDir}/composer.json")
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand(
$"{appDir} -o {appOutputDir} --platform {PhpConstants.PlatformName} --platform-version {phpVersion}")
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();

Просмотреть файл

@ -484,11 +484,13 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = $"{appDir}/output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand(
$"{appDir} -o {appOutputDir} --platform {PythonConstants.PlatformName} " +
$"--platform-version {PythonVersions.Python36Version}")
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -531,11 +533,13 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = $"{appDir}/output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand(
$"{appDir} -o {appOutputDir} --platform {PythonConstants.PlatformName} " +
$"--platform-version {PythonVersions.Python36Version}")
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -575,11 +579,13 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appDir = volume.ContainerDir;
var appOutputDir = $"{appDir}/output";
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddBuildCommand(
$"{appDir} -o {appOutputDir} --platform {PythonConstants.PlatformName} " +
$"--platform-version {PythonVersions.Python36Version}")
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -739,9 +745,11 @@ namespace Microsoft.Oryx.BuildImage.Tests
var appOutputDir = "/tmp/app-output";
var virtualEnvName = GetDefaultVirtualEnvName(PythonConstants.PythonLtsVersion);
var manifestFile = $"{appOutputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{appOutputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddBuildCommand($"{appDir} -o {appOutputDir} -i {appIntermediateDir}")
.AddDirectoryExistsCheck($"{appOutputDir}/{virtualEnvName}")
.AddFileExistsCheck(osTypeFile)
.AddCommand($"cat {manifestFile}")
.ToString();
@ -1399,13 +1407,15 @@ namespace Microsoft.Oryx.BuildImage.Tests
var outputDir = "/tmp/output";
var virtualEnvName = "antenv";
var manifestFile = $"{outputDir}/{FilePaths.BuildManifestFileName}";
var osTypeFile = $"{outputDir}/{FilePaths.OsTypeFileName}";
var script = new ShellScriptBuilder()
.AddDefaultTestEnvironmentVariables()
.AddCommand(
$"oryx build {appDir} -i {buildDir} -o {outputDir} " +
$"-p virtualenv_name={virtualEnvName} --compress-destination-dir")
.AddFileExistsCheck($"{outputDir}/output.tar.gz")
.AddFileExistsCheck($"{outputDir}/oryx-manifest.toml")
.AddFileExistsCheck(manifestFile)
.AddFileExistsCheck(osTypeFile)
.AddFileDoesNotExistCheck($"{outputDir}/requirements.txt")
.AddDirectoryDoesNotExistCheck($"{outputDir}/{virtualEnvName}")
.AddCommand($"cat {manifestFile}")

Просмотреть файл

@ -119,6 +119,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
.AddBuildCommand(
$"{appDir} -o {appOutputDir} --apptype {Constants.StaticSiteApplications} ")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck(
$"{ManifestFilePropertyKeys.PlatformName}=\"{RubyConstants.PlatformName}\"",
$"{appOutputDir}/{FilePaths.BuildManifestFileName}")
@ -153,6 +154,7 @@ namespace Microsoft.Oryx.BuildImage.Tests
$"{appDir} -o {appOutputDir} --apptype {Constants.StaticSiteApplications} ")
.AddFileExistsCheck($"{appOutputDir}/example.txt")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.BuildManifestFileName}")
.AddFileExistsCheck($"{appOutputDir}/{FilePaths.OsTypeFileName}")
.AddStringExistsInFileCheck(
$"{ManifestFilePropertyKeys.PlatformName}=\"{RubyConstants.PlatformName}\"",
$"{appOutputDir}/{FilePaths.BuildManifestFileName}")

Просмотреть файл

@ -93,6 +93,8 @@ namespace Microsoft.Oryx.Integration.Tests
$"--platform-version {dotnetcoreVersion} " +
$"--manifest-dir {manifestDir}")
.AddFileExistsCheck($"{manifestDir}/{FilePaths.BuildManifestFileName}")
// Additionally ensure that the ostype file is placed where the manifest file is, not the output dir
.AddFileExistsCheck($"{manifestDir}/{FilePaths.OsTypeFileName}")
.ToString();
var runtimeImageScript = new ShellScriptBuilder()
.AddCommand(