Skip to content

Commit

Permalink
feat: Add support for macos game-ci#211
Browse files Browse the repository at this point in the history
  • Loading branch information
Kariaro committed Dec 27, 2022
1 parent d982116 commit 97a959b
Show file tree
Hide file tree
Showing 12 changed files with 311 additions and 39 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
# - run: yarn build --quiet && git diff --quiet action || { echo "ERROR - index.js is different from repository version. Forgot to run `yarn build`?" ; exit 62; }

testAllModesLikeInTheReadme:
name: Test in ${{ matrix.testMode }} on version ${{ matrix.unityVersion }}
runs-on: ubuntu-latest
name: Test in ${{ matrix.testMode }} on version ${{ matrix.unityVersion }} on system ${{ matrix.system }}
runs-on: ${{ matrix.system }}
strategy:
fail-fast: false
matrix:
Expand All @@ -36,6 +36,9 @@ jobs:
testMode:
- playmode
- editmode
system:
- ubuntu-latest
- macos-latest
steps:
###########################
# Checkout #
Expand Down
152 changes: 136 additions & 16 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.

54 changes: 36 additions & 18 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@actions/core';
import { Action, Docker, ImageTag, Input, Output, ResultsCheck } from './model';
import { Action, Docker, ImageTag, Input, MacRunner, Output, ResultsCheck } from './model';

export async function run() {
try {
Expand All @@ -26,23 +26,41 @@ export async function run() {
const runnerContext = Action.runnerContext();

try {
await Docker.run(baseImage, {
actionFolder,
editorVersion,
workspace,
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
chownFilesTo,
unityLicensingServer,
...runnerContext,
});
await (process.platform === 'darwin'
? MacRunner.run({
actionFolder,
editorVersion,
workspace,
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
chownFilesTo,
unityLicensingServer,
...runnerContext,
})
: Docker.run(baseImage, {
actionFolder,
editorVersion,
workspace,
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
chownFilesTo,
unityLicensingServer,
...runnerContext,
}));
} finally {
await Output.setArtifactsPath(artifactsPath);
await Output.setCoveragePath('CodeCoverage');
Expand Down
6 changes: 5 additions & 1 deletion src/model/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import path from 'path';
describe('Action', () => {
describe('compatibility check', () => {
it('throws for anything other than linux or windows', () => {
if (process.platform !== 'linux' && process.platform !== 'win32') {
if (
process.platform !== 'linux' &&
process.platform !== 'win32' &&
process.platform !== 'darwin'
) {
expect(() => Action.checkCompatibility()).toThrow();
} else {
expect(() => Action.checkCompatibility()).not.toThrow();
Expand Down
2 changes: 1 addition & 1 deletion src/model/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface RunnerContext {

const Action = {
get supportedPlatforms() {
return ['linux', 'win32'];
return ['linux', 'win32', 'darwin'];
},

get isRunningLocally() {
Expand Down
4 changes: 4 additions & 0 deletions src/model/image-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class ImageTag {
return 'ubuntu';
case 'win32':
return 'windows';
case 'darwin':
return 'macos';
default:
throw new Error(
`The Operating System of this runner, "${platform}", is not yet supported.`,
Expand All @@ -71,6 +73,8 @@ class ImageTag {
return Platform.types.StandaloneLinux64;
case 'win32':
return Platform.types.StandaloneWindows;
case 'darwin':
return Platform.types.StandaloneOSX;
default:
throw new Error(
`The Operating System of this runner, "${platform}", is not yet supported.`,
Expand Down
1 change: 1 addition & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export { default as Action } from './action';
export { default as Docker } from './docker';
export { default as ImageTag } from './image-tag';
export { default as Input } from './input';
export { default as MacRunner } from './mac-runner';
export { default as Output } from './output';
export { default as ResultsCheck } from './results-check';
15 changes: 15 additions & 0 deletions src/model/mac-runner.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Action from './action';
import MacRunner from './mac-runner';

describe('MacRunner', () => {
it.skip('runs', async () => {
const parameters = {
workspace: Action.rootFolder,
projectPath: `${Action.rootFolder}/test-project`,
buildName: 'someBuildName',
buildsPath: 'build',
method: '',
};
await MacRunner.run(parameters);
});
});
Loading

0 comments on commit 97a959b

Please sign in to comment.