Modifying js files to account for win support
parent
d95f760d49
commit
8e5895210d
|
|
@ -95,7 +95,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const Action = {
|
const Action = {
|
||||||
get supportedPlatforms() {
|
get supportedPlatforms() {
|
||||||
return ['linux'];
|
return ['linux', 'win32'];
|
||||||
},
|
},
|
||||||
get isRunningLocally() {
|
get isRunningLocally() {
|
||||||
return process.env.RUNNER_WORKSPACE === undefined;
|
return process.env.RUNNER_WORKSPACE === undefined;
|
||||||
|
|
@ -162,6 +162,43 @@ const Docker = {
|
||||||
if (!(0, fs_1.existsSync)(githubWorkflow))
|
if (!(0, fs_1.existsSync)(githubWorkflow))
|
||||||
(0, fs_1.mkdirSync)(githubWorkflow);
|
(0, fs_1.mkdirSync)(githubWorkflow);
|
||||||
const testPlatforms = (testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]).join(';');
|
const testPlatforms = (testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]).join(';');
|
||||||
|
const dockerPaths = new Map([
|
||||||
|
[
|
||||||
|
'linux',
|
||||||
|
new Map([
|
||||||
|
['shell', '/bin/bash'],
|
||||||
|
['sshAgent', '/ssh-agent'],
|
||||||
|
['githubHome', '/root'],
|
||||||
|
['githubWorkflow', '/github/workflow'],
|
||||||
|
['githubWorkspace', '/github/workspace'],
|
||||||
|
['stepsPathParent', `${actionFolder}/steps`],
|
||||||
|
['stepsPathContainer', '/steps'],
|
||||||
|
['entrypointPathParent', `${actionFolder}/entrypoint.sh`],
|
||||||
|
['entrypointPathContainer', '/entrypoint.sh'],
|
||||||
|
['knownHostsParent', ' /home/runner/.ssh/known_hosts'],
|
||||||
|
['knownHostsContainer', '/root/.ssh/known_hosts'],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'win32',
|
||||||
|
new Map([
|
||||||
|
['shell', 'powershell'],
|
||||||
|
['sshAgent', 'C:\\ssh-agent'],
|
||||||
|
['githubHome', 'C:\\root'],
|
||||||
|
['githubWorkflow', 'C:\\github\\workflow'],
|
||||||
|
['githubWorkspace', 'C:\\github\\workspace'],
|
||||||
|
['stepsPathParent', `${actionFolder}\\steps`],
|
||||||
|
['stepsPathContainer', 'C:\\steps'],
|
||||||
|
['entrypointPathParent', `${actionFolder}\\entrypoint.ps1`],
|
||||||
|
['entrypointPathContainer', 'C:\\entrypoint.ps1'],
|
||||||
|
['knownHostsParent', 'C:\\Users\\Administrator\\.ssh\\known_hosts'],
|
||||||
|
['knownHostsContainer', 'C:\\root\\.ssh\\known_hosts'],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
const currentDockerPath = dockerPaths.get(process.platform);
|
||||||
|
const bindMountZ = process.platform === 'linux' ? ':z' : '';
|
||||||
|
const bindMountRO = process.platform === 'linux' ? ':ro' : '';
|
||||||
const command = `docker run \
|
const command = `docker run \
|
||||||
--workdir /github/workspace \
|
--workdir /github/workspace \
|
||||||
--rm \
|
--rm \
|
||||||
|
|
@ -193,18 +230,20 @@ const Docker = {
|
||||||
--env RUNNER_TEMP \
|
--env RUNNER_TEMP \
|
||||||
--env RUNNER_WORKSPACE \
|
--env RUNNER_WORKSPACE \
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
${sshAgent ? `--env SSH_AUTH_SOCK=${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('sshAgent')}` : ''} \
|
||||||
--volume "${githubHome}":"/root:z" \
|
--volume "${githubHome}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubHome')}${bindMountZ}" \
|
||||||
--volume "${githubWorkflow}":"/github/workflow:z" \
|
--volume "${githubWorkflow}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubWorkflow')}${bindMountZ}" \
|
||||||
--volume "${workspace}":"/github/workspace:z" \
|
--volume "${workspace}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubWorkspace')}${bindMountZ}" \
|
||||||
--volume "${actionFolder}/steps":"/steps:z" \
|
--volume "${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('stepsPathParent')}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('stepsPathContainer')}${bindMountZ}" \
|
||||||
--volume "${actionFolder}/entrypoint.sh":"/entrypoint.sh:z" \
|
--volume "${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathParent')}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathContainer')}${bindMountZ}" \
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
${sshAgent ? `--volume ${sshAgent}:${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('sshAgent')}` : ''} \
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
${sshAgent
|
||||||
|
? `--volume ${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('knownHostParent')}${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('knownHostContainer')}${bindMountRO}`
|
||||||
|
: ''} \
|
||||||
${useHostNetwork ? '--net=host' : ''} \
|
${useHostNetwork ? '--net=host' : ''} \
|
||||||
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
||||||
${image} \
|
${image} \
|
||||||
/bin/bash /entrypoint.sh`;
|
${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('shell')} ${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathContainer')}`;
|
||||||
yield (0, exec_1.exec)(command, undefined, { silent });
|
yield (0, exec_1.exec)(command, undefined, { silent });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -261,6 +300,8 @@ class ImageTag {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return 'ubuntu';
|
return 'ubuntu';
|
||||||
|
case 'win32':
|
||||||
|
return 'windows';
|
||||||
default:
|
default:
|
||||||
throw new Error('The Operating System of this runner is not yet supported.');
|
throw new Error('The Operating System of this runner is not yet supported.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -4,8 +4,8 @@ import path from 'path';
|
||||||
|
|
||||||
describe('Action', () => {
|
describe('Action', () => {
|
||||||
describe('compatibility check', () => {
|
describe('compatibility check', () => {
|
||||||
it('throws for anything other than linux', () => {
|
it('throws for anything other than linux or windows', () => {
|
||||||
if (process.platform !== 'linux') {
|
if (process.platform !== 'linux' && process.platform !== 'win32') {
|
||||||
expect(() => Action.checkCompatibility()).toThrow();
|
expect(() => Action.checkCompatibility()).toThrow();
|
||||||
} else {
|
} else {
|
||||||
expect(() => Action.checkCompatibility()).not.toThrow();
|
expect(() => Action.checkCompatibility()).not.toThrow();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import path from 'path';
|
||||||
|
|
||||||
const Action = {
|
const Action = {
|
||||||
get supportedPlatforms() {
|
get supportedPlatforms() {
|
||||||
return ['linux'];
|
return ['linux', 'win32'];
|
||||||
},
|
},
|
||||||
|
|
||||||
get isRunningLocally() {
|
get isRunningLocally() {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,44 @@ const Docker = {
|
||||||
testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]
|
testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]
|
||||||
).join(';');
|
).join(';');
|
||||||
|
|
||||||
|
const dockerPaths = new Map([
|
||||||
|
[
|
||||||
|
'linux',
|
||||||
|
new Map([
|
||||||
|
['shellCommand', '/bin/bash /dist/entrypoint.sh'],
|
||||||
|
['sshAgent', '/ssh-agent'],
|
||||||
|
['githubHome', '/root'],
|
||||||
|
['githubWorkflow', '/github/workflow'],
|
||||||
|
['githubWorkspace', '/github/workspace'],
|
||||||
|
['stepsPathParent', `${actionFolder}/steps`],
|
||||||
|
['stepsPathContainer', '/steps'],
|
||||||
|
['entrypointPathParent', `${actionFolder}/`],
|
||||||
|
['entrypointPathContainer', '/dist'],
|
||||||
|
['knownHostsParent', ' /home/runner/.ssh/known_hosts'],
|
||||||
|
['knownHostsContainer', '/root/.ssh/known_hosts'],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'win32',
|
||||||
|
new Map([
|
||||||
|
['shellCommand', 'powershell C:\\dist\\entrypoint.ps1'],
|
||||||
|
['sshAgent', 'C:\\ssh-agent'],
|
||||||
|
['githubHome', 'C:\\root'],
|
||||||
|
['githubWorkflow', 'C:\\github\\workflow'],
|
||||||
|
['githubWorkspace', 'C:\\github\\workspace'],
|
||||||
|
['stepsPathParent', `${actionFolder}\\steps`],
|
||||||
|
['stepsPathContainer', 'C:\\steps'],
|
||||||
|
['entrypointPathParent', `${actionFolder}\\`],
|
||||||
|
['entrypointPathContainer', 'C:\\dist'],
|
||||||
|
['knownHostsParent', 'C:\\Users\\Administrator\\.ssh\\known_hosts'],
|
||||||
|
['knownHostsContainer', 'C:\\root\\.ssh\\known_hosts'],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
const currentDockerPath = dockerPaths.get(process.platform);
|
||||||
|
const bindMountZ = process.platform === 'linux' ? ':z' : '';
|
||||||
|
const bindMountRO = process.platform === 'linux' ? ':ro' : '';
|
||||||
|
|
||||||
const command = `docker run \
|
const command = `docker run \
|
||||||
--workdir /github/workspace \
|
--workdir /github/workspace \
|
||||||
--rm \
|
--rm \
|
||||||
|
|
@ -51,7 +89,7 @@ const Docker = {
|
||||||
--env GITHUB_HEAD_REF \
|
--env GITHUB_HEAD_REF \
|
||||||
--env GITHUB_BASE_REF \
|
--env GITHUB_BASE_REF \
|
||||||
--env GITHUB_EVENT_NAME \
|
--env GITHUB_EVENT_NAME \
|
||||||
--env GITHUB_WORKSPACE=/github/workspace \
|
--env GITHUB_WORKSPACE="${currentDockerPath?.get('githubWorkspace')}" \
|
||||||
--env GITHUB_ACTION \
|
--env GITHUB_ACTION \
|
||||||
--env GITHUB_EVENT_PATH \
|
--env GITHUB_EVENT_PATH \
|
||||||
--env RUNNER_OS \
|
--env RUNNER_OS \
|
||||||
|
|
@ -59,18 +97,28 @@ const Docker = {
|
||||||
--env RUNNER_TEMP \
|
--env RUNNER_TEMP \
|
||||||
--env RUNNER_WORKSPACE \
|
--env RUNNER_WORKSPACE \
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
${sshAgent ? `--env SSH_AUTH_SOCK=${currentDockerPath?.get('sshAgent')}` : ''} \
|
||||||
--volume "${githubHome}":"/root:z" \
|
--volume "${githubHome}:${currentDockerPath?.get('githubHome')}${bindMountZ}" \
|
||||||
--volume "${githubWorkflow}":"/github/workflow:z" \
|
--volume "${githubWorkflow}:${currentDockerPath?.get('githubWorkflow')}${bindMountZ}" \
|
||||||
--volume "${workspace}":"/github/workspace:z" \
|
--volume "${workspace}:${currentDockerPath?.get('githubWorkspace')}${bindMountZ}" \
|
||||||
--volume "${actionFolder}/steps":"/steps:z" \
|
--volume "${currentDockerPath?.get('stepsPathParent')}:${currentDockerPath?.get(
|
||||||
--volume "${actionFolder}/entrypoint.sh":"/entrypoint.sh:z" \
|
'stepsPathContainer',
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
)}${bindMountZ}" \
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
--volume "${currentDockerPath?.get('entrypointPathParent')}:${currentDockerPath?.get(
|
||||||
|
'entrypointPathContainer',
|
||||||
|
)}${bindMountZ}" \
|
||||||
|
${sshAgent ? `--volume ${sshAgent}:${currentDockerPath?.get('sshAgent')}` : ''} \
|
||||||
|
${
|
||||||
|
sshAgent
|
||||||
|
? `--volume ${currentDockerPath?.get('knownHostParent')}${currentDockerPath?.get(
|
||||||
|
'knownHostContainer',
|
||||||
|
)}${bindMountRO}`
|
||||||
|
: ''
|
||||||
|
} \
|
||||||
${useHostNetwork ? '--net=host' : ''} \
|
${useHostNetwork ? '--net=host' : ''} \
|
||||||
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
||||||
${image} \
|
${image} \
|
||||||
/bin/bash /entrypoint.sh`;
|
${currentDockerPath?.get('shellCommand')}`;
|
||||||
|
|
||||||
await exec(command, undefined, { silent });
|
await exec(command, undefined, { silent });
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ class ImageTag {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return 'ubuntu';
|
return 'ubuntu';
|
||||||
|
case 'win32':
|
||||||
|
return 'windows';
|
||||||
default:
|
default:
|
||||||
throw new Error('The Operating System of this runner is not yet supported.');
|
throw new Error('The Operating System of this runner is not yet supported.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue