Switch to version 1 images (#374)

* feat: upgrade to images of version 1 (rolling tag)

* chore: indicate what needs to move out of the input class
This commit is contained in:
Webber Takken
2022-04-03 17:59:14 +02:00
committed by GitHub
parent 1bc7130fea
commit 441be81543
17 changed files with 175 additions and 139 deletions

103
dist/index.js generated vendored
View File

@@ -245,8 +245,8 @@ class BuildParameters {
static create() {
return __awaiter(this, void 0, void 0, function* () {
const buildFile = this.parseBuildFile(input_1.default.buildName, input_1.default.targetPlatform, input_1.default.androidAppBundle);
const unityVersion = unity_versioning_1.default.determineUnityVersion(input_1.default.projectPath, input_1.default.unityVersion);
const buildVersion = yield versioning_1.default.determineVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
const editorVersion = unity_versioning_1.default.determineUnityVersion(input_1.default.projectPath, input_1.default.unityVersion);
const buildVersion = yield versioning_1.default.determineBuildVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
const androidVersionCode = android_versioning_1.default.determineVersionCode(buildVersion, input_1.default.androidVersionCode);
const androidSdkManagerParameters = android_versioning_1.default.determineSdkManagerParameters(input_1.default.androidTargetSdkVersion);
// Todo - Don't use process.env directly, that's what the input model class is for.
@@ -268,11 +268,11 @@ class BuildParameters {
core.setSecret(unitySerial);
// ---
return {
version: unityVersion,
editorVersion,
customImage: input_1.default.customImage,
unitySerial,
runnerTempPath: process.env.RUNNER_TEMP,
platform: input_1.default.targetPlatform,
targetPlatform: input_1.default.targetPlatform,
projectPath: input_1.default.projectPath,
buildName: input_1.default.buildName,
buildPath: `${input_1.default.buildsPath}/${input_1.default.targetPlatform}`,
@@ -304,6 +304,7 @@ class BuildParameters {
customJob: input_1.default.customJob,
runNumber: input_1.default.runNumber,
branch: yield input_1.default.branch(),
// Todo - move this out of UserInput and into some class that determines additional information (as needed)
githubRepo: yield input_1.default.githubRepo(),
remoteBuildCluster: input_1.default.cloudRunnerCluster,
awsStackName: input_1.default.awsBaseStackName,
@@ -2093,7 +2094,7 @@ class KubernetesJobSpecFactory {
},
{
name: 'BUILD_TARGET',
value: buildParameters.platform,
value: buildParameters.targetPlatform,
},
{
name: 'ANDROID_VERSION_CODE',
@@ -2744,7 +2745,7 @@ class TaskParameterSerializer {
},
{
name: 'BUILD_TARGET',
value: cloud_runner_state_1.CloudRunnerState.buildParams.platform,
value: cloud_runner_state_1.CloudRunnerState.buildParams.targetPlatform,
},
...TaskParameterSerializer.serializeBuildParamsAndInput,
];
@@ -3406,10 +3407,10 @@ class ImageEnvironmentFactory {
{ name: 'UNITY_EMAIL', value: process.env.UNITY_EMAIL },
{ name: 'UNITY_PASSWORD', value: process.env.UNITY_PASSWORD },
{ name: 'UNITY_SERIAL', value: parameters.unitySerial },
{ name: 'UNITY_VERSION', value: parameters.version },
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
{ name: 'USYM_UPLOAD_AUTH_TOKEN', value: process.env.USYM_UPLOAD_AUTH_TOKEN },
{ name: 'PROJECT_PATH', value: parameters.projectPath },
{ name: 'BUILD_TARGET', value: parameters.platform },
{ name: 'BUILD_TARGET', value: parameters.targetPlatform },
{ name: 'BUILD_NAME', value: parameters.buildName },
{ name: 'BUILD_PATH', value: parameters.buildPath },
{ name: 'BUILD_FILE', value: parameters.buildFile },
@@ -3462,22 +3463,26 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const platform_1 = __importDefault(__nccwpck_require__(9707));
class ImageTag {
constructor(imageProperties) {
const { repository = 'unityci', name = 'editor', version = '2019.2.11f1', platform, customImage } = imageProperties;
if (!ImageTag.versionPattern.test(version)) {
throw new Error(`Invalid version "${version}".`);
const { editorVersion = '2019.2.11f1', targetPlatform, customImage } = imageProperties;
if (!ImageTag.versionPattern.test(editorVersion)) {
throw new Error(`Invalid version "${editorVersion}".`);
}
const builderPlatform = ImageTag.getTargetPlatformToImageSuffixMap(platform, version);
this.repository = repository;
this.name = name;
this.version = version;
this.platform = platform;
this.builderPlatform = builderPlatform;
// Todo we might as well skip this class for customImage.
// Either
this.customImage = customImage;
// Or
this.repository = 'unityci';
this.name = 'editor';
this.editorVersion = editorVersion;
this.targetPlatform = targetPlatform;
this.builderPlatform = ImageTag.getTargetPlatformToTargetPlatformSuffixMap(targetPlatform, editorVersion);
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefixes(process.platform);
this.imageRollingVersion = 1; // will automatically roll to the latest non-breaking version.
}
static get versionPattern() {
return /^20\d{2}\.\d\.\w{3,4}|3$/;
}
static get imageSuffixes() {
static get targetPlatformSuffixes() {
return {
generic: '',
webgl: 'webgl',
@@ -3493,8 +3498,18 @@ class ImageTag {
facebook: 'facebook',
};
}
static getTargetPlatformToImageSuffixMap(platform, version) {
const { generic, webgl, mac, windows, windowsIl2cpp, wsaPlayer, linux, linuxIl2cpp, android, ios, tvos, facebook } = ImageTag.imageSuffixes;
static getImagePlatformPrefixes(platform) {
switch (platform) {
case 'win32':
return 'windows';
case 'linux':
return 'ubuntu';
default:
throw new Error('The Operating System of this runner is not yet supported.');
}
}
static getTargetPlatformToTargetPlatformSuffixMap(platform, version) {
const { generic, webgl, mac, windows, windowsIl2cpp, wsaPlayer, linux, linuxIl2cpp, android, ios, tvos, facebook } = ImageTag.targetPlatformSuffixes;
const [major, minor] = version.split('.').map((digit) => Number(digit));
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
switch (platform) {
@@ -3564,25 +3579,17 @@ class ImageTag {
}
}
get tag() {
//We check the host os so we know what type of the images we need to pull
switch (process.platform) {
case 'win32':
return `windows-${this.version}-${this.builderPlatform}`.replace(/-+$/, '');
case 'linux':
return `${this.version}-${this.builderPlatform}`.replace(/-+$/, '');
default:
break;
}
const versionAndPlatform = `${this.editorVersion}-${this.builderPlatform}`.replace(/-+$/, '');
return `${this.imagePlatformPrefix}-${versionAndPlatform}-${this.imageRollingVersion}`;
}
get image() {
return `${this.repository}/${this.name}`.replace(/^\/+/, '');
}
toString() {
const { image, tag, customImage } = this;
if (customImage && customImage !== '') {
if (customImage)
return customImage;
}
return `${image}:${tag}-0`; // '0' here represents the docker repo version
return `${image}:${tag}`; // '0' here represents the docker repo version
}
}
exports["default"] = ImageTag;
@@ -3818,6 +3825,8 @@ const core = __nccwpck_require__(42186);
* Input variables specified in workflows using "with" prop.
*
* Note that input is always passed as a string, even booleans.
*
* Todo: rename to UserInput and remove anything that is not direct input from the user / ci workflow
*/
class Input {
// also enabled debug logging for cloud runner
@@ -3844,6 +3853,7 @@ class Input {
return __awaiter(this, void 0, void 0, function* () {
return (Input.getInput('GITHUB_REPOSITORY') ||
Input.getInput('GITHUB_REPO') ||
// todo - move this to some class specific for determining additional information
(yield git_repo_1.GitRepoReader.GetRemote()) ||
'game-ci/unity-builder');
});
@@ -3851,6 +3861,7 @@ class Input {
static branch() {
return __awaiter(this, void 0, void 0, function* () {
if (yield git_repo_1.GitRepoReader.GetBranch()) {
// todo - move this to some class specific for determining additional information
return yield git_repo_1.GitRepoReader.GetBranch();
}
else if (Input.getInput(`GITHUB_REF`)) {
@@ -3872,6 +3883,7 @@ class Input {
return Input.getInput(`GitSHA`);
}
else if (git_repo_1.GitRepoReader.GetSha()) {
// todo - move this to some class specific for determining additional information
return git_repo_1.GitRepoReader.GetSha();
}
}
@@ -3978,6 +3990,7 @@ class Input {
}
static githubToken() {
return __awaiter(this, void 0, void 0, function* () {
// Todo - move GitHubCLI out of the simple input class. It is in fact not input from the user.
return Input.getInput('githubToken') || (yield github_cli_1.GithubCliReader.GetGitHubAuthToken()) || '';
});
}
@@ -4146,7 +4159,7 @@ const fs_1 = __importDefault(__nccwpck_require__(57147));
class SetupMac {
static setup(buildParameters, actionFolder) {
return __awaiter(this, void 0, void 0, function* () {
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.version}/Unity.app/Contents/MacOS/Unity`;
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.editorVersion}/Unity.app/Contents/MacOS/Unity`;
// Only install unity if the editor doesn't already exist
if (!fs_1.default.existsSync(unityEditorPath)) {
yield SetupMac.installUnityHub();
@@ -4170,9 +4183,9 @@ class SetupMac {
}
static installUnity(buildParameters, silent = false) {
return __awaiter(this, void 0, void 0, function* () {
const unityChangeset = yield unity_changeset_1.getUnityChangeset(buildParameters.version);
const unityChangeset = yield unity_changeset_1.getUnityChangeset(buildParameters.editorVersion);
const command = `${this.unityHubPath} -- --headless install \
--version ${buildParameters.version} \
--version ${buildParameters.editorVersion} \
--changeset ${unityChangeset.changeset} \
--module mac-il2cpp \
--childModules`;
@@ -4189,10 +4202,10 @@ class SetupMac {
// Need to set environment variables from here because we execute
// the scripts on the host for mac
process.env.ACTION_FOLDER = actionFolder;
process.env.UNITY_VERSION = buildParameters.version;
process.env.UNITY_VERSION = buildParameters.editorVersion;
process.env.UNITY_SERIAL = buildParameters.unitySerial;
process.env.PROJECT_PATH = buildParameters.projectPath;
process.env.BUILD_TARGET = buildParameters.platform;
process.env.BUILD_TARGET = buildParameters.targetPlatform;
process.env.BUILD_NAME = buildParameters.buildName;
process.env.BUILD_PATH = buildParameters.buildPath;
process.env.BUILD_FILE = buildParameters.buildFile;
@@ -4240,28 +4253,28 @@ const fs_1 = __importDefault(__nccwpck_require__(57147));
class SetupWindows {
static setup(buildParameters) {
return __awaiter(this, void 0, void 0, function* () {
yield SetupWindows.setupWindowsRun(buildParameters.platform);
const { targetPlatform } = buildParameters;
yield SetupWindows.setupWindowsRun(targetPlatform);
});
}
//Setup prerequisite files/folders for a windows-based docker run
static setupWindowsRun(platform, silent = false) {
static setupWindowsRun(targetPlatform, silent = false) {
return __awaiter(this, void 0, void 0, function* () {
if (!fs_1.default.existsSync('c:/regkeys')) {
fs_1.default.mkdirSync('c:/regkeys');
}
switch (platform) {
switch (targetPlatform) {
//These all need the Windows 10 SDK
case 'StandaloneWindows':
case 'StandaloneWindows64':
case 'WSAPlayer':
this.generateWinSDKRegKeys(silent);
yield this.generateWinSDKRegKeys(silent);
break;
}
});
}
static generateWinSDKRegKeys(silent = false) {
return __awaiter(this, void 0, void 0, function* () {
// Export registry keys that point to the location of the windows 10 sdk
// Export registry keys that point to the Windows 10 SDK
const exportWinSDKRegKeysCommand = 'reg export "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" c:/regkeys/winsdk.reg /y';
yield exec_1.exec(exportWinSDKRegKeysCommand, undefined, { silent });
});
@@ -4284,7 +4297,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const fs_1 = __importDefault(__nccwpck_require__(57147));
class ValidateWindows {
static validate(buildParameters) {
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.platform);
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.targetPlatform);
if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) {
throw new Error(`Unity email and password must be set for Windows based builds to
authenticate the license. Make sure to set them inside UNITY_EMAIL
@@ -4702,7 +4715,7 @@ class Versioning {
static get descriptionRegex3() {
return /^v?([\d.]+-\w+\.\d+)-(\d+)-g(\w+)-?(\w+)*/g;
}
static determineVersion(strategy, inputVersion) {
static determineBuildVersion(strategy, inputVersion) {
return __awaiter(this, void 0, void 0, function* () {
// Validate input
if (!Object.hasOwnProperty.call(this.strategies, strategy)) {