Skip to content

Commit

Permalink
Merge pull request #129 from triwav/parallel_testing_improvements
Browse files Browse the repository at this point in the history
Add createPackage and publish to RokuDevice to avoid parallel testing…
  • Loading branch information
triwav authored Feb 28, 2024
2 parents aa62c49 + 931692d commit 6cf4ce8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/src/OnDeviceComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ export class OnDeviceComponent {
if (this.getConfig()?.clientDebugLogging) {
const date = new Date;
const formattedDate = `${utils.lpad(date.getMonth())}-${utils.lpad(date.getDate())} ${utils.lpad(date.getHours())}:${utils.lpad(date.getMinutes())}:${utils.lpad(date.getSeconds())}:${utils.lpad(date.getMilliseconds(), 3)}`;
console.log(`${formattedDate} [ODC] ${message}`, ...args);
console.log(`${formattedDate} [ODC][${this.device.getCurrentDeviceConfig().host}] ${message}`, ...args);
}
}
}
43 changes: 30 additions & 13 deletions client/src/RokuDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,27 @@ export class RokuDevice {
public async deploy(options?: rokuDeploy.RokuDeployOptions & {
injectTestingFiles?: boolean;
preventMultipleDeployments?: boolean;
deleteBeforeInstall?: boolean;
deleteBeforeInstall?: boolean; // Remove in v3
}, beforeZipCallback?: (info: rokuDeploy.BeforeZipCallbackInfo) => void) {
const injectTestingFiles = options?.injectTestingFiles !== false;

const deviceConfig = this.getCurrentDeviceConfig();
options = rokuDeploy.getOptions(options);
options.host = deviceConfig.host;
options.password = deviceConfig.password;

if (options.deleteBeforeInstall) {
if (options.deleteInstalledChannel || options.deleteBeforeInstall) {
try {
await rokuDeploy.deleteInstalledChannel(options);
} catch (e) {}
} else if (options?.preventMultipleDeployments !== false) {
if (this.deployed) return;
} catch (e) {
// note we don't report the error; as we don't actually care that we could not deploy - it's just useless noise to log it.
}
}
await this.createPackage(options, beforeZipCallback);
const result = await this.publish(options);
this.deployed = true;
return result;
}

public async createPackage(options?: rokuDeploy.RokuDeployOptions & {
injectTestingFiles?: boolean;
}, beforeZipCallback?: (info: rokuDeploy.BeforeZipCallbackInfo) => void) {
const injectTestingFiles = options?.injectTestingFiles !== false;
options = rokuDeploy.getOptions(options);

if (injectTestingFiles) {
const files = options.files ?? [];
Expand All @@ -70,7 +75,7 @@ export class RokuDevice {
options.files = files;
}

await rokuDeploy.deploy(options, (info) => {
await rokuDeploy.createPackage(options, (info) => {
// Manifest modification
const manifestPath = `${info.stagingDir}/manifest`;
const manifestContents = fsExtra.readFileSync(manifestPath, 'utf-8').replace('ENABLE_RTA=false', 'ENABLE_RTA=true');
Expand All @@ -90,7 +95,19 @@ export class RokuDevice {
beforeZipCallback(info);
}
});
this.deployed = true;
}

public async publish(options?: rokuDeploy.RokuDeployOptions) {
const deviceConfig = this.getCurrentDeviceConfig();
options = rokuDeploy.getOptions(options);
options.host = deviceConfig.host;
options.password = deviceConfig.password;

return await rokuDeploy.publish(options);
}

public getOutputZipFilePath(options: rokuDeploy.RokuDeployOptions) {
return rokuDeploy.getOutputZipFilePath(options);
}

private injectRtaHelpersIntoComponentContents(contents: string) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Utils {
/** Helper for setting up process.env from a config file */
public setupEnvironmentFromConfigFile(configFilePath = 'rta-config.json', deviceSelector: Record<string, any> | number | undefined = undefined) {
const config = this.getConfigFromConfigFile(configFilePath);
this.setupEnvironmentFromConfig(config);
this.setupEnvironmentFromConfig(config, deviceSelector);
}

/** Validates the ConfigOptions schema the current class is using
Expand Down

0 comments on commit 6cf4ce8

Please sign in to comment.