Compare commits

..

5 Commits

Author SHA1 Message Date
WINDOWS-8IMA9MH\jasfu
8acf57570f rclone basic test 2024-08-08 15:31:41 +01:00
WINDOWS-8IMA9MH\jasfu
ba925c0e55 rclone basic test 2024-08-08 01:42:33 +01:00
WINDOWS-8IMA9MH\jasfu
47d1c5feca rclone basic test 2024-08-08 01:41:46 +01:00
WINDOWS-8IMA9MH\jasfu
4b6ca3b5a4 no message 2024-07-20 06:47:57 +01:00
WINDOWS-8IMA9MH\jasfu
3db9ec2db7 no message 2024-07-20 06:40:46 +01:00
43 changed files with 278 additions and 1983 deletions

View File

@ -13,7 +13,7 @@ jobs:
id: requestActivationFile id: requestActivationFile
uses: game-ci/unity-request-activation-file@v2.0-alpha-1 uses: game-ci/unity-request-activation-file@v2.0-alpha-1
- name: Upload activation file - name: Upload activation file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v3
with: with:
name: ${{ steps.requestActivationFile.outputs.filePath }} name: ${{ steps.requestActivationFile.outputs.filePath }}
path: ${{ steps.requestActivationFile.outputs.filePath }} path: ${{ steps.requestActivationFile.outputs.filePath }}

View File

@ -59,7 +59,6 @@ jobs:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with: with:
buildName: 'GameCI Test Build' buildName: 'GameCI Test Build'
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}

View File

@ -36,8 +36,7 @@ env:
jobs: jobs:
buildForAllPlatformsUbuntu: buildForAllPlatformsUbuntu:
name: name: ${{ matrix.targetPlatform }} on ${{ matrix.unityVersion }}
"${{ matrix.targetPlatform }} on ${{ matrix.unityVersion}}${{startsWith(matrix.buildProfile, 'Assets') && ' (via Build Profile)' || '' }}"
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
@ -92,12 +91,6 @@ jobs:
- targetPlatform: StandaloneWindows64 - targetPlatform: StandaloneWindows64
additionalParameters: -standaloneBuildSubtarget Server additionalParameters: -standaloneBuildSubtarget Server
buildWithIl2cpp: true buildWithIl2cpp: true
include:
- unityVersion: 6000.0.36f1
targetPlatform: WebGL
- unityVersion: 6000.0.36f1
targetPlatform: WebGL
buildProfile: 'Assets/Settings/Build Profiles/Sample WebGL Build Profile.asset'
steps: steps:
- name: Clear Space for Android Build - name: Clear Space for Android Build
@ -143,7 +136,6 @@ jobs:
with: with:
buildName: 'GameCI Test Build' buildName: 'GameCI Test Build'
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
buildProfile: ${{ matrix.buildProfile }}
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.targetPlatform }} targetPlatform: ${{ matrix.targetPlatform }}
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue ${{ matrix.additionalParameters }} customParameters: -profile SomeProfile -someBoolean -someValue exampleValue ${{ matrix.additionalParameters }}
@ -166,7 +158,6 @@ jobs:
with: with:
buildName: 'GameCI Test Build' buildName: 'GameCI Test Build'
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
buildProfile: ${{ matrix.buildProfile }}
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.targetPlatform }} targetPlatform: ${{ matrix.targetPlatform }}
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue ${{ matrix.additionalParameters }} customParameters: -profile SomeProfile -someBoolean -someValue exampleValue ${{ matrix.additionalParameters }}
@ -188,7 +179,6 @@ jobs:
with: with:
buildName: 'GameCI Test Build' buildName: 'GameCI Test Build'
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
buildProfile: ${{ matrix.buildProfile }}
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.targetPlatform }} targetPlatform: ${{ matrix.targetPlatform }}
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue ${{ matrix.additionalParameters }} customParameters: -profile SomeProfile -someBoolean -someValue exampleValue ${{ matrix.additionalParameters }}
@ -201,6 +191,7 @@ jobs:
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: name:
"Build ${{ matrix.targetPlatform }}${{ startsWith(matrix.buildProfile, 'Assets') && ' (via Build Profile)' || '' }} on Ubuntu (${{ matrix.unityVersion }}_il2cpp_${{ matrix.buildWithIl2cpp }}_params_${{ matrix.additionalParameters }})" 'Build ${{ matrix.targetPlatform }} on Ubuntu (${{ matrix.unityVersion }}_il2cpp_${{ matrix.buildWithIl2cpp
}}_params_${{ matrix.additionalParameters }})'
path: build path: build
retention-days: 14 retention-days: 14

View File

@ -65,7 +65,6 @@ jobs:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with: with:
buildName: 'GameCI Test Build' buildName: 'GameCI Test Build'
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
@ -90,7 +89,6 @@ jobs:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with: with:
buildName: 'GameCI Test Build' buildName: 'GameCI Test Build'
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
@ -114,7 +112,6 @@ jobs:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with: with:
buildName: 'GameCI Test Build' buildName: 'GameCI Test Build'
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}

View File

@ -92,6 +92,7 @@ jobs:
- 'cloud-runner-kubernetes' - 'cloud-runner-kubernetes'
- 'cloud-runner-environment' - 'cloud-runner-environment'
- 'cloud-runner-github-checks' - 'cloud-runner-github-checks'
- 'cloud-runner-rclone-core'
steps: steps:
- name: Checkout (default) - name: Checkout (default)
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -160,6 +161,7 @@ jobs:
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }} GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
buildTargetTests: buildTargetTests:
name: Local Build Target Tests name: Local Build Target Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -190,7 +192,6 @@ jobs:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }} GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
@ -202,7 +203,7 @@ jobs:
providerStrategy: ${{ matrix.providerStrategy }} providerStrategy: ${{ matrix.providerStrategy }}
- run: | - run: |
cp ./cloud-runner-cache/cache/${{ steps.unity-build.outputs.CACHE_KEY }}/build/${{ steps.unity-build.outputs.BUILD_ARTIFACT }} ${{ steps.unity-build.outputs.BUILD_ARTIFACT }} cp ./cloud-runner-cache/cache/${{ steps.unity-build.outputs.CACHE_KEY }}/build/${{ steps.unity-build.outputs.BUILD_ARTIFACT }} ${{ steps.unity-build.outputs.BUILD_ARTIFACT }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v3
with: with:
name: ${{ matrix.providerStrategy }} Build (${{ matrix.targetPlatform }}) name: ${{ matrix.providerStrategy }} Build (${{ matrix.targetPlatform }})
path: ${{ steps.unity-build.outputs.BUILD_ARTIFACT }} path: ${{ steps.unity-build.outputs.BUILD_ARTIFACT }}

View File

@ -18,11 +18,7 @@ inputs:
projectPath: projectPath:
required: false required: false
default: '' default: ''
description: 'Path to the project to be built, relative to the repository root.' description: 'Relative path to the project to be built.'
buildProfile:
required: false
default: ''
description: 'Path to the build profile to activate, relative to the project root.'
buildName: buildName:
required: false required: false
default: '' default: ''

View File

@ -6,9 +6,6 @@ using UnityBuilderAction.Reporting;
using UnityBuilderAction.Versioning; using UnityBuilderAction.Versioning;
using UnityEditor; using UnityEditor;
using UnityEditor.Build.Reporting; using UnityEditor.Build.Reporting;
#if UNITY_6000_0_OR_NEWER
using UnityEditor.Build.Profile;
#endif
using UnityEngine; using UnityEngine;
namespace UnityBuilderAction namespace UnityBuilderAction
@ -20,9 +17,47 @@ namespace UnityBuilderAction
// Gather values from args // Gather values from args
var options = ArgumentsParser.GetValidatedOptions(); var options = ArgumentsParser.GetValidatedOptions();
// Gather values from project
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
// Get all buildOptions from options
BuildOptions buildOptions = BuildOptions.None;
foreach (string buildOptionString in Enum.GetNames(typeof(BuildOptions))) {
if (options.ContainsKey(buildOptionString)) {
BuildOptions buildOptionEnum = (BuildOptions) Enum.Parse(typeof(BuildOptions), buildOptionString);
buildOptions |= buildOptionEnum;
}
}
#if UNITY_2021_2_OR_NEWER
// Determine subtarget
StandaloneBuildSubtarget buildSubtarget;
if (!options.TryGetValue("standaloneBuildSubtarget", out var subtargetValue) || !Enum.TryParse(subtargetValue, out buildSubtarget)) {
buildSubtarget = default;
}
#endif
// Define BuildPlayer Options
var buildPlayerOptions = new BuildPlayerOptions {
scenes = scenes,
locationPathName = options["customBuildPath"],
target = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
options = buildOptions,
#if UNITY_2021_2_OR_NEWER
subtarget = (int) buildSubtarget
#endif
};
// Set version for this build // Set version for this build
VersionApplicator.SetVersion(options["buildVersion"]); VersionApplicator.SetVersion(options["buildVersion"]);
// Apply Android settings
if (buildPlayerOptions.target == BuildTarget.Android)
{
VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);
AndroidSettings.Apply(options);
}
// Execute default AddressableAsset content build, if the package is installed. // Execute default AddressableAsset content build, if the package is installed.
// Version defines would be the best solution here, but Unity 2018 doesn't support that, // Version defines would be the best solution here, but Unity 2018 doesn't support that,
// so we fall back to using reflection instead. // so we fall back to using reflection instead.
@ -39,76 +74,10 @@ namespace UnityBuilderAction
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogError("Failed to run default addressables build:\n" + e); Debug.LogError($"Failed to run default addressables build:\n{e}");
} }
} }
// Get all buildOptions from options
BuildOptions buildOptions = BuildOptions.None;
foreach (string buildOptionString in Enum.GetNames(typeof(BuildOptions))) {
if (options.ContainsKey(buildOptionString)) {
BuildOptions buildOptionEnum = (BuildOptions) Enum.Parse(typeof(BuildOptions), buildOptionString);
buildOptions |= buildOptionEnum;
}
}
// Depending on whether the build is using a build profile, `buildPlayerOptions` will an instance
// of either `UnityEditor.BuildPlayerOptions` or `UnityEditor.BuildPlayerWithProfileOptions`
dynamic buildPlayerOptions;
if (options["customBuildProfile"] != "") {
#if UNITY_6000_0_OR_NEWER
// Load build profile from Assets folder
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]);
// Set it as active
BuildProfile.SetActiveBuildProfile(buildProfile);
// Define BuildPlayerWithProfileOptions
buildPlayerOptions = new BuildPlayerWithProfileOptions {
buildProfile = buildProfile,
locationPathName = options["customBuildPath"],
options = buildOptions,
};
#else
throw new Exception("Build profiles are not supported by this version of Unity (" + Application.unityVersion +")");
#endif
} else {
// Gather values from project
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
#if UNITY_2021_2_OR_NEWER
// Determine subtarget
StandaloneBuildSubtarget buildSubtarget;
if (!options.TryGetValue("standaloneBuildSubtarget", out var subtargetValue) || !Enum.TryParse(subtargetValue, out buildSubtarget)) {
buildSubtarget = default;
}
#endif
BuildTarget buildTarget = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]);
// Define BuildPlayerOptions
buildPlayerOptions = new BuildPlayerOptions {
scenes = scenes,
locationPathName = options["customBuildPath"],
target = buildTarget,
options = buildOptions,
#if UNITY_2021_2_OR_NEWER
subtarget = (int) buildSubtarget
#endif
};
// Apply Android settings
if (buildTarget == BuildTarget.Android) {
VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);
AndroidSettings.Apply(options);
}
}
// Perform build // Perform build
BuildReport buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions); BuildReport buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);

View File

@ -56,17 +56,17 @@ namespace UnityBuilderAction.Input
case "androidStudioProject": case "androidStudioProject":
EditorUserBuildSettings.exportAsGoogleAndroidProject = true; EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
if (buildAppBundle != null) if (buildAppBundle != null)
buildAppBundle.SetValue(null, false, null); buildAppBundle.SetValue(null, false);
break; break;
case "androidAppBundle": case "androidAppBundle":
EditorUserBuildSettings.exportAsGoogleAndroidProject = false; EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
if (buildAppBundle != null) if (buildAppBundle != null)
buildAppBundle.SetValue(null, true, null); buildAppBundle.SetValue(null, true);
break; break;
case "androidPackage": case "androidPackage":
EditorUserBuildSettings.exportAsGoogleAndroidProject = false; EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
if (buildAppBundle != null) if (buildAppBundle != null)
buildAppBundle.SetValue(null, false, null); buildAppBundle.SetValue(null, false);
break; break;
} }
} }

View File

@ -28,7 +28,7 @@ namespace UnityBuilderAction.Input
} }
if (!Enum.IsDefined(typeof(BuildTarget), buildTarget)) { if (!Enum.IsDefined(typeof(BuildTarget), buildTarget)) {
Console.WriteLine(buildTarget + " is not a defined " + typeof(BuildTarget).Name); Console.WriteLine($"{buildTarget} is not a defined {nameof(BuildTarget)}");
EditorApplication.Exit(121); EditorApplication.Exit(121);
} }
@ -41,10 +41,10 @@ namespace UnityBuilderAction.Input
const string defaultCustomBuildName = "TestBuild"; const string defaultCustomBuildName = "TestBuild";
string customBuildName; string customBuildName;
if (!validatedOptions.TryGetValue("customBuildName", out customBuildName)) { if (!validatedOptions.TryGetValue("customBuildName", out customBuildName)) {
Console.WriteLine("Missing argument -customBuildName, defaulting to" + defaultCustomBuildName); Console.WriteLine($"Missing argument -customBuildName, defaulting to {defaultCustomBuildName}.");
validatedOptions.Add("customBuildName", defaultCustomBuildName); validatedOptions.Add("customBuildName", defaultCustomBuildName);
} else if (customBuildName == "") { } else if (customBuildName == "") {
Console.WriteLine("Invalid argument -customBuildName, defaulting to" + defaultCustomBuildName); Console.WriteLine($"Invalid argument -customBuildName, defaulting to {defaultCustomBuildName}.");
validatedOptions.Add("customBuildName", defaultCustomBuildName); validatedOptions.Add("customBuildName", defaultCustomBuildName);
} }
@ -57,11 +57,11 @@ namespace UnityBuilderAction.Input
string[] args = Environment.GetCommandLineArgs(); string[] args = Environment.GetCommandLineArgs();
Console.WriteLine( Console.WriteLine(
EOL + $"{EOL}" +
"###########################" + EOL + $"###########################{EOL}" +
"# Parsing settings #" + EOL + $"# Parsing settings #{EOL}" +
"###########################" + EOL + $"###########################{EOL}" +
EOL $"{EOL}"
); );
// Extract flags with optional values // Extract flags with optional values
@ -78,7 +78,7 @@ namespace UnityBuilderAction.Input
string displayValue = secret ? "*HIDDEN*" : "\"" + value + "\""; string displayValue = secret ? "*HIDDEN*" : "\"" + value + "\"";
// Assign // Assign
Console.WriteLine("Found flag \"" + flag + "\" with value " + displayValue); Console.WriteLine($"Found flag \"{flag}\" with value {displayValue}.");
providedArguments.Add(flag, value); providedArguments.Add(flag, value);
} }
} }

View File

@ -30,7 +30,7 @@ namespace UnityBuilderAction.Reporting
prefix = "error"; prefix = "error";
break; break;
} }
Console.WriteLine(Environment.NewLine + "::" + prefix + "::" + condition + Environment.NewLine + stackTrace); Console.WriteLine($"{Environment.NewLine}::{prefix} ::{condition}{Environment.NewLine}{stackTrace}");
} }
} }
} }

View File

@ -11,16 +11,16 @@ namespace UnityBuilderAction.Reporting
public static void ReportSummary(BuildSummary summary) public static void ReportSummary(BuildSummary summary)
{ {
Console.WriteLine( Console.WriteLine(
EOL + $"{EOL}" +
"###########################" + EOL + $"###########################{EOL}" +
"# Build results #" + EOL + $"# Build results #{EOL}" +
"###########################" + EOL + $"###########################{EOL}" +
EOL + $"{EOL}" +
"Duration: " + summary.totalTime.ToString() + EOL + $"Duration: {summary.totalTime.ToString()}{EOL}" +
"Warnings: " + summary.totalWarnings.ToString() + EOL + $"Warnings: {summary.totalWarnings.ToString()}{EOL}" +
"Errors: " + summary.totalErrors.ToString() + EOL + $"Errors: {summary.totalErrors.ToString()}{EOL}" +
"Size: " + summary.totalSize.ToString() + " bytes" + EOL + $"Size: {summary.totalSize.ToString()} bytes{EOL}" +
EOL $"{EOL}"
); );
} }

View File

@ -21,11 +21,11 @@ namespace UnityBuilderAction.Versioning
version = GetSemanticCommitVersion(); version = GetSemanticCommitVersion();
Console.WriteLine("Repository has a valid version tag."); Console.WriteLine("Repository has a valid version tag.");
} else { } else {
version = "0.0." + GetTotalNumberOfCommits(); version = $"0.0.{GetTotalNumberOfCommits()}";
Console.WriteLine("Repository does not have tags to base the version on."); Console.WriteLine("Repository does not have tags to base the version on.");
} }
Console.WriteLine("Version is " + version); Console.WriteLine($"Version is {version}");
return version; return version;
} }

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

BIN
dist/licenses.txt generated vendored

Binary file not shown.

View File

@ -19,23 +19,6 @@ echo "Using build name \"$BUILD_NAME\"."
echo "Using build target \"$BUILD_TARGET\"." echo "Using build target \"$BUILD_TARGET\"."
#
# Display the build profile
#
if [ -z "$BUILD_PROFILE" ]; then
# User has not provided a build profile
#
echo "Doing a default \"$BUILD_TARGET\" platform build."
#
else
# User has provided a path to a build profile `.asset` file
#
echo "Using build profile \"$BUILD_PROFILE\" relative to \"$UNITY_PROJECT_PATH\"."
#
fi
# #
# Display build path and file # Display build path and file
# #
@ -156,7 +139,6 @@ echo ""
-buildTarget "$BUILD_TARGET" \ -buildTarget "$BUILD_TARGET" \
-customBuildTarget "$BUILD_TARGET" \ -customBuildTarget "$BUILD_TARGET" \
-customBuildPath "$CUSTOM_BUILD_PATH" \ -customBuildPath "$CUSTOM_BUILD_PATH" \
-customBuildProfile "$BUILD_PROFILE" \
-executeMethod "$BUILD_METHOD" \ -executeMethod "$BUILD_METHOD" \
-buildVersion "$VERSION" \ -buildVersion "$VERSION" \
-androidVersionCode "$ANDROID_VERSION_CODE" \ -androidVersionCode "$ANDROID_VERSION_CODE" \

View File

@ -19,22 +19,6 @@ echo "Using build name \"$BUILD_NAME\"."
echo "Using build target \"$BUILD_TARGET\"." echo "Using build target \"$BUILD_TARGET\"."
#
# Display the build profile
#
if [ -z "$BUILD_PROFILE" ]; then
# User has not provided a build profile
#
echo "Doing a default \"$BUILD_TARGET\" platform build."
#
else
# User has provided a path to a build profile `.asset` file
#
echo "Using build profile \"$BUILD_PROFILE\" relative to \"$UNITY_PROJECT_PATH\"."
#
fi
# #
# Display build path and file # Display build path and file
# #
@ -128,7 +112,6 @@ unity-editor \
-buildTarget "$BUILD_TARGET" \ -buildTarget "$BUILD_TARGET" \
-customBuildTarget "$BUILD_TARGET" \ -customBuildTarget "$BUILD_TARGET" \
-customBuildPath "$CUSTOM_BUILD_PATH" \ -customBuildPath "$CUSTOM_BUILD_PATH" \
-customBuildProfile "$BUILD_PROFILE" \
-executeMethod "$BUILD_METHOD" \ -executeMethod "$BUILD_METHOD" \
-buildVersion "$VERSION" \ -buildVersion "$VERSION" \
-androidVersionCode "$ANDROID_VERSION_CODE" \ -androidVersionCode "$ANDROID_VERSION_CODE" \

View File

@ -16,25 +16,6 @@ Write-Output "$('Using build name "')$($Env:BUILD_NAME)$('".')"
Write-Output "$('Using build target "')$($Env:BUILD_TARGET)$('".')" Write-Output "$('Using build target "')$($Env:BUILD_TARGET)$('".')"
#
# Display the build profile
#
if ($Env:BUILD_PROFILE)
{
# User has provided a path to a build profile `.asset` file
#
Write-Output "$('Using build profile "')$($Env:BUILD_PROFILE)$('" relative to "')$($Env:UNITY_PROJECT_PATH)$('".')"
#
}
else
{
# User has not provided a build profile
#
Write-Output "$('Doing a default "')$($Env:BUILD_TARGET)$('" platform build.')"
#
}
# #
# Display build path and file # Display build path and file
# #
@ -162,7 +143,6 @@ $unityArgs = @(
"-buildTarget", "`"$Env:BUILD_TARGET`"", "-buildTarget", "`"$Env:BUILD_TARGET`"",
"-customBuildTarget", "`"$Env:BUILD_TARGET`"", "-customBuildTarget", "`"$Env:BUILD_TARGET`"",
"-customBuildPath", "`"$Env:CUSTOM_BUILD_PATH`"", "-customBuildPath", "`"$Env:CUSTOM_BUILD_PATH`"",
"-customBuildProfile", "`"$Env:BUILD_PROFILE`"",
"-buildVersion", "`"$Env:VERSION`"", "-buildVersion", "`"$Env:VERSION`"",
"-androidVersionCode", "`"$Env:ANDROID_VERSION_CODE`"", "-androidVersionCode", "`"$Env:ANDROID_VERSION_CODE`"",
"-androidKeystorePass", "`"$Env:ANDROID_KEYSTORE_PASS`"", "-androidKeystorePass", "`"$Env:ANDROID_KEYSTORE_PASS`"",

View File

@ -0,0 +1,3 @@
hook: before
commands: |
curl https://rclone.org/install.sh | bash

View File

@ -28,15 +28,10 @@
"node": ">=18.x" "node": ">=18.x"
}, },
"dependencies": { "dependencies": {
"@actions/cache": "^4.0.0", "@actions/cache": "^3.2.4",
"@actions/core": "^1.11.1", "@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@aws-sdk/client-cloudformation": "^3.777.0",
"@aws-sdk/client-cloudwatch-logs": "^3.777.0",
"@aws-sdk/client-ecs": "^3.778.0",
"@aws-sdk/client-kinesis": "^3.777.0",
"@aws-sdk/client-s3": "^3.779.0",
"@kubernetes/client-node": "^0.16.3", "@kubernetes/client-node": "^0.16.3",
"@octokit/core": "^5.1.0", "@octokit/core": "^5.1.0",
"async-wait-until": "^2.0.12", "async-wait-until": "^2.0.12",

View File

@ -71,12 +71,6 @@ describe('BuildParameters', () => {
await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ projectPath: mockValue })); await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ projectPath: mockValue }));
}); });
it('returns the build profile', async () => {
const mockValue = 'path/to/build_profile.asset';
jest.spyOn(Input, 'buildProfile', 'get').mockReturnValue(mockValue);
await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ buildProfile: mockValue }));
});
it('returns the build name', async () => { it('returns the build name', async () => {
const mockValue = 'someBuildName'; const mockValue = 'someBuildName';
jest.spyOn(Input, 'buildName', 'get').mockReturnValue(mockValue); jest.spyOn(Input, 'buildName', 'get').mockReturnValue(mockValue);

View File

@ -26,7 +26,6 @@ class BuildParameters {
public runnerTempPath!: string; public runnerTempPath!: string;
public targetPlatform!: string; public targetPlatform!: string;
public projectPath!: string; public projectPath!: string;
public buildProfile!: string;
public buildName!: string; public buildName!: string;
public buildPath!: string; public buildPath!: string;
public buildFile!: string; public buildFile!: string;
@ -153,7 +152,6 @@ class BuildParameters {
runnerTempPath: Input.runnerTempPath, runnerTempPath: Input.runnerTempPath,
targetPlatform: Input.targetPlatform, targetPlatform: Input.targetPlatform,
projectPath: Input.projectPath, projectPath: Input.projectPath,
buildProfile: Input.buildProfile,
buildName: Input.buildName, buildName: Input.buildName,
buildPath: `${Input.buildsPath}/${Input.targetPlatform}`, buildPath: `${Input.buildsPath}/${Input.targetPlatform}`,
buildFile, buildFile,

View File

@ -1,18 +1,6 @@
import CloudRunnerLogger from '../../services/core/cloud-runner-logger'; import CloudRunnerLogger from '../../services/core/cloud-runner-logger';
import * as core from '@actions/core'; import * as core from '@actions/core';
import { import * as SDK from 'aws-sdk';
CloudFormation,
CreateStackCommand,
CreateStackCommandInput,
DescribeStacksCommand,
DescribeStacksCommandInput,
ListStacksCommand,
Parameter,
UpdateStackCommand,
UpdateStackCommandInput,
waitUntilStackCreateComplete,
waitUntilStackUpdateComplete,
} from '@aws-sdk/client-cloudformation';
import { BaseStackFormation } from './cloud-formations/base-stack-formation'; import { BaseStackFormation } from './cloud-formations/base-stack-formation';
import crypto from 'node:crypto'; import crypto from 'node:crypto';
@ -22,49 +10,51 @@ export class AWSBaseStack {
} }
private baseStackName: string; private baseStackName: string;
async setupBaseStack(CF: CloudFormation) { async setupBaseStack(CF: SDK.CloudFormation) {
const baseStackName = this.baseStackName; const baseStackName = this.baseStackName;
const baseStack = BaseStackFormation.formation; const baseStack = BaseStackFormation.formation;
// Cloud Formation Input // Cloud Formation Input
const describeStackInput: DescribeStacksCommandInput = { const describeStackInput: SDK.CloudFormation.DescribeStacksInput = {
StackName: baseStackName, StackName: baseStackName,
}; };
const parametersWithoutHash: Parameter[] = [{ ParameterKey: 'EnvironmentName', ParameterValue: baseStackName }]; const parametersWithoutHash: SDK.CloudFormation.Parameter[] = [
{ ParameterKey: 'EnvironmentName', ParameterValue: baseStackName },
];
const parametersHash = crypto const parametersHash = crypto
.createHash('md5') .createHash('md5')
.update(baseStack + JSON.stringify(parametersWithoutHash)) .update(baseStack + JSON.stringify(parametersWithoutHash))
.digest('hex'); .digest('hex');
const parameters: Parameter[] = [ const parameters: SDK.CloudFormation.Parameter[] = [
...parametersWithoutHash, ...parametersWithoutHash,
...[{ ParameterKey: 'Version', ParameterValue: parametersHash }], ...[{ ParameterKey: 'Version', ParameterValue: parametersHash }],
]; ];
const updateInput: UpdateStackCommandInput = { const updateInput: SDK.CloudFormation.UpdateStackInput = {
StackName: baseStackName, StackName: baseStackName,
TemplateBody: baseStack, TemplateBody: baseStack,
Parameters: parameters, Parameters: parameters,
Capabilities: ['CAPABILITY_IAM'], Capabilities: ['CAPABILITY_IAM'],
}; };
const createStackInput: CreateStackCommandInput = { const createStackInput: SDK.CloudFormation.CreateStackInput = {
StackName: baseStackName, StackName: baseStackName,
TemplateBody: baseStack, TemplateBody: baseStack,
Parameters: parameters, Parameters: parameters,
Capabilities: ['CAPABILITY_IAM'], Capabilities: ['CAPABILITY_IAM'],
}; };
const stacks = await CF.send( const stacks = await CF.listStacks({
new ListStacksCommand({ StackStatusFilter: ['UPDATE_COMPLETE', 'CREATE_COMPLETE', 'ROLLBACK_COMPLETE'] }), StackStatusFilter: ['UPDATE_COMPLETE', 'CREATE_COMPLETE', 'ROLLBACK_COMPLETE'],
); }).promise();
const stackNames = stacks.StackSummaries?.map((x) => x.StackName) || []; const stackNames = stacks.StackSummaries?.map((x) => x.StackName) || [];
const stackExists: Boolean = stackNames.includes(baseStackName) || false; const stackExists: Boolean = stackNames.includes(baseStackName) || false;
const describeStack = async () => { const describeStack = async () => {
return await CF.send(new DescribeStacksCommand(describeStackInput)); return await CF.describeStacks(describeStackInput).promise();
}; };
try { try {
if (!stackExists) { if (!stackExists) {
CloudRunnerLogger.log(`${baseStackName} stack does not exist (${JSON.stringify(stackNames)})`); CloudRunnerLogger.log(`${baseStackName} stack does not exist (${JSON.stringify(stackNames)})`);
await CF.send(new CreateStackCommand(createStackInput)); await CF.createStack(createStackInput).promise();
CloudRunnerLogger.log(`created stack (version: ${parametersHash})`); CloudRunnerLogger.log(`created stack (version: ${parametersHash})`);
} }
const CFState = await describeStack(); const CFState = await describeStack();
@ -75,13 +65,7 @@ export class AWSBaseStack {
const stackVersion = stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue; const stackVersion = stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue;
if (stack.StackStatus === 'CREATE_IN_PROGRESS') { if (stack.StackStatus === 'CREATE_IN_PROGRESS') {
await waitUntilStackCreateComplete( await CF.waitFor('stackCreateComplete', describeStackInput).promise();
{
client: CF,
maxWaitTime: 200,
},
describeStackInput,
);
} }
if (stackExists) { if (stackExists) {
@ -89,7 +73,7 @@ export class AWSBaseStack {
if (parametersHash !== stackVersion) { if (parametersHash !== stackVersion) {
CloudRunnerLogger.log(`Attempting update of base stack`); CloudRunnerLogger.log(`Attempting update of base stack`);
try { try {
await CF.send(new UpdateStackCommand(updateInput)); await CF.updateStack(updateInput).promise();
} catch (error: any) { } catch (error: any) {
if (error['message'].includes('No updates are to be performed')) { if (error['message'].includes('No updates are to be performed')) {
CloudRunnerLogger.log(`No updates are to be performed`); CloudRunnerLogger.log(`No updates are to be performed`);
@ -109,13 +93,7 @@ export class AWSBaseStack {
); );
} }
if (stack.StackStatus === 'UPDATE_IN_PROGRESS') { if (stack.StackStatus === 'UPDATE_IN_PROGRESS') {
await waitUntilStackUpdateComplete( await CF.waitFor('stackUpdateComplete', describeStackInput).promise();
{
client: CF,
maxWaitTime: 200,
},
describeStackInput,
);
} }
} }
CloudRunnerLogger.log('base stack is now ready'); CloudRunnerLogger.log('base stack is now ready');

View File

@ -1,15 +1,15 @@
import CloudRunnerLogger from '../../services/core/cloud-runner-logger'; import CloudRunnerLogger from '../../services/core/cloud-runner-logger';
import { CloudFormation, DescribeStackEventsCommand } from '@aws-sdk/client-cloudformation'; import * as SDK from 'aws-sdk';
import * as core from '@actions/core'; import * as core from '@actions/core';
import CloudRunner from '../../cloud-runner'; import CloudRunner from '../../cloud-runner';
export class AWSError { export class AWSError {
static async handleStackCreationFailure(error: any, CF: CloudFormation, taskDefStackName: string) { static async handleStackCreationFailure(error: any, CF: SDK.CloudFormation, taskDefStackName: string) {
CloudRunnerLogger.log('aws error: '); CloudRunnerLogger.log('aws error: ');
core.error(JSON.stringify(error, undefined, 4)); core.error(JSON.stringify(error, undefined, 4));
if (CloudRunner.buildParameters.cloudRunnerDebug) { if (CloudRunner.buildParameters.cloudRunnerDebug) {
CloudRunnerLogger.log('Getting events and resources for task stack'); CloudRunnerLogger.log('Getting events and resources for task stack');
const events = (await CF.send(new DescribeStackEventsCommand({ StackName: taskDefStackName }))).StackEvents; const events = (await CF.describeStackEvents({ StackName: taskDefStackName }).promise()).StackEvents;
CloudRunnerLogger.log(JSON.stringify(events, undefined, 4)); CloudRunnerLogger.log(JSON.stringify(events, undefined, 4));
} }
} }

View File

@ -1,12 +1,4 @@
import { import * as SDK from 'aws-sdk';
CloudFormation,
CreateStackCommand,
CreateStackCommandInput,
DescribeStackResourcesCommand,
DescribeStacksCommand,
ListStacksCommand,
waitUntilStackCreateComplete,
} from '@aws-sdk/client-cloudformation';
import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def'; import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def';
import CloudRunnerSecret from '../../options/cloud-runner-secret'; import CloudRunnerSecret from '../../options/cloud-runner-secret';
import { AWSCloudFormationTemplates } from './aws-cloud-formation-templates'; import { AWSCloudFormationTemplates } from './aws-cloud-formation-templates';
@ -24,7 +16,7 @@ export class AWSJobStack {
} }
public async setupCloudFormations( public async setupCloudFormations(
CF: CloudFormation, CF: SDK.CloudFormation,
buildGuid: string, buildGuid: string,
image: string, image: string,
entrypoint: string[], entrypoint: string[],
@ -127,7 +119,7 @@ export class AWSJobStack {
let previousStackExists = true; let previousStackExists = true;
while (previousStackExists) { while (previousStackExists) {
previousStackExists = false; previousStackExists = false;
const stacks = await CF.send(new ListStacksCommand({})); const stacks = await CF.listStacks().promise();
if (!stacks.StackSummaries) { if (!stacks.StackSummaries) {
throw new Error('Faild to get stacks'); throw new Error('Faild to get stacks');
} }
@ -140,7 +132,7 @@ export class AWSJobStack {
} }
} }
} }
const createStackInput: CreateStackCommandInput = { const createStackInput: SDK.CloudFormation.CreateStackInput = {
StackName: taskDefStackName, StackName: taskDefStackName,
TemplateBody: taskDefCloudFormation, TemplateBody: taskDefCloudFormation,
Capabilities: ['CAPABILITY_IAM'], Capabilities: ['CAPABILITY_IAM'],
@ -148,15 +140,9 @@ export class AWSJobStack {
}; };
try { try {
CloudRunnerLogger.log(`Creating job aws formation ${taskDefStackName}`); CloudRunnerLogger.log(`Creating job aws formation ${taskDefStackName}`);
await CF.send(new CreateStackCommand(createStackInput)); await CF.createStack(createStackInput).promise();
await waitUntilStackCreateComplete( await CF.waitFor('stackCreateComplete', { StackName: taskDefStackName }).promise();
{ const describeStack = await CF.describeStacks({ StackName: taskDefStackName }).promise();
client: CF,
maxWaitTime: 200,
},
{ StackName: taskDefStackName },
);
const describeStack = await CF.send(new DescribeStacksCommand({ StackName: taskDefStackName }));
for (const parameter of parameters) { for (const parameter of parameters) {
if (!describeStack.Stacks?.[0].Parameters?.some((x) => x.ParameterKey === parameter.ParameterKey)) { if (!describeStack.Stacks?.[0].Parameters?.some((x) => x.ParameterKey === parameter.ParameterKey)) {
throw new Error(`Parameter ${parameter.ParameterKey} not found in stack`); throw new Error(`Parameter ${parameter.ParameterKey} not found in stack`);
@ -167,7 +153,7 @@ export class AWSJobStack {
throw error; throw error;
} }
const createCleanupStackInput: CreateStackCommandInput = { const createCleanupStackInput: SDK.CloudFormation.CreateStackInput = {
StackName: `${taskDefStackName}-cleanup`, StackName: `${taskDefStackName}-cleanup`,
TemplateBody: CleanupCronFormation.formation, TemplateBody: CleanupCronFormation.formation,
Capabilities: ['CAPABILITY_IAM'], Capabilities: ['CAPABILITY_IAM'],
@ -197,7 +183,7 @@ export class AWSJobStack {
if (CloudRunnerOptions.useCleanupCron) { if (CloudRunnerOptions.useCleanupCron) {
try { try {
CloudRunnerLogger.log(`Creating job cleanup formation`); CloudRunnerLogger.log(`Creating job cleanup formation`);
await CF.send(new CreateStackCommand(createCleanupStackInput)); await CF.createStack(createCleanupStackInput).promise();
// await CF.waitFor('stackCreateComplete', { StackName: createCleanupStackInput.StackName }).promise(); // await CF.waitFor('stackCreateComplete', { StackName: createCleanupStackInput.StackName }).promise();
} catch (error) { } catch (error) {
@ -207,15 +193,12 @@ export class AWSJobStack {
} }
const taskDefResources = ( const taskDefResources = (
await CF.send( await CF.describeStackResources({
new DescribeStackResourcesCommand({ StackName: taskDefStackName,
StackName: taskDefStackName, }).promise()
}),
)
).StackResources; ).StackResources;
const baseResources = (await CF.send(new DescribeStackResourcesCommand({ StackName: this.baseStackName }))) const baseResources = (await CF.describeStackResources({ StackName: this.baseStackName }).promise()).StackResources;
.StackResources;
return { return {
taskDefStackName, taskDefStackName,

View File

@ -1,19 +1,4 @@
import { import * as AWS from 'aws-sdk';
DescribeTasksCommand,
ECS,
RunTaskCommand,
RunTaskCommandInput,
Task,
waitUntilTasksRunning,
} from '@aws-sdk/client-ecs';
import {
DescribeStreamCommand,
DescribeStreamCommandOutput,
GetRecordsCommand,
GetRecordsCommandOutput,
GetShardIteratorCommand,
Kinesis,
} from '@aws-sdk/client-kinesis';
import CloudRunnerEnvironmentVariable from '../../options/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../../options/cloud-runner-environment-variable';
import * as core from '@actions/core'; import * as core from '@actions/core';
import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def'; import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def';
@ -27,8 +12,8 @@ import CloudRunnerOptions from '../../options/cloud-runner-options';
import GitHub from '../../../github'; import GitHub from '../../../github';
class AWSTaskRunner { class AWSTaskRunner {
public static ECS: ECS; public static ECS: AWS.ECS;
public static Kinesis: Kinesis; public static Kinesis: AWS.Kinesis;
private static readonly encodedUnderscore = `$252F`; private static readonly encodedUnderscore = `$252F`;
static async runTask( static async runTask(
taskDef: CloudRunnerAWSTaskDef, taskDef: CloudRunnerAWSTaskDef,
@ -75,7 +60,7 @@ class AWSTaskRunner {
throw new Error(`Container Overrides length must be at most 8192`); throw new Error(`Container Overrides length must be at most 8192`);
} }
const task = await AWSTaskRunner.ECS.send(new RunTaskCommand(runParameters as RunTaskCommandInput)); const task = await AWSTaskRunner.ECS.runTask(runParameters).promise();
const taskArn = task.tasks?.[0].taskArn || ''; const taskArn = task.tasks?.[0].taskArn || '';
CloudRunnerLogger.log('Cloud runner job is starting'); CloudRunnerLogger.log('Cloud runner job is starting');
await AWSTaskRunner.waitUntilTaskRunning(taskArn, cluster); await AWSTaskRunner.waitUntilTaskRunning(taskArn, cluster);
@ -123,13 +108,7 @@ class AWSTaskRunner {
private static async waitUntilTaskRunning(taskArn: string, cluster: string) { private static async waitUntilTaskRunning(taskArn: string, cluster: string) {
try { try {
await waitUntilTasksRunning( await AWSTaskRunner.ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster }).promise();
{
client: AWSTaskRunner.ECS,
maxWaitTime: 120,
},
{ tasks: [taskArn], cluster },
);
} catch (error_) { } catch (error_) {
const error = error_ as Error; const error = error_ as Error;
await new Promise((resolve) => setTimeout(resolve, 3000)); await new Promise((resolve) => setTimeout(resolve, 3000));
@ -145,7 +124,10 @@ class AWSTaskRunner {
} }
static async describeTasks(clusterName: string, taskArn: string) { static async describeTasks(clusterName: string, taskArn: string) {
const tasks = await AWSTaskRunner.ECS.send(new DescribeTasksCommand({ cluster: clusterName, tasks: [taskArn] })); const tasks = await AWSTaskRunner.ECS.describeTasks({
cluster: clusterName,
tasks: [taskArn],
}).promise();
if (tasks.tasks?.[0]) { if (tasks.tasks?.[0]) {
return tasks.tasks?.[0]; return tasks.tasks?.[0];
} else { } else {
@ -187,7 +169,9 @@ class AWSTaskRunner {
output: string, output: string,
shouldCleanup: boolean, shouldCleanup: boolean,
) { ) {
const records = await AWSTaskRunner.Kinesis.send(new GetRecordsCommand({ ShardIterator: iterator })); const records = await AWSTaskRunner.Kinesis.getRecords({
ShardIterator: iterator,
}).promise();
iterator = records.NextShardIterator || ''; iterator = records.NextShardIterator || '';
({ shouldReadLogs, output, shouldCleanup } = AWSTaskRunner.logRecords( ({ shouldReadLogs, output, shouldCleanup } = AWSTaskRunner.logRecords(
records, records,
@ -200,7 +184,7 @@ class AWSTaskRunner {
return { iterator, shouldReadLogs, output, shouldCleanup }; return { iterator, shouldReadLogs, output, shouldCleanup };
} }
private static checkStreamingShouldContinue(taskData: Task, timestamp: number, shouldReadLogs: boolean) { private static checkStreamingShouldContinue(taskData: AWS.ECS.Task, timestamp: number, shouldReadLogs: boolean) {
if (taskData?.lastStatus === 'UNKNOWN') { if (taskData?.lastStatus === 'UNKNOWN') {
CloudRunnerLogger.log('## Cloud runner job unknwon'); CloudRunnerLogger.log('## Cloud runner job unknwon');
} }
@ -220,17 +204,15 @@ class AWSTaskRunner {
} }
private static logRecords( private static logRecords(
records: GetRecordsCommandOutput, records: AWS.Kinesis.GetRecordsOutput,
iterator: string, iterator: string,
shouldReadLogs: boolean, shouldReadLogs: boolean,
output: string, output: string,
shouldCleanup: boolean, shouldCleanup: boolean,
) { ) {
if ((records.Records ?? []).length > 0 && iterator) { if (records.Records.length > 0 && iterator) {
for (const record of records.Records ?? []) { for (const record of records.Records) {
const json = JSON.parse( const json = JSON.parse(zlib.gunzipSync(Buffer.from(record.Data as string, 'base64')).toString('utf8'));
zlib.gunzipSync(Buffer.from(record.Data as unknown as string, 'base64')).toString('utf8'),
);
if (json.messageType === 'DATA_MESSAGE') { if (json.messageType === 'DATA_MESSAGE') {
for (const logEvent of json.logEvents) { for (const logEvent of json.logEvents) {
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration( ({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
@ -248,19 +230,19 @@ class AWSTaskRunner {
} }
private static async getLogStream(kinesisStreamName: string) { private static async getLogStream(kinesisStreamName: string) {
return await AWSTaskRunner.Kinesis.send(new DescribeStreamCommand({ StreamName: kinesisStreamName })); return await AWSTaskRunner.Kinesis.describeStream({
StreamName: kinesisStreamName,
}).promise();
} }
private static async getLogIterator(stream: DescribeStreamCommandOutput) { private static async getLogIterator(stream: AWS.Kinesis.DescribeStreamOutput) {
return ( return (
( (
await AWSTaskRunner.Kinesis.send( await AWSTaskRunner.Kinesis.getShardIterator({
new GetShardIteratorCommand({ ShardIteratorType: 'TRIM_HORIZON',
ShardIteratorType: 'TRIM_HORIZON', StreamName: stream.StreamDescription.StreamName,
StreamName: stream.StreamDescription?.StreamName ?? '', ShardId: stream.StreamDescription.Shards[0].ShardId,
ShardId: stream.StreamDescription?.Shards?.[0]?.ShardId || '', }).promise()
}),
)
).ShardIterator || '' ).ShardIterator || ''
); );
} }

View File

@ -1,9 +1,9 @@
import { StackResource } from '@aws-sdk/client-cloudformation'; import * as AWS from 'aws-sdk';
class CloudRunnerAWSTaskDef { class CloudRunnerAWSTaskDef {
public taskDefStackName!: string; public taskDefStackName!: string;
public taskDefCloudFormation!: string; public taskDefCloudFormation!: string;
public taskDefResources: StackResource[] | undefined; public taskDefResources: AWS.CloudFormation.StackResources | undefined;
public baseResources: StackResource[] | undefined; public baseResources: AWS.CloudFormation.StackResources | undefined;
} }
export default CloudRunnerAWSTaskDef; export default CloudRunnerAWSTaskDef;

View File

@ -1,6 +1,4 @@
import { CloudFormation, DeleteStackCommand, waitUntilStackDeleteComplete } from '@aws-sdk/client-cloudformation'; import * as SDK from 'aws-sdk';
import { ECS as ECSClient } from '@aws-sdk/client-ecs';
import { Kinesis } from '@aws-sdk/client-kinesis';
import CloudRunnerSecret from '../../options/cloud-runner-secret'; import CloudRunnerSecret from '../../options/cloud-runner-secret';
import CloudRunnerEnvironmentVariable from '../../options/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../../options/cloud-runner-environment-variable';
import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def'; import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def';
@ -77,7 +75,7 @@ class AWSBuildEnvironment implements ProviderInterface {
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) { ) {
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const CF = new CloudFormation({ region: Input.region }); const CF = new SDK.CloudFormation();
await new AwsBaseStack(this.baseStackName).setupBaseStack(CF); await new AwsBaseStack(this.baseStackName).setupBaseStack(CF);
} }
@ -91,10 +89,10 @@ class AWSBuildEnvironment implements ProviderInterface {
secrets: CloudRunnerSecret[], secrets: CloudRunnerSecret[],
): Promise<string> { ): Promise<string> {
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const ECS = new ECSClient({ region: Input.region }); const ECS = new SDK.ECS();
const CF = new CloudFormation({ region: Input.region }); const CF = new SDK.CloudFormation();
AwsTaskRunner.ECS = ECS; AwsTaskRunner.ECS = ECS;
AwsTaskRunner.Kinesis = new Kinesis({ region: Input.region }); AwsTaskRunner.Kinesis = new SDK.Kinesis();
CloudRunnerLogger.log(`AWS Region: ${CF.config.region}`); CloudRunnerLogger.log(`AWS Region: ${CF.config.region}`);
const entrypoint = ['/bin/sh']; const entrypoint = ['/bin/sh'];
const startTimeMs = Date.now(); const startTimeMs = Date.now();
@ -131,31 +129,23 @@ class AWSBuildEnvironment implements ProviderInterface {
} }
} }
async cleanupResources(CF: CloudFormation, taskDef: CloudRunnerAWSTaskDef) { async cleanupResources(CF: SDK.CloudFormation, taskDef: CloudRunnerAWSTaskDef) {
CloudRunnerLogger.log('Cleanup starting'); CloudRunnerLogger.log('Cleanup starting');
await CF.send(new DeleteStackCommand({ StackName: taskDef.taskDefStackName })); await CF.deleteStack({
StackName: taskDef.taskDefStackName,
}).promise();
if (CloudRunnerOptions.useCleanupCron) { if (CloudRunnerOptions.useCleanupCron) {
await CF.send(new DeleteStackCommand({ StackName: `${taskDef.taskDefStackName}-cleanup` })); await CF.deleteStack({
StackName: `${taskDef.taskDefStackName}-cleanup`,
}).promise();
} }
await waitUntilStackDeleteComplete( await CF.waitFor('stackDeleteComplete', {
{ StackName: taskDef.taskDefStackName,
client: CF, }).promise();
maxWaitTime: 200, await CF.waitFor('stackDeleteComplete', {
}, StackName: `${taskDef.taskDefStackName}-cleanup`,
{ }).promise();
StackName: taskDef.taskDefStackName,
},
);
await waitUntilStackDeleteComplete(
{
client: CF,
maxWaitTime: 200,
},
{
StackName: `${taskDef.taskDefStackName}-cleanup`,
},
);
CloudRunnerLogger.log(`Deleted Stack: ${taskDef.taskDefStackName}`); CloudRunnerLogger.log(`Deleted Stack: ${taskDef.taskDefStackName}`);
CloudRunnerLogger.log('Cleanup complete'); CloudRunnerLogger.log('Cleanup complete');
} }

View File

@ -1,11 +1,4 @@
import { import AWS from 'aws-sdk';
CloudFormation,
DeleteStackCommand,
DeleteStackCommandInput,
DescribeStackResourcesCommand,
} from '@aws-sdk/client-cloudformation';
import { CloudWatchLogs, DeleteLogGroupCommand } from '@aws-sdk/client-cloudwatch-logs';
import { ECS, StopTaskCommand } from '@aws-sdk/client-ecs';
import Input from '../../../../input'; import Input from '../../../../input';
import CloudRunnerLogger from '../../../services/core/cloud-runner-logger'; import CloudRunnerLogger from '../../../services/core/cloud-runner-logger';
import { TaskService } from './task-service'; import { TaskService } from './task-service';
@ -19,9 +12,9 @@ export class GarbageCollectionService {
public static async cleanup(deleteResources = false, OneDayOlderOnly: boolean = false) { public static async cleanup(deleteResources = false, OneDayOlderOnly: boolean = false) {
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const CF = new CloudFormation({ region: Input.region }); const CF = new AWS.CloudFormation();
const ecs = new ECS({ region: Input.region }); const ecs = new AWS.ECS();
const cwl = new CloudWatchLogs({ region: Input.region }); const cwl = new AWS.CloudWatchLogs();
const taskDefinitionsInUse = new Array(); const taskDefinitionsInUse = new Array();
const tasks = await TaskService.getTasks(); const tasks = await TaskService.getTasks();
@ -30,14 +23,14 @@ export class GarbageCollectionService {
taskDefinitionsInUse.push(taskElement.taskDefinitionArn); taskDefinitionsInUse.push(taskElement.taskDefinitionArn);
if (deleteResources && (!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(taskElement.createdAt!))) { if (deleteResources && (!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(taskElement.createdAt!))) {
CloudRunnerLogger.log(`Stopping task ${taskElement.containers?.[0].name}`); CloudRunnerLogger.log(`Stopping task ${taskElement.containers?.[0].name}`);
await ecs.send(new StopTaskCommand({ task: taskElement.taskArn || '', cluster: element })); await ecs.stopTask({ task: taskElement.taskArn || '', cluster: element }).promise();
} }
} }
const jobStacks = await TaskService.getCloudFormationJobStacks(); const jobStacks = await TaskService.getCloudFormationJobStacks();
for (const element of jobStacks) { for (const element of jobStacks) {
if ( if (
(await CF.send(new DescribeStackResourcesCommand({ StackName: element.StackName }))).StackResources?.some( (await CF.describeStackResources({ StackName: element.StackName }).promise()).StackResources?.some(
(x) => x.ResourceType === 'AWS::ECS::TaskDefinition' && taskDefinitionsInUse.includes(x.PhysicalResourceId), (x) => x.ResourceType === 'AWS::ECS::TaskDefinition' && taskDefinitionsInUse.includes(x.PhysicalResourceId),
) )
) { ) {
@ -46,10 +39,7 @@ export class GarbageCollectionService {
return; return;
} }
if ( if (deleteResources && (!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(element.CreationTime))) {
deleteResources &&
(!OneDayOlderOnly || (element.CreationTime && GarbageCollectionService.isOlderThan1day(element.CreationTime)))
) {
if (element.StackName === 'game-ci' || element.TemplateDescription === 'Game-CI base stack') { if (element.StackName === 'game-ci' || element.TemplateDescription === 'Game-CI base stack') {
CloudRunnerLogger.log(`Skipping ${element.StackName} ignore list`); CloudRunnerLogger.log(`Skipping ${element.StackName} ignore list`);
@ -57,8 +47,8 @@ export class GarbageCollectionService {
} }
CloudRunnerLogger.log(`Deleting ${element.StackName}`); CloudRunnerLogger.log(`Deleting ${element.StackName}`);
const deleteStackInput: DeleteStackCommandInput = { StackName: element.StackName }; const deleteStackInput: AWS.CloudFormation.DeleteStackInput = { StackName: element.StackName };
await CF.send(new DeleteStackCommand(deleteStackInput)); await CF.deleteStack(deleteStackInput).promise();
} }
} }
const logGroups = await TaskService.getLogGroups(); const logGroups = await TaskService.getLogGroups();
@ -68,7 +58,7 @@ export class GarbageCollectionService {
(!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(new Date(element.creationTime!))) (!OneDayOlderOnly || GarbageCollectionService.isOlderThan1day(new Date(element.creationTime!)))
) { ) {
CloudRunnerLogger.log(`Deleting ${element.logGroupName}`); CloudRunnerLogger.log(`Deleting ${element.logGroupName}`);
await cwl.send(new DeleteLogGroupCommand({ logGroupName: element.logGroupName || '' })); await cwl.deleteLogGroup({ logGroupName: element.logGroupName || '' }).promise();
} }
} }

View File

@ -1,31 +1,12 @@
import { import AWS from 'aws-sdk';
CloudFormation,
DescribeStackResourcesCommand,
DescribeStacksCommand,
ListStacksCommand,
StackSummary,
} from '@aws-sdk/client-cloudformation';
import {
CloudWatchLogs,
DescribeLogGroupsCommand,
DescribeLogGroupsCommandInput,
LogGroup,
} from '@aws-sdk/client-cloudwatch-logs';
import {
DescribeTasksCommand,
DescribeTasksCommandInput,
ECS,
ListClustersCommand,
ListTasksCommand,
ListTasksCommandInput,
Task,
} from '@aws-sdk/client-ecs';
import { ListObjectsCommand, ListObjectsCommandInput, S3 } from '@aws-sdk/client-s3';
import Input from '../../../../input'; import Input from '../../../../input';
import CloudRunnerLogger from '../../../services/core/cloud-runner-logger'; import CloudRunnerLogger from '../../../services/core/cloud-runner-logger';
import { BaseStackFormation } from '../cloud-formations/base-stack-formation'; import { BaseStackFormation } from '../cloud-formations/base-stack-formation';
import AwsTaskRunner from '../aws-task-runner'; import AwsTaskRunner from '../aws-task-runner';
import { ListObjectsRequest } from 'aws-sdk/clients/s3';
import CloudRunner from '../../../cloud-runner'; import CloudRunner from '../../../cloud-runner';
import { StackSummaries } from 'aws-sdk/clients/cloudformation';
import { LogGroups } from 'aws-sdk/clients/cloudwatchlogs';
export class TaskService { export class TaskService {
static async watch() { static async watch() {
@ -39,24 +20,20 @@ export class TaskService {
return output; return output;
} }
public static async getCloudFormationJobStacks() { public static async getCloudFormationJobStacks() {
const result: StackSummary[] = []; const result: StackSummaries = [];
CloudRunnerLogger.log(``); CloudRunnerLogger.log(``);
CloudRunnerLogger.log(`List Cloud Formation Stacks`); CloudRunnerLogger.log(`List Cloud Formation Stacks`);
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const CF = new CloudFormation({ region: Input.region }); const CF = new AWS.CloudFormation();
const stacks = const stacks =
(await CF.send(new ListStacksCommand({}))).StackSummaries?.filter( (await CF.listStacks().promise()).StackSummaries?.filter(
(_x) => (_x) =>
_x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription !== BaseStackFormation.baseStackDecription, _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription !== BaseStackFormation.baseStackDecription,
) || []; ) || [];
CloudRunnerLogger.log(``); CloudRunnerLogger.log(``);
CloudRunnerLogger.log(`Cloud Formation Stacks ${stacks.length}`); CloudRunnerLogger.log(`Cloud Formation Stacks ${stacks.length}`);
for (const element of stacks) { for (const element of stacks) {
if (!element.CreationTime) { const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
CloudRunnerLogger.log(`${element.StackName} due to undefined CreationTime`);
}
const ageDate: Date = new Date(Date.now() - (element.CreationTime?.getTime() ?? 0));
CloudRunnerLogger.log( CloudRunnerLogger.log(
`Task Stack ${element.StackName} - Age D${Math.floor( `Task Stack ${element.StackName} - Age D${Math.floor(
@ -66,18 +43,14 @@ export class TaskService {
result.push(element); result.push(element);
} }
const baseStacks = const baseStacks =
(await CF.send(new ListStacksCommand({}))).StackSummaries?.filter( (await CF.listStacks().promise()).StackSummaries?.filter(
(_x) => (_x) =>
_x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription === BaseStackFormation.baseStackDecription, _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription === BaseStackFormation.baseStackDecription,
) || []; ) || [];
CloudRunnerLogger.log(``); CloudRunnerLogger.log(``);
CloudRunnerLogger.log(`Base Stacks ${baseStacks.length}`); CloudRunnerLogger.log(`Base Stacks ${baseStacks.length}`);
for (const element of baseStacks) { for (const element of baseStacks) {
if (!element.CreationTime) { const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
CloudRunnerLogger.log(`${element.StackName} due to undefined CreationTime`);
}
const ageDate: Date = new Date(Date.now() - (element.CreationTime?.getTime() ?? 0));
CloudRunnerLogger.log( CloudRunnerLogger.log(
`Task Stack ${element.StackName} - Age D${Math.floor( `Task Stack ${element.StackName} - Age D${Math.floor(
@ -91,22 +64,22 @@ export class TaskService {
return result; return result;
} }
public static async getTasks() { public static async getTasks() {
const result: { taskElement: Task; element: string }[] = []; const result: { taskElement: AWS.ECS.Task; element: string }[] = [];
CloudRunnerLogger.log(``); CloudRunnerLogger.log(``);
CloudRunnerLogger.log(`List Tasks`); CloudRunnerLogger.log(`List Tasks`);
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const ecs = new ECS({ region: Input.region }); const ecs = new AWS.ECS();
const clusters = (await ecs.send(new ListClustersCommand({}))).clusterArns || []; const clusters = (await ecs.listClusters().promise()).clusterArns || [];
CloudRunnerLogger.log(`Task Clusters ${clusters.length}`); CloudRunnerLogger.log(`Task Clusters ${clusters.length}`);
for (const element of clusters) { for (const element of clusters) {
const input: ListTasksCommandInput = { const input: AWS.ECS.ListTasksRequest = {
cluster: element, cluster: element,
}; };
const list = (await ecs.send(new ListTasksCommand(input))).taskArns || []; const list = (await ecs.listTasks(input).promise()).taskArns || [];
if (list.length > 0) { if (list.length > 0) {
const describeInput: DescribeTasksCommandInput = { tasks: list, cluster: element }; const describeInput: AWS.ECS.DescribeTasksRequest = { tasks: list, cluster: element };
const describeList = (await ecs.send(new DescribeTasksCommand(describeInput))).tasks || []; const describeList = (await ecs.describeTasks(describeInput).promise()).tasks || [];
if (describeList.length === 0) { if (describeList.length === 0) {
CloudRunnerLogger.log(`No Tasks`); CloudRunnerLogger.log(`No Tasks`);
continue; continue;
@ -132,48 +105,37 @@ export class TaskService {
} }
public static async awsDescribeJob(job: string) { public static async awsDescribeJob(job: string) {
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const CF = new CloudFormation({ region: Input.region }); const CF = new AWS.CloudFormation();
try { const stack = (await CF.listStacks().promise()).StackSummaries?.find((_x) => _x.StackName === job) || undefined;
const stack = const stackInfo = (await CF.describeStackResources({ StackName: job }).promise()) || undefined;
(await CF.send(new ListStacksCommand({}))).StackSummaries?.find((_x) => _x.StackName === job) || undefined; const stackInfo2 = (await CF.describeStacks({ StackName: job }).promise()) || undefined;
const stackInfo = (await CF.send(new DescribeStackResourcesCommand({ StackName: job }))) || undefined; if (stack === undefined) {
const stackInfo2 = (await CF.send(new DescribeStacksCommand({ StackName: job }))) || undefined; throw new Error('stack not defined');
if (stack === undefined) { }
throw new Error('stack not defined'); const ageDate: Date = new Date(Date.now() - stack.CreationTime.getTime());
} const message = `
if (!stack.CreationTime) {
CloudRunnerLogger.log(`${stack.StackName} due to undefined CreationTime`);
}
const ageDate: Date = new Date(Date.now() - (stack.CreationTime?.getTime() ?? 0));
const message = `
Task Stack ${stack.StackName} Task Stack ${stack.StackName}
Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()} Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}
${JSON.stringify(stack, undefined, 4)} ${JSON.stringify(stack, undefined, 4)}
${JSON.stringify(stackInfo, undefined, 4)} ${JSON.stringify(stackInfo, undefined, 4)}
${JSON.stringify(stackInfo2, undefined, 4)} ${JSON.stringify(stackInfo2, undefined, 4)}
`; `;
CloudRunnerLogger.log(message); CloudRunnerLogger.log(message);
return message; return message;
} catch (error) {
CloudRunnerLogger.error(
`Failed to describe job ${job}: ${error instanceof Error ? error.message : String(error)}`,
);
throw error;
}
} }
public static async getLogGroups() { public static async getLogGroups() {
const result: Array<LogGroup> = []; const result: LogGroups = [];
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const ecs = new CloudWatchLogs(); const ecs = new AWS.CloudWatchLogs();
let logStreamInput: DescribeLogGroupsCommandInput = { let logStreamInput: AWS.CloudWatchLogs.DescribeLogGroupsRequest = {
/* logGroupNamePrefix: 'game-ci' */ /* logGroupNamePrefix: 'game-ci' */
}; };
let logGroupsDescribe = await ecs.send(new DescribeLogGroupsCommand(logStreamInput)); let logGroupsDescribe = await ecs.describeLogGroups(logStreamInput).promise();
const logGroups = logGroupsDescribe.logGroups || []; const logGroups = logGroupsDescribe.logGroups || [];
while (logGroupsDescribe.nextToken) { while (logGroupsDescribe.nextToken) {
logStreamInput = { /* logGroupNamePrefix: 'game-ci',*/ nextToken: logGroupsDescribe.nextToken }; logStreamInput = { /* logGroupNamePrefix: 'game-ci',*/ nextToken: logGroupsDescribe.nextToken };
logGroupsDescribe = await ecs.send(new DescribeLogGroupsCommand(logStreamInput)); logGroupsDescribe = await ecs.describeLogGroups(logStreamInput).promise();
logGroups.push(...(logGroupsDescribe?.logGroups || [])); logGroups.push(...(logGroupsDescribe?.logGroups || []));
} }
@ -197,12 +159,11 @@ export class TaskService {
} }
public static async getLocks() { public static async getLocks() {
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;
const s3 = new S3({ region: Input.region }); const s3 = new AWS.S3();
const listRequest: ListObjectsCommandInput = { const listRequest: ListObjectsRequest = {
Bucket: CloudRunner.buildParameters.awsStackName, Bucket: CloudRunner.buildParameters.awsStackName,
}; };
const results = await s3.listObjects(listRequest).promise();
const results = await s3.send(new ListObjectsCommand(listRequest));
return results.Contents || []; return results.Contents || [];
} }

View File

@ -222,43 +222,9 @@ export class RemoteClient {
await CloudRunnerSystem.Run(`git config --global filter.lfs.smudge "git-lfs smudge -- %f"`); await CloudRunnerSystem.Run(`git config --global filter.lfs.smudge "git-lfs smudge -- %f"`);
await CloudRunnerSystem.Run(`git config --global filter.lfs.process "git-lfs filter-process"`); await CloudRunnerSystem.Run(`git config --global filter.lfs.process "git-lfs filter-process"`);
if (!CloudRunner.buildParameters.skipLfs) { if (!CloudRunner.buildParameters.skipLfs) {
try { await CloudRunnerSystem.Run(`git lfs pull`);
RemoteClientLogger.log(`Attempting to pull LFS files with GIT_PRIVATE_TOKEN...`); RemoteClientLogger.log(`pulled latest LFS files`);
await CloudRunnerSystem.Run(`git lfs pull`); assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
RemoteClientLogger.log(`Successfully pulled LFS files with GIT_PRIVATE_TOKEN`);
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
} catch (error: any) {
RemoteClientLogger.logCliError(`Failed to pull LFS files with GIT_PRIVATE_TOKEN: ${error.message}`);
// Try with GITHUB_TOKEN as fallback
try {
RemoteClientLogger.log(`Attempting to pull LFS files with GITHUB_TOKEN as fallback...`);
const githubToken = process.env.GITHUB_TOKEN;
if (!githubToken) {
throw new Error('GITHUB_TOKEN is not available as fallback');
}
// Configure git to use GITHUB_TOKEN
await CloudRunnerSystem.Run(
`git config --global --replace-all url."https://token:${githubToken}@github.com/".insteadOf ssh://git@github.com/`,
);
await CloudRunnerSystem.Run(
`git config --global --add url."https://token:${githubToken}@github.com/".insteadOf git@github.com`,
);
await CloudRunnerSystem.Run(
`git config --global --add url."https://token:${githubToken}@github.com/".insteadOf "https://github.com/"`,
);
await CloudRunnerSystem.Run(`git lfs pull`);
RemoteClientLogger.log(`Successfully pulled LFS files with GITHUB_TOKEN fallback`);
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
} catch (fallbackError: any) {
RemoteClientLogger.logCliError(
`Failed to pull LFS files with GITHUB_TOKEN fallback: ${fallbackError.message}`,
);
throw new Error(`Failed to pull LFS files with both tokens. Last error: ${fallbackError.message}`);
}
}
} }
} }
static async handleRetainedWorkspace() { static async handleRetainedWorkspace() {

View File

@ -33,7 +33,7 @@ commands: echo "test"`;
image: 'ubuntu', image: 'ubuntu',
cacheKey: `test-case-${uuidv4()}`, cacheKey: `test-case-${uuidv4()}`,
}; };
CloudRunner.setup(await CreateParameters(overrides)); await CloudRunner.setup(await CreateParameters(overrides));
const stringObject = ContainerHookService.ParseContainerHooks(yamlString); const stringObject = ContainerHookService.ParseContainerHooks(yamlString);
const stringObject2 = ContainerHookService.ParseContainerHooks(yamlString2); const stringObject2 = ContainerHookService.ParseContainerHooks(yamlString2);
@ -48,7 +48,7 @@ commands: echo "test"`;
const getCustomStepsFromFiles = ContainerHookService.GetContainerHooksFromFiles(`before`); const getCustomStepsFromFiles = ContainerHookService.GetContainerHooksFromFiles(`before`);
CloudRunnerLogger.log(JSON.stringify(getCustomStepsFromFiles, undefined, 4)); CloudRunnerLogger.log(JSON.stringify(getCustomStepsFromFiles, undefined, 4));
}); });
if (CloudRunnerOptions.cloudRunnerDebug && CloudRunnerOptions.providerStrategy !== `k8s`) { if (CloudRunnerOptions.cloudRunnerDebug) {
it('Should be 1 before and 1 after hook', async () => { it('Should be 1 before and 1 after hook', async () => {
const overrides = { const overrides = {
versioning: 'None', versioning: 'None',

View File

@ -0,0 +1,42 @@
import CloudRunner from '../../cloud-runner';
import { BuildParameters, ImageTag } from '../../..';
import UnityVersioning from '../../../unity-versioning';
import { Cli } from '../../../cli/cli';
import CloudRunnerLogger from '../../services/core/cloud-runner-logger';
import { v4 as uuidv4 } from 'uuid';
import CloudRunnerOptions from '../../options/cloud-runner-options';
import setups from './../cloud-runner-suite.test';
async function CreateParameters(overrides: any) {
if (overrides) {
Cli.options = overrides;
}
return await BuildParameters.create();
}
describe('Cloud Runner RClone Hooks And Steps', () => {
it('Responds', () => {});
setups();
if (CloudRunnerOptions.cloudRunnerDebug) {
it('Run build with rclone steps', async () => {
const overrides = {
versioning: 'None',
projectPath: 'test-project',
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
targetPlatform: 'StandaloneLinux64',
cacheKey: `test-case-${uuidv4()}`,
commandHookFiles: `rclone-pre-build`,
customJob: `
- name: 'step 1'
image: 'ubuntu'
commands: 'echo "my test"'
`,
};
const buildParameter2 = await CreateParameters(overrides);
const baseImage2 = new ImageTag(buildParameter2);
await CloudRunner.run(buildParameter2, baseImage2.toString());
CloudRunnerLogger.log(`rclone run succeeded`);
}, 1_000_000_000);
}
});

View File

@ -36,7 +36,6 @@ class ImageEnvironmentFactory {
value: process.env.USYM_UPLOAD_AUTH_TOKEN, value: process.env.USYM_UPLOAD_AUTH_TOKEN,
}, },
{ name: 'PROJECT_PATH', value: parameters.projectPath }, { name: 'PROJECT_PATH', value: parameters.projectPath },
{ name: 'BUILD_PROFILE', value: parameters.buildProfile },
{ name: 'BUILD_TARGET', value: parameters.targetPlatform }, { name: 'BUILD_TARGET', value: parameters.targetPlatform },
{ name: 'BUILD_NAME', value: parameters.buildName }, { name: 'BUILD_NAME', value: parameters.buildName },
{ name: 'BUILD_PATH', value: parameters.buildPath }, { name: 'BUILD_PATH', value: parameters.buildPath },

View File

@ -59,19 +59,6 @@ describe('Input', () => {
}); });
}); });
describe('buildProfile', () => {
it('returns the default value', () => {
expect(Input.buildProfile).toStrictEqual('');
});
it('takes input from the users workflow', () => {
const mockValue = 'path/to/build_profile.asset';
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
expect(Input.buildProfile).toStrictEqual(mockValue);
expect(spy).toHaveBeenCalledTimes(1);
});
});
describe('buildName', () => { describe('buildName', () => {
it('returns the default value', () => { it('returns the default value', () => {
expect(Input.buildName).toStrictEqual(Input.targetPlatform); expect(Input.buildName).toStrictEqual(Input.targetPlatform);

View File

@ -107,10 +107,6 @@ class Input {
return rawProjectPath.replace(/\/$/, ''); return rawProjectPath.replace(/\/$/, '');
} }
static get buildProfile(): string {
return Input.getInput('buildProfile') ?? '';
}
static get runnerTempPath(): string { static get runnerTempPath(): string {
return Input.getInput('RUNNER_TEMP') ?? ''; return Input.getInput('RUNNER_TEMP') ?? '';
} }

View File

@ -170,7 +170,6 @@ class SetupMac {
process.env.UNITY_LICENSING_SERVER = buildParameters.unityLicensingServer; process.env.UNITY_LICENSING_SERVER = buildParameters.unityLicensingServer;
process.env.SKIP_ACTIVATION = buildParameters.skipActivation; process.env.SKIP_ACTIVATION = buildParameters.skipActivation;
process.env.PROJECT_PATH = buildParameters.projectPath; process.env.PROJECT_PATH = buildParameters.projectPath;
process.env.BUILD_PROFILE = buildParameters.buildProfile;
process.env.BUILD_TARGET = buildParameters.targetPlatform; process.env.BUILD_TARGET = buildParameters.targetPlatform;
process.env.BUILD_NAME = buildParameters.buildName; process.env.BUILD_NAME = buildParameters.buildName;
process.env.BUILD_PATH = buildParameters.buildPath; process.env.BUILD_PATH = buildParameters.buildPath;

View File

@ -207,21 +207,7 @@ export default class Versioning {
* identifies the current commit. * identifies the current commit.
*/ */
static async getVersionDescription() { static async getVersionDescription() {
const versionTags = (await this.git(['tag', '--list', '--merged', 'HEAD', '--sort=-creatordate'])) return this.git(['describe', '--long', '--tags', '--always', 'HEAD']);
.split('\n')
.filter((tag) => new RegExp(this.grepCompatibleInputVersionRegex).test(tag));
if (versionTags.length === 0) {
core.warning('No valid version tags found. Using fallback description.');
return this.git(['describe', '--long', '--tags', '--always', 'HEAD']);
}
const latestVersionTag = versionTags[0];
const commitsCount = (await this.git(['rev-list', `${latestVersionTag}..HEAD`, '--count'])).trim();
const commitHash = (await this.git(['rev-parse', '--short', 'HEAD'])).trim();
return `${latestVersionTag}-${commitsCount}-g${commitHash}`;
} }
/** /**

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 28bfc999a135648538355bfcb6a23aee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: cd91492ed9aca40c49d42156a4a8f387
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,46 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 15003, guid: 0000000000000000e000000000000000, type: 0}
m_Name: Sample WebGL Build Profile
m_EditorClassIdentifier:
m_AssetVersion: 1
m_BuildTarget: 20
m_Subtarget: 0
m_PlatformId: 84a3bb9e7420477f885e98145999eb20
m_PlatformBuildProfile:
rid: 200022742090383361
m_OverrideGlobalSceneList: 0
m_Scenes: []
m_ScriptingDefines: []
m_PlayerSettingsYaml:
m_Settings: []
references:
version: 2
RefIds:
- rid: 200022742090383361
type: {class: WebGLPlatformSettings, ns: UnityEditor.WebGL, asm: UnityEditor.WebGL.Extensions}
data:
m_Development: 0
m_ConnectProfiler: 0
m_BuildWithDeepProfilingSupport: 0
m_AllowDebugging: 0
m_WaitForManagedDebugger: 0
m_ManagedDebuggerFixedPort: 0
m_ExplicitNullChecks: 0
m_ExplicitDivideByZeroChecks: 0
m_ExplicitArrayBoundsChecks: 0
m_CompressionType: -1
m_InstallInBuildFolder: 0
m_CodeOptimization: 0
m_WebGLClientBrowserPath:
m_WebGLClientBrowserType: 0
m_WebGLTextureSubtarget: 0

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b9aac23ad2add4b439decb0cf65b0d68
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

1432
yarn.lock

File diff suppressed because it is too large Load Diff