Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorWhenMissingUnityBuildResults exposed as with parameter #575

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ inputs:
description:
'The path to mount the workspace inside the docker container. For windows, leave out the drive letter. For example
c:/github/workspace should be defined as /github/workspace'
errorWhenMissingUnityBuildResults:
default: true
required: false
description:
'Check if Unity build product is present after build, and error if not. Set to false to not check, useful if
producing alternative build products.'
Comment on lines +220 to +225
Copy link
Member

@webbertakken webbertakken Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is effectively a discrepancy in the application (builder and/or container). I feel adding an option in the (functional) public api isn't the answer to this technical issue.

We should probably agree on how the application should handle this case and then handle it correctly without exposing any new "options".


outputs:
volume:
Expand Down
36 changes: 25 additions & 11 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ async function runMain() {
if (process.platform === 'darwin') {
MacBuilder.run(actionFolder);
} else {
await Docker.run(baseImage.toString(), { workspace, actionFolder, ...buildParameters });
await Docker.run(
baseImage.toString(),
{ workspace, actionFolder, ...buildParameters },
{
errorWhenMissingUnityBuildResults: buildParameters.errorWhenMissingUnityBuildResults,
},
);
}
} else {
await CloudRunner.run(buildParameters, baseImage.toString());
Expand Down
2 changes: 2 additions & 0 deletions src/model/build-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class BuildParameters {
public cacheUnityInstallationOnMac!: boolean;
public unityHubVersionOnMac!: string;
public dockerWorkspacePath!: string;
public errorWhenMissingUnityBuildResults!: boolean;

public static shouldUseRetainedWorkspaceMode(buildParameters: BuildParameters) {
return buildParameters.maxRetainedWorkspaces > 0 && CloudRunner.lockedWorkspace !== ``;
Expand Down Expand Up @@ -192,6 +193,7 @@ class BuildParameters {
cacheUnityInstallationOnMac: Input.cacheUnityInstallationOnMac,
unityHubVersionOnMac: Input.unityHubVersionOnMac,
dockerWorkspacePath: Input.dockerWorkspacePath,
errorWhenMissingUnityBuildResults: Input.errorWhenMissingUnityBuildResults,
};
}

Expand Down
24 changes: 13 additions & 11 deletions src/model/cloud-runner/providers/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,23 @@ cp -a ${sharedFolder}. /github/workspace/cloud-runner-cache/
await Docker.run(
image,
{ workspace, actionFolder, ...this.buildParameters },
false,
`chmod +x /github/workspace/${entrypointFilePath} && /github/workspace/${entrypointFilePath}`,
content,
{
listeners: {
stdout: (data: Buffer) => {
myOutput += data.toString();
},
stderr: (data: Buffer) => {
myOutput += `[LOCAL-DOCKER-ERROR]${data.toString()}`;
silent: false,
overrideCommands: `chmod +x /github/workspace/${entrypointFilePath} && /github/workspace/${entrypointFilePath}`,
additionalVariables: content,
options: {
listeners: {
stdout: (data: Buffer) => {
myOutput += data.toString();
},
stderr: (data: Buffer) => {
myOutput += `[LOCAL-DOCKER-ERROR]${data.toString()}`;
},
},
},
entrypointBash: true,
errorWhenMissingUnityBuildResults: false,
},
true,
false,
);

return myOutput;
Expand Down
2 changes: 1 addition & 1 deletion src/model/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ describe('Docker', () => {
buildsPath: 'build',
method: '',
};
await Docker.run(image, parameters);
await Docker.run(image, parameters, {});
});
});
25 changes: 18 additions & 7 deletions src/model/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@ import path from 'node:path';
import { ExecOptions } from '@actions/exec';
import { DockerParameters, StringKeyValuePair } from './shared-types';

interface IDockerOptions {
silent?: boolean;
overrideCommands?: string;
additionalVariables?: StringKeyValuePair[];
options?: ExecOptions | undefined;
entrypointBash?: boolean;
errorWhenMissingUnityBuildResults?: boolean;
}

class Docker {
static async run(
image: string,
parameters: DockerParameters,
silent: boolean = false,
overrideCommands: string = '',
additionalVariables: StringKeyValuePair[] = [],
// eslint-disable-next-line unicorn/no-useless-undefined
options: ExecOptions | undefined = undefined,
entrypointBash: boolean = false,
errorWhenMissingUnityBuildResults: boolean = true,
{
silent = false,
overrideCommands = '',
additionalVariables = [],
// eslint-disable-next-line unicorn/no-useless-undefined
options = undefined,
entrypointBash = false,
errorWhenMissingUnityBuildResults = true,
}: IDockerOptions,
) {
let runCommand = '';
switch (process.platform) {
Expand Down
18 changes: 18 additions & 0 deletions src/model/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,22 @@ describe('Input', () => {
expect(spy).toHaveBeenCalledTimes(1);
});
});

describe('errorWhenMissingUnityBuildResults', () => {
it('returns the default value', () => {
expect(Input.errorWhenMissingUnityBuildResults).toStrictEqual(false);
});

it('returns true when string true is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
expect(Input.errorWhenMissingUnityBuildResults).toStrictEqual(true);
expect(spy).toHaveBeenCalledTimes(1);
});

it('returns false when string false is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
expect(Input.errorWhenMissingUnityBuildResults).toStrictEqual(false);
expect(spy).toHaveBeenCalledTimes(1);
});
});
});
6 changes: 6 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ class Input {
return Input.getInput('dockerWorkspacePath') || '/github/workspace';
}

static get errorWhenMissingUnityBuildResults(): boolean {
const input = Input.getInput('errorWhenMissingUnityBuildResults') || false;

return input === 'true';
}

public static ToEnvVarFormat(input: string) {
if (input.toUpperCase() === input) {
return input;
Expand Down