mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-01-29 12:19:06 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0399609b07 | ||
|
|
1c91a3bf31 | ||
|
|
ae7f659e9f | ||
|
|
b781b891ec | ||
|
|
f3a984165e | ||
|
|
d8896dc4f5 | ||
|
|
4051832dc0 | ||
|
|
fe2311ef4b | ||
|
|
37d5ce498f |
@@ -2,4 +2,4 @@
|
|||||||
*
|
*
|
||||||
|
|
||||||
# Files required for the action
|
# Files required for the action
|
||||||
!builder/
|
!action/
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
**/node_modules/**
|
**/node_modules/**
|
||||||
**/builder/**
|
**/action/**
|
||||||
|
|||||||
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
name: Tests
|
name: Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 12.x
|
||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- run: yarn lint
|
- run: yarn lint
|
||||||
- run: yarn test
|
- run: yarn test
|
||||||
- run: yarn build || { echo "build command should always succeed" ; exit 61; }
|
- run: yarn build || { echo "build command should always succeed" ; exit 61; }
|
||||||
- run: yarn build --quiet && git diff --quiet builder || { echo "builder should be auto generated" ; exit 62; }
|
- run: yarn build --quiet && git diff --quiet action || { echo "action should be auto generated" ; git diff action ; exit 62; }
|
||||||
|
|
||||||
buildForAllPlatforms:
|
buildForAllPlatforms:
|
||||||
name: Build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }}
|
name: Build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }}
|
||||||
@@ -48,7 +48,9 @@ jobs:
|
|||||||
# - Switch # Build a Nintendo Switch player.
|
# - Switch # Build a Nintendo Switch player.
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
lfs: true
|
||||||
- uses: actions/cache@v1.1.0
|
- uses: actions/cache@v1.1.0
|
||||||
with:
|
with:
|
||||||
path: ${{ matrix.projectPath }}/Library
|
path: ${{ matrix.projectPath }}/Library
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
**/node_modules/**
|
**/node_modules/**
|
||||||
**/dist/**
|
**/action/**
|
||||||
|
|||||||
99
README.md
99
README.md
@@ -31,8 +31,22 @@ collection repository for workflow documentation and reference implementation.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
#### Setup builder
|
||||||
|
|
||||||
|
By default the enabled scenes from the project's settings will be built.
|
||||||
|
|
||||||
Create or edit the file called `.github/workflows/main.yml` and add a job to it.
|
Create or edit the file called `.github/workflows/main.yml` and add a job to it.
|
||||||
|
|
||||||
|
##### Personal License
|
||||||
|
|
||||||
|
Personal licenses require a one-time manual activation step (per unity version).
|
||||||
|
|
||||||
|
Make sure you
|
||||||
|
[acquire and activate](https://github.com/marketplace/actions/unity-request-activation-file)
|
||||||
|
your license file and add it as a secret.
|
||||||
|
|
||||||
|
Then, define the build step as follows:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: webbertakken/unity-builder@v0.9
|
- uses: webbertakken/unity-builder@v0.9
|
||||||
env:
|
env:
|
||||||
@@ -43,6 +57,75 @@ Create or edit the file called `.github/workflows/main.yml` and add a job to it.
|
|||||||
targetPlatform: WebGL
|
targetPlatform: WebGL
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Professional license
|
||||||
|
|
||||||
|
Professional licenses do not need any manual steps.
|
||||||
|
|
||||||
|
Instead, three variables will need to be set.
|
||||||
|
|
||||||
|
- `UNITY_EMAIL` (should contain the email address for your Unity account)
|
||||||
|
- `UNITY_PASSWORD` (the password that you use to login to Unity)
|
||||||
|
- `UNITY_SERIAL` (the serial provided by Unity)
|
||||||
|
|
||||||
|
Define the build step as follows:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: webbertakken/unity-builder@v0.9
|
||||||
|
env:
|
||||||
|
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||||
|
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||||
|
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
|
||||||
|
with:
|
||||||
|
projectPath: path/to/your/project
|
||||||
|
unityVersion: 2020.X.XXXX
|
||||||
|
targetPlatform: WebGL
|
||||||
|
```
|
||||||
|
|
||||||
|
That is all you need to build your project.
|
||||||
|
|
||||||
|
#### Storing the build
|
||||||
|
|
||||||
|
To be able to access your built files,
|
||||||
|
they need to be uploaded as artifacts.
|
||||||
|
To do this it is recommended to use Github Actions official
|
||||||
|
[upload artifact action](https://github.com/marketplace/actions/upload-artifact)
|
||||||
|
after any build action.
|
||||||
|
|
||||||
|
By default, Builder outputs it's builds to a folder named `build`.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Build
|
||||||
|
path: build
|
||||||
|
```
|
||||||
|
|
||||||
|
Builds can now be downloaded as Artifacts in the Actions tab.
|
||||||
|
|
||||||
|
#### Caching
|
||||||
|
|
||||||
|
In order to make builds run faster, you can cache Library files from previous
|
||||||
|
builds. To do so simply add Github Actions official
|
||||||
|
[cache action](https://github.com/marketplace/actions/cache) before any unity steps.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v1.1.0
|
||||||
|
with:
|
||||||
|
path: path/to/your/project/Library
|
||||||
|
key: Library-MyProjectName-TargetPlatform
|
||||||
|
restore-keys: |
|
||||||
|
Library-MyProjectName-
|
||||||
|
Library-
|
||||||
|
```
|
||||||
|
|
||||||
|
This simple addition could speed up your build by more than 50%.
|
||||||
|
|
||||||
|
## Complete example
|
||||||
|
|
||||||
A complete workflow that builds every available platform could look like this:
|
A complete workflow that builds every available platform could look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -81,7 +164,16 @@ jobs:
|
|||||||
- tvOS # Build to Apple's tvOS platform.
|
- tvOS # Build to Apple's tvOS platform.
|
||||||
- Switch # Build a Nintendo Switch player.
|
- Switch # Build a Nintendo Switch player.
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
lfs: true
|
||||||
|
- uses: actions/cache@v1.1.0
|
||||||
|
with:
|
||||||
|
path: ${{ matrix.projectPath }}/Library
|
||||||
|
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
|
||||||
|
restore-keys: |
|
||||||
|
Library-${{ matrix.projectPath }}-
|
||||||
|
Library-
|
||||||
- uses: webbertakken/unity-builder@v0.9
|
- uses: webbertakken/unity-builder@v0.9
|
||||||
with:
|
with:
|
||||||
projectPath: ${{ matrix.projectPath }}
|
projectPath: ${{ matrix.projectPath }}
|
||||||
@@ -93,10 +185,7 @@ jobs:
|
|||||||
path: build
|
path: build
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Notes:**
|
> **Note:** _Environment variables are set for all jobs in the workflow like this._
|
||||||
>
|
|
||||||
> - Don't forget to replace _<test-project>_ with your project name.
|
|
||||||
> - By default the enabled scenes from the project's settings will be built.
|
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
|
|
||||||
|
|||||||
@@ -32,4 +32,4 @@ branding:
|
|||||||
color: 'gray-dark'
|
color: 'gray-dark'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'builder/index.js'
|
main: 'action/index.js'
|
||||||
|
|||||||
1
action/index.js
Normal file
1
action/index.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -2,12 +2,12 @@
|
|||||||
"name": "unity-builder",
|
"name": "unity-builder",
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
"description": "Build Unity projects for different platforms.",
|
"description": "Build Unity projects for different platforms.",
|
||||||
"main": "builder/index.js",
|
"main": "action/index.js",
|
||||||
"repository": "git@github.com:webbertakken/unity-builder.git",
|
"repository": "git@github.com:webbertakken/unity-builder.git",
|
||||||
"author": "Webber <webber@takken.io>",
|
"author": "Webber <webber@takken.io>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src --out builder --minify",
|
"build": "ncc build src --out action --minify",
|
||||||
"lint": "prettier --check \"src/**/*.js\" && eslint src",
|
"lint": "prettier --check \"src/**/*.js\" && eslint src",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "lint-staged && yarn build && git add builder/index.js"
|
"pre-commit": "lint-staged && yarn build && git add action/index.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
import { Action, Docker, Input, ImageTag, BuildParameters } from './model';
|
import { Action, BuildParameters, Cache, Docker, Input, ImageTag } from './model';
|
||||||
|
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
|
||||||
async function action() {
|
async function action() {
|
||||||
Action.checkCompatibility();
|
Action.checkCompatibility();
|
||||||
|
Cache.verify();
|
||||||
|
|
||||||
const { dockerfile, workspace, builderFolder } = Action;
|
const { dockerfile, workspace, actionFolder } = Action;
|
||||||
const buildParameters = BuildParameters.create(Input.getFromUser());
|
const buildParameters = BuildParameters.create(Input.getFromUser());
|
||||||
const baseImage = new ImageTag(buildParameters);
|
const baseImage = new ImageTag(buildParameters);
|
||||||
|
|
||||||
// Build docker image
|
// Build docker image
|
||||||
const builtImage = await Docker.build({ path: builderFolder, dockerfile, baseImage });
|
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
|
|
||||||
// Run docker image
|
// Run docker image
|
||||||
await Docker.run(builtImage, { workspace, ...buildParameters });
|
await Docker.run(builtImage, { workspace, ...buildParameters });
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ class Action {
|
|||||||
return path.dirname(path.dirname(__filename));
|
return path.dirname(path.dirname(__filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
static get builderFolder() {
|
static get actionFolder() {
|
||||||
return `${Action.rootFolder}/builder`;
|
return `${Action.rootFolder}/action`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get dockerfile() {
|
static get dockerfile() {
|
||||||
return `${Action.builderFolder}/Dockerfile`;
|
return `${Action.actionFolder}/Dockerfile`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get workspace() {
|
static get workspace() {
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ describe('Action', () => {
|
|||||||
expect(fs.existsSync(rootFolder)).toStrictEqual(true);
|
expect(fs.existsSync(rootFolder)).toStrictEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the builder folder', () => {
|
it('returns the action folder', () => {
|
||||||
const { builderFolder } = Action;
|
const { actionFolder } = Action;
|
||||||
|
|
||||||
expect(path.basename(builderFolder)).toStrictEqual('builder');
|
expect(path.basename(actionFolder)).toStrictEqual('action');
|
||||||
expect(fs.existsSync(builderFolder)).toStrictEqual(true);
|
expect(fs.existsSync(actionFolder)).toStrictEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the docker file', () => {
|
it('returns the docker file', () => {
|
||||||
|
|||||||
85
src/model/build-parameters.test.js
Normal file
85
src/model/build-parameters.test.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import BuildParameters from './build-parameters';
|
||||||
|
import Platform from './platform';
|
||||||
|
|
||||||
|
describe('BuildParameters', () => {
|
||||||
|
describe('create', () => {
|
||||||
|
const someParameters = {
|
||||||
|
unityVersion: 'someVersion',
|
||||||
|
targetPlatform: 'somePlatform',
|
||||||
|
projectPath: 'path/to/project',
|
||||||
|
buildName: 'someBuildName',
|
||||||
|
buildsPath: 'someBuildsPath',
|
||||||
|
buildMethod: 'Namespace.Class.Method',
|
||||||
|
customParameters: '-someParam someValue',
|
||||||
|
};
|
||||||
|
|
||||||
|
it('does not throw', () => {
|
||||||
|
expect(() => BuildParameters.create(someParameters)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the version', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).version).toStrictEqual(
|
||||||
|
someParameters.unityVersion,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the platform', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).platform).toStrictEqual(
|
||||||
|
someParameters.targetPlatform,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the project path', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).projectPath).toStrictEqual(
|
||||||
|
someParameters.projectPath,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the build name', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).buildName).toStrictEqual(
|
||||||
|
someParameters.buildName,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the build path', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).buildPath).toStrictEqual(
|
||||||
|
`${someParameters.buildsPath}/${someParameters.targetPlatform}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('build file', () => {
|
||||||
|
it('returns the build file', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).buildFile).toStrictEqual(
|
||||||
|
someParameters.buildName,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each([Platform.types.StandaloneWindows, Platform.types.StandaloneWindows64])(
|
||||||
|
'appends exe for %s',
|
||||||
|
targetPlatform => {
|
||||||
|
expect(
|
||||||
|
BuildParameters.create({ ...someParameters, targetPlatform }).buildFile,
|
||||||
|
).toStrictEqual(`${someParameters.buildName}.exe`);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.each([Platform.types.Android])('appends apk for %s', targetPlatform => {
|
||||||
|
expect(
|
||||||
|
BuildParameters.create({ ...someParameters, targetPlatform }).buildFile,
|
||||||
|
).toStrictEqual(`${someParameters.buildName}.apk`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the build method', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).buildMethod).toStrictEqual(
|
||||||
|
someParameters.buildMethod,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the custom parameters', () => {
|
||||||
|
expect(BuildParameters.create(someParameters).customParameters).toStrictEqual(
|
||||||
|
someParameters.customParameters,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
25
src/model/cache.js
Normal file
25
src/model/cache.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import Action from './action';
|
||||||
|
import Project from './project';
|
||||||
|
|
||||||
|
class Cache {
|
||||||
|
static verify() {
|
||||||
|
if (!fs.existsSync(Project.libraryFolder)) {
|
||||||
|
this.notifyAboutCachingPossibility();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static notifyAboutCachingPossibility() {
|
||||||
|
if (Action.isRunningLocally) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`
|
||||||
|
Library folder does not exist.
|
||||||
|
Consider setting up caching to speed up your workflow
|
||||||
|
If this is not your first build.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Cache;
|
||||||
9
src/model/cache.test.js
Normal file
9
src/model/cache.test.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import Cache from './cache';
|
||||||
|
|
||||||
|
describe('Cache', () => {
|
||||||
|
describe('Verification', () => {
|
||||||
|
it('does not throw', () => {
|
||||||
|
expect(() => Cache.verify()).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -37,14 +37,14 @@ class Docker {
|
|||||||
--env UNITY_EMAIL \
|
--env UNITY_EMAIL \
|
||||||
--env UNITY_PASSWORD \
|
--env UNITY_PASSWORD \
|
||||||
--env UNITY_SERIAL \
|
--env UNITY_SERIAL \
|
||||||
--env UNITY_VERSION=${version} \
|
--env UNITY_VERSION="${version}" \
|
||||||
--env PROJECT_PATH=${projectPath} \
|
--env PROJECT_PATH="${projectPath}" \
|
||||||
--env BUILD_TARGET=${platform} \
|
--env BUILD_TARGET="${platform}" \
|
||||||
--env BUILD_NAME=${buildName} \
|
--env BUILD_NAME="${buildName}" \
|
||||||
--env BUILD_PATH=${buildPath} \
|
--env BUILD_PATH="${buildPath}" \
|
||||||
--env BUILD_FILE=${buildFile} \
|
--env BUILD_FILE="${buildFile}" \
|
||||||
--env BUILD_METHOD=${buildMethod} \
|
--env BUILD_METHOD="${buildMethod}" \
|
||||||
--env CUSTOM_PARAMETERS=${customParameters} \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env HOME=/github/home \
|
--env HOME=/github/home \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
--env GITHUB_SHA \
|
--env GITHUB_SHA \
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import ImageTag from './image-tag';
|
|||||||
|
|
||||||
describe('Docker', () => {
|
describe('Docker', () => {
|
||||||
it('builds', async () => {
|
it('builds', async () => {
|
||||||
const path = Action.builderFolder;
|
const path = Action.actionFolder;
|
||||||
const dockerfile = `${path}/Dockerfile`;
|
const dockerfile = `${path}/Dockerfile`;
|
||||||
const baseImage = new ImageTag({
|
const baseImage = new ImageTag({
|
||||||
repository: '',
|
repository: '',
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import Action from './action';
|
import Action from './action';
|
||||||
import BuildParameters from './build-parameters';
|
import BuildParameters from './build-parameters';
|
||||||
|
import Cache from './cache';
|
||||||
import Docker from './docker';
|
import Docker from './docker';
|
||||||
import Input from './input';
|
import Input from './input';
|
||||||
import ImageTag from './image-tag';
|
import ImageTag from './image-tag';
|
||||||
import Platform from './platform';
|
import Platform from './platform';
|
||||||
|
import Project from './project';
|
||||||
|
import Unity from './unity';
|
||||||
|
|
||||||
export { Action, BuildParameters, Docker, Input, ImageTag, Platform };
|
export { Action, BuildParameters, Cache, Docker, Input, ImageTag, Platform, Project, Unity };
|
||||||
|
|||||||
17
src/model/index.test.js
Normal file
17
src/model/index.test.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import * as Index from '.';
|
||||||
|
|
||||||
|
describe('Index', () => {
|
||||||
|
test.each([
|
||||||
|
'Action',
|
||||||
|
'BuildParameters',
|
||||||
|
'Cache',
|
||||||
|
'Docker',
|
||||||
|
'Input',
|
||||||
|
'ImageTag',
|
||||||
|
'Platform',
|
||||||
|
'Project',
|
||||||
|
'Unity',
|
||||||
|
])('exports %s', exportedModule => {
|
||||||
|
expect(typeof Index[exportedModule]).toStrictEqual('function');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -7,12 +7,16 @@ class Input {
|
|||||||
// Input variables specified in workflows using "with" prop.
|
// Input variables specified in workflows using "with" prop.
|
||||||
const unityVersion = core.getInput('unityVersion');
|
const unityVersion = core.getInput('unityVersion');
|
||||||
const targetPlatform = core.getInput('targetPlatform') || Platform.default;
|
const targetPlatform = core.getInput('targetPlatform') || Platform.default;
|
||||||
const projectPath = core.getInput('projectPath') || '.';
|
const rawProjectPath = core.getInput('projectPath') || '.';
|
||||||
const buildName = core.getInput('buildName') || targetPlatform;
|
const buildName = core.getInput('buildName') || targetPlatform;
|
||||||
const buildsPath = core.getInput('buildsPath') || 'build';
|
const buildsPath = core.getInput('buildsPath') || 'build';
|
||||||
const buildMethod = core.getInput('buildMethod'); // processed in docker file
|
const buildMethod = core.getInput('buildMethod'); // processed in docker file
|
||||||
const customParameters = core.getInput('customParameters') || '';
|
const customParameters = core.getInput('customParameters') || '';
|
||||||
|
|
||||||
|
// Sanitise input
|
||||||
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
||||||
|
|
||||||
|
// Return sanitised input
|
||||||
return {
|
return {
|
||||||
unityVersion,
|
unityVersion,
|
||||||
targetPlatform,
|
targetPlatform,
|
||||||
|
|||||||
@@ -5,5 +5,9 @@ describe('Input', () => {
|
|||||||
it('does not throw', () => {
|
it('does not throw', () => {
|
||||||
expect(() => Input.getFromUser()).not.toThrow();
|
expect(() => Input.getFromUser()).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns an object', () => {
|
||||||
|
expect(typeof Input.getFromUser()).toStrictEqual('object');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
37
src/model/platform.test.js
Normal file
37
src/model/platform.test.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import Platform from './platform';
|
||||||
|
|
||||||
|
describe('Platform', () => {
|
||||||
|
describe('default', () => {
|
||||||
|
it('does not throw', () => {
|
||||||
|
expect(() => Platform.default).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a string', () => {
|
||||||
|
expect(typeof Platform.default).toStrictEqual('string');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a platform', () => {
|
||||||
|
expect(Object.values(Platform.types)).toContain(Platform.default);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('isWindows', () => {
|
||||||
|
it('returns true for windows', () => {
|
||||||
|
expect(Platform.isWindows(Platform.types.StandaloneWindows64)).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false for MacOS', () => {
|
||||||
|
expect(Platform.isWindows(Platform.types.StandaloneOSX)).toStrictEqual(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('isAndroid', () => {
|
||||||
|
it('returns true for Android', () => {
|
||||||
|
expect(Platform.isAndroid(Platform.types.Android)).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false for Windows', () => {
|
||||||
|
expect(Platform.isAndroid(Platform.types.StandaloneWindows64)).toStrictEqual(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
23
src/model/project.js
Normal file
23
src/model/project.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import Unity from './unity';
|
||||||
|
import Input from './input';
|
||||||
|
import Action from './action';
|
||||||
|
|
||||||
|
class Project {
|
||||||
|
static get relativePath() {
|
||||||
|
const { projectPath } = Input.getFromUser();
|
||||||
|
|
||||||
|
return `${projectPath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get absolutePath() {
|
||||||
|
const { workspace } = Action;
|
||||||
|
|
||||||
|
return `${workspace}/${this.relativePath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get libraryFolder() {
|
||||||
|
return `${this.relativePath}/${Unity.libraryFolder}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Project;
|
||||||
33
src/model/project.test.js
Normal file
33
src/model/project.test.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import Project from './project';
|
||||||
|
|
||||||
|
describe('Platform', () => {
|
||||||
|
describe('relativePath', () => {
|
||||||
|
it('does not throw', () => {
|
||||||
|
expect(() => Project.relativePath).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a string', () => {
|
||||||
|
expect(typeof Project.relativePath).toStrictEqual('string');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('absolutePath', () => {
|
||||||
|
it('does not throw', () => {
|
||||||
|
expect(() => Project.absolutePath).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a string', () => {
|
||||||
|
expect(typeof Project.absolutePath).toStrictEqual('string');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('libraryFolder', () => {
|
||||||
|
it('does not throw', () => {
|
||||||
|
expect(() => Project.libraryFolder).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a string', () => {
|
||||||
|
expect(typeof Project.libraryFolder).toStrictEqual('string');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
7
src/model/unity.js
Normal file
7
src/model/unity.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class Unity {
|
||||||
|
static get libraryFolder() {
|
||||||
|
return 'Library';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Unity;
|
||||||
13
src/model/unity.test.js
Normal file
13
src/model/unity.test.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import Unity from './unity';
|
||||||
|
|
||||||
|
describe('Unity', () => {
|
||||||
|
describe('libraryFolder', () => {
|
||||||
|
it('does not throw', () => {
|
||||||
|
expect(() => Unity.libraryFolder).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a string', () => {
|
||||||
|
expect(typeof Unity.libraryFolder).toStrictEqual('string');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user