2020-01-20 23:06:14 +00:00
|
|
|
import Platform from './platform';
|
Cloud Runner v0 - Reliable and trimmed down cloud runner (#353)
* Update cloud-runner-aws-pipeline.yml
* Update cloud-runner-k8s-pipeline.yml
* yarn build
* yarn build
* correct branch ref
* correct branch ref passed to target repo
* Create k8s-tests.yml
* Delete k8s-tests.yml
* correct branch ref passed to target repo
* correct branch ref passed to target repo
* Always describe AWS tasks for now, because unstable error handling
* Remove unused tree commands
* Use lfs guid sum
* Simple override cache push
* Simple override cache push and pull override to allow pure cloud storage driven caching
* Removal of early branch (breaks lfs caching)
* Remove unused tree commands
* Update action.yml
* Update action.yml
* Support cache and input override commands as input + full support custom hooks
* Increase k8s timeout
* replace filename being appended for unknclear reason
* cache key should not contain whitespaces
* Always try and deploy rook for k8s
* Apply k8s files for rook
* Update action.yml
* Apply k8s files for rook
* Apply k8s files for rook
* cache test and action description for kuber storage class
* Correct test and implement dependency health check and start
* GCP-secret run, cache key
* lfs smudge set explicit and undo explicit
* Run using external secret provider to speed up input
* Update cloud-runner-aws-pipeline.yml
* Add nodejs as build step dependency
* Add nodejs as build step dependency
* Cloud Runner Tests must be specified to capture logs from cloud runner for tests
* Cloud Runner Tests must be specified to capture logs from cloud runner for tests
* Refactor and cleanup - no async input, combined setup/build, removed github logs for cli runs
* Refactor and cleanup - no async input, combined setup/build, removed github logs for cli runs
* Refactor and cleanup - no async input, combined setup/build, removed github logs for cli runs
* Refactor and cleanup - no async input, combined setup/build, removed github logs for cli runs
* Refactor and cleanup - no async input, combined setup/build, removed github logs for cli runs
* better defaults for new inputs
* better defaults
* merge latest
* force build update
* use npm n to update node in unity builder
* use npm n to update node in unity builder
* use npm n to update node in unity builder
* correct new line
* quiet zipping
* quiet zipping
* default secrets for unity username and password
* default secrets for unity username and password
* ls active directory before lfs install
* Get cloud runner secrets from
* Get cloud runner secrets from
* Cleanup setup of default secrets
* Various fixes
* Cleanup setup of default secrets
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* Various fixes
* AWS secrets manager support
* less caching logs
* default k8s storage class to pd-standard
* more readable build commands
* Capture aws exit code 1 reliably
* Always replace /head from branch
* k8s default storage class to standard-rwo
* cleanup
* further cleanup input
* further cleanup input
* further cleanup input
* further cleanup input
* further cleanup input
* folder sizes to inspect caching
* dir command for local cloud runner test
* k8s wait for pending because pvc will not create earlier
* prefer k8s standard storage
* handle empty string as cloud runner cluster input
* local-system is now used for cloud runner test implementation AND correctly unset test CLI input
* local-system is now used for cloud runner test implementation AND correctly unset test CLI input
* fix unterminated quote
* fix unterminated quote
* do not share build parameters in tests - in cloud runner this will cause conflicts with resouces of the same name
* remove head and heads from branch prefix
* fix reversed caching direction of cache-push
* fixes
* fixes
* fixes
* cachePull cli
* fixes
* fixes
* fixes
* fixes
* fixes
* order cache test to be first
* order cache test to be first
* fixes
* populate cache key instead of using branch
* cleanup cli
* garbage-collect-aws cli can iterate over aws resources and cli scans all ts files
* import cli methods
* import cli files explicitly
* import cli files explicitly
* import cli files explicitly
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* import cli methods
* log parameters in cloud runner parameter test
* log parameters in cloud runner parameter test
* log parameters in cloud runner parameter test
* Cloud runner param test before caching because we have a fast local cache test now
* Using custom build path relative to repo root rather than project root
* aws-garbage-collect at end of pipeline
* aws-garbage-collect do not actually delete anything for now - just list
* remove some legacy du commands
* Update cloud-runner-aws-pipeline.yml
* log contents after cache pull and fix some scenarios with duplicate secrets
* log contents after cache pull and fix some scenarios with duplicate secrets
* log contents after cache pull and fix some scenarios with duplicate secrets
* PR comments
* Replace guid with uuid package
* use fileExists lambda instead of stat to check file exists in caching
* build failed results in core error message
* Delete sample.txt
2022-04-10 23:00:37 +00:00
|
|
|
|
2020-01-20 23:06:14 +00:00
|
|
|
class ImageTag {
|
2021-03-13 23:44:01 +00:00
|
|
|
public repository: string;
|
2022-04-03 15:59:14 +00:00
|
|
|
public editorVersion: string;
|
2023-03-04 00:25:40 +00:00
|
|
|
public targetPlatform: string;
|
2021-03-13 23:44:01 +00:00
|
|
|
public builderPlatform: string;
|
2023-03-04 00:25:40 +00:00
|
|
|
public customImage: string;
|
2022-04-03 15:59:14 +00:00
|
|
|
public imageRollingVersion: number;
|
|
|
|
public imagePlatformPrefix: string;
|
2021-03-13 23:44:01 +00:00
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
constructor(imageProperties: { [key: string]: string }) {
|
2023-11-15 14:17:55 +00:00
|
|
|
const {
|
|
|
|
editorVersion,
|
|
|
|
targetPlatform,
|
|
|
|
customImage,
|
2024-02-06 23:46:31 +00:00
|
|
|
buildPlatform,
|
2023-11-15 14:17:55 +00:00
|
|
|
containerRegistryRepository,
|
|
|
|
containerRegistryImageVersion,
|
2024-02-19 03:44:25 +00:00
|
|
|
providerStrategy,
|
2023-11-15 14:17:55 +00:00
|
|
|
} = imageProperties;
|
2019-12-22 14:05:15 +00:00
|
|
|
|
2022-04-03 15:59:14 +00:00
|
|
|
if (!ImageTag.versionPattern.test(editorVersion)) {
|
|
|
|
throw new Error(`Invalid version "${editorVersion}".`);
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
2022-04-03 15:59:14 +00:00
|
|
|
// Todo we might as well skip this class for customImage.
|
|
|
|
// Either
|
2021-03-13 23:44:01 +00:00
|
|
|
this.customImage = customImage;
|
2022-04-03 15:59:14 +00:00
|
|
|
|
|
|
|
// Or
|
2023-11-15 14:17:55 +00:00
|
|
|
this.repository = containerRegistryRepository;
|
2022-04-03 15:59:14 +00:00
|
|
|
this.editorVersion = editorVersion;
|
|
|
|
this.targetPlatform = targetPlatform;
|
2024-02-19 03:44:25 +00:00
|
|
|
this.builderPlatform = ImageTag.getTargetPlatformToTargetPlatformSuffixMap(
|
|
|
|
targetPlatform,
|
|
|
|
editorVersion,
|
|
|
|
providerStrategy,
|
|
|
|
);
|
2024-02-06 23:46:31 +00:00
|
|
|
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefixes(buildPlatform);
|
2023-11-15 14:17:55 +00:00
|
|
|
this.imageRollingVersion = Number(containerRegistryImageVersion); // Will automatically roll to the latest non-breaking version.
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static get versionPattern(): RegExp {
|
2024-03-17 20:33:23 +00:00
|
|
|
return /^\d+\.\d+\.\d+[a-z]\d+$/;
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
2022-04-03 15:59:14 +00:00
|
|
|
static get targetPlatformSuffixes() {
|
2019-12-22 14:05:15 +00:00
|
|
|
return {
|
|
|
|
generic: '',
|
|
|
|
webgl: 'webgl',
|
2020-10-24 06:43:29 +00:00
|
|
|
mac: 'mac-mono',
|
|
|
|
windows: 'windows-mono',
|
2022-01-25 21:18:15 +00:00
|
|
|
windowsIl2cpp: 'windows-il2cpp',
|
|
|
|
wsaPlayer: 'universal-windows-platform',
|
2020-10-24 07:39:01 +00:00
|
|
|
linux: 'base',
|
2020-11-13 23:57:44 +00:00
|
|
|
linuxIl2cpp: 'linux-il2cpp',
|
2019-12-22 14:05:15 +00:00
|
|
|
android: 'android',
|
|
|
|
ios: 'ios',
|
2022-01-25 21:18:15 +00:00
|
|
|
tvos: 'appletv',
|
2025-06-07 18:20:18 +00:00
|
|
|
visionos: 'visionos',
|
2020-01-07 23:39:53 +00:00
|
|
|
facebook: 'facebook',
|
2019-12-22 14:05:15 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static getImagePlatformPrefixes(platform: string): string {
|
2024-02-06 23:46:31 +00:00
|
|
|
if (!platform || platform === '') {
|
|
|
|
platform = process.platform;
|
|
|
|
}
|
|
|
|
|
2022-04-03 15:59:14 +00:00
|
|
|
switch (platform) {
|
|
|
|
case 'win32':
|
|
|
|
return 'windows';
|
|
|
|
case 'linux':
|
|
|
|
return 'ubuntu';
|
|
|
|
default:
|
2022-04-04 08:19:40 +00:00
|
|
|
return '';
|
2022-04-03 15:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-19 03:44:25 +00:00
|
|
|
static getTargetPlatformToTargetPlatformSuffixMap(
|
|
|
|
platform: string,
|
|
|
|
version: string,
|
|
|
|
providerStrategy: string,
|
|
|
|
): string {
|
2025-06-07 18:20:18 +00:00
|
|
|
const {
|
|
|
|
generic,
|
|
|
|
webgl,
|
|
|
|
mac,
|
|
|
|
windows,
|
|
|
|
windowsIl2cpp,
|
|
|
|
wsaPlayer,
|
|
|
|
linux,
|
|
|
|
linuxIl2cpp,
|
|
|
|
android,
|
|
|
|
ios,
|
|
|
|
tvos,
|
|
|
|
visionos,
|
|
|
|
facebook,
|
|
|
|
} = ImageTag.targetPlatformSuffixes;
|
2019-12-22 14:05:15 +00:00
|
|
|
|
2020-11-17 23:51:10 +00:00
|
|
|
const [major, minor] = version.split('.').map((digit) => Number(digit));
|
2022-04-11 22:43:41 +00:00
|
|
|
|
2020-10-24 06:43:29 +00:00
|
|
|
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
2020-11-13 23:57:44 +00:00
|
|
|
switch (platform) {
|
|
|
|
case Platform.types.StandaloneOSX:
|
|
|
|
return mac;
|
|
|
|
case Platform.types.StandaloneWindows:
|
|
|
|
case Platform.types.StandaloneWindows64:
|
2022-01-25 21:18:15 +00:00
|
|
|
// Can only build windows-il2cpp on a windows based system
|
2023-03-04 00:25:40 +00:00
|
|
|
if (process.platform === 'win32') {
|
2022-01-25 21:18:15 +00:00
|
|
|
// Unity versions before 2019.3 do not support il2cpp
|
|
|
|
if (major >= 2020 || (major === 2019 && minor >= 3)) {
|
|
|
|
return windowsIl2cpp;
|
|
|
|
} else {
|
2023-10-31 06:55:39 +00:00
|
|
|
throw new Error(
|
|
|
|
`Windows-based builds are only supported on 2019.3.X+ versions of Unity.
|
|
|
|
If you are trying to build for windows-mono, please use a Linux based OS.`,
|
|
|
|
);
|
2022-01-25 21:18:15 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-11 22:43:41 +00:00
|
|
|
|
2020-11-13 23:57:44 +00:00
|
|
|
return windows;
|
|
|
|
case Platform.types.StandaloneLinux64: {
|
|
|
|
// Unity versions before 2019.3 do not support il2cpp
|
2024-02-19 03:44:25 +00:00
|
|
|
if (major >= 2020 || (major === 2019 && minor >= 3)) {
|
|
|
|
if (providerStrategy === 'local') {
|
|
|
|
return linuxIl2cpp;
|
|
|
|
} else {
|
|
|
|
return process.env.USE_IL2CPP === 'true' ? linuxIl2cpp : linux;
|
|
|
|
}
|
2020-11-13 23:57:44 +00:00
|
|
|
}
|
2022-04-11 22:43:41 +00:00
|
|
|
|
2020-11-13 23:57:44 +00:00
|
|
|
return linux;
|
|
|
|
}
|
|
|
|
case Platform.types.iOS:
|
|
|
|
return ios;
|
|
|
|
case Platform.types.Android:
|
|
|
|
return android;
|
|
|
|
case Platform.types.WebGL:
|
|
|
|
return webgl;
|
|
|
|
case Platform.types.WSAPlayer:
|
2022-01-25 21:18:15 +00:00
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
throw new Error(`WSAPlayer can only be built on a windows base OS`);
|
|
|
|
}
|
2022-04-11 22:43:41 +00:00
|
|
|
|
2022-01-25 21:18:15 +00:00
|
|
|
return wsaPlayer;
|
2020-11-13 23:57:44 +00:00
|
|
|
case Platform.types.PS4:
|
|
|
|
return windows;
|
|
|
|
case Platform.types.XboxOne:
|
|
|
|
return windows;
|
|
|
|
case Platform.types.tvOS:
|
2025-06-07 16:08:47 +00:00
|
|
|
if (process.platform !== 'win32' && process.platform !== 'darwin') {
|
|
|
|
throw new Error(`tvOS can only be built on Windows or macOS base OS`);
|
2022-01-25 21:18:15 +00:00
|
|
|
}
|
2022-04-11 22:43:41 +00:00
|
|
|
|
2022-01-25 21:18:15 +00:00
|
|
|
return tvos;
|
2025-06-07 18:20:18 +00:00
|
|
|
case Platform.types.VisionOS:
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
throw new Error(`visionOS can only be built on a macOS base OS`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return visionos;
|
2020-11-13 23:57:44 +00:00
|
|
|
case Platform.types.Switch:
|
|
|
|
return windows;
|
2022-04-11 22:43:41 +00:00
|
|
|
|
2020-01-07 23:39:53 +00:00
|
|
|
// Unsupported
|
2020-11-13 23:57:44 +00:00
|
|
|
case Platform.types.Lumin:
|
|
|
|
return windows;
|
|
|
|
case Platform.types.BJM:
|
|
|
|
return windows;
|
|
|
|
case Platform.types.Stadia:
|
|
|
|
return windows;
|
|
|
|
case Platform.types.Facebook:
|
|
|
|
return facebook;
|
|
|
|
case Platform.types.NoTarget:
|
|
|
|
return generic;
|
|
|
|
|
2020-01-07 23:39:53 +00:00
|
|
|
// Test specific
|
2020-11-13 23:57:44 +00:00
|
|
|
case Platform.types.Test:
|
|
|
|
return generic;
|
|
|
|
default:
|
|
|
|
throw new Error(`
|
|
|
|
Platform must be one of the ones described in the documentation.
|
|
|
|
"${platform}" is currently not supported.`);
|
|
|
|
}
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
get tag(): string {
|
2022-04-03 15:59:14 +00:00
|
|
|
const versionAndPlatform = `${this.editorVersion}-${this.builderPlatform}`.replace(/-+$/, '');
|
|
|
|
|
|
|
|
return `${this.imagePlatformPrefix}-${versionAndPlatform}-${this.imageRollingVersion}`;
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
get image(): string {
|
2023-11-15 14:17:55 +00:00
|
|
|
return `${this.repository}`.replace(/^\/+/, '');
|
2019-12-22 17:07:55 +00:00
|
|
|
}
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
toString(): string {
|
2021-03-13 23:44:01 +00:00
|
|
|
const { image, tag, customImage } = this;
|
2019-12-22 14:05:15 +00:00
|
|
|
|
2022-04-03 15:59:14 +00:00
|
|
|
if (customImage) return customImage;
|
2020-09-18 16:41:31 +00:00
|
|
|
|
2023-12-13 06:10:57 +00:00
|
|
|
return `${image}:${tag}`;
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
}
|
2023-08-22 08:03:32 +00:00
|
|
|
|
2020-01-20 23:06:14 +00:00
|
|
|
export default ImageTag;
|