Skip to content
Merged
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
2 changes: 1 addition & 1 deletion action/index.js

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: '70...100'

status:
patch:
default:
# basic
target: auto
threshold: 100% # don't require patch to have coverage per se
base: auto

project:
default:
# basic
target: auto
threshold: 5%
base: auto
flags:
- unit
paths:
- 'src'

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: 'reach,diff,flags,tree'
behavior: default
require_changes: no
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
"test": "jest"
},
"dependencies": {
"@actions/core": "^1.2.2",
"@actions/exec": "1.0.3",
"@actions/core": "^1.2.4",
"@actions/exec": "1.0.4",
"@actions/github": "^2.1.1"
},
"devDependencies": {
"@babel/cli": "7.8.4",
"@babel/core": "7.8.7",
"@babel/preset-env": "7.8.7",
"@zeit/ncc": "0.21.1",
"@babel/core": "7.9.6",
"@babel/preset-env": "7.9.6",
"@zeit/ncc": "0.22.1",
"babel-eslint": "10.1.0",
"eslint": "6.8.0",
"eslint-config-airbnb": "18.0.1",
"eslint-config-prettier": "6.10.0",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "2.20.1",
"eslint-config-airbnb": "18.1.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-flowtype": "4.7.0",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-prettier": "3.1.2",
"eslint-plugin-prettier": "3.1.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-unicorn": "17.1.0",
"husky": "4.2.3",
"jest": "25.1.0",
"lint-staged": "10.0.8",
"eslint-plugin-unicorn": "19.0.1",
"husky": "4.2.5",
"jest": "25.5.3",
"lint-staged": "10.2.2",
"lodash-es": "4.17.15",
"prettier": "1.19.1"
"prettier": "2.0.5"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ async function action() {
await Docker.run(builtImage, { workspace, ...buildParameters });
}

action().catch(error => {
action().catch((error) => {
core.setFailed(error.message);
});
2 changes: 0 additions & 2 deletions src/model/__snapshots__/versioning.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

exports[`Versioning determineVersion throws for invalid strategy 0 1`] = `"Versioning strategy should be one of None, Semantic, Tag, Custom."`;

exports[`Versioning determineVersion throws for invalid strategy null 1`] = `"Versioning strategy should be one of None, Semantic, Tag, Custom."`;

exports[`Versioning determineVersion throws for invalid strategy somethingRandom 1`] = `"Versioning strategy should be one of None, Semantic, Tag, Custom."`;

exports[`Versioning determineVersion throws for invalid strategy undefined 1`] = `"Versioning strategy should be one of None, Semantic, Tag, Custom."`;
4 changes: 2 additions & 2 deletions src/model/build-parameters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ describe('BuildParameters', () => {

test.each([Platform.types.StandaloneWindows, Platform.types.StandaloneWindows64])(
'appends exe for %s',
targetPlatform => {
(targetPlatform) => {
expect(
BuildParameters.create({ ...someParameters, targetPlatform }).buildFile,
).toStrictEqual(`${someParameters.buildName}.exe`);
},
);

test.each([Platform.types.Android])('appends apk for %s', targetPlatform => {
test.each([Platform.types.Android])('appends apk for %s', (targetPlatform) => {
expect(
BuildParameters.create({ ...someParameters, targetPlatform }).buildFile,
).toStrictEqual(`${someParameters.buildName}.apk`);
Expand Down
4 changes: 2 additions & 2 deletions src/model/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Docker {
--build-arg IMAGE=${baseImage} \
--tag ${tag}`;

await exec(command, null, { silent });
await exec(command, undefined, { silent });

return tag;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ class Docker {
--volume "${workspace}":"/github/workspace" \
${image}`;

await exec(command, null, { silent });
await exec(command, undefined, { silent });
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/error/command-execution-error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('CommandExecutionError', () => {
expect(() => new CommandExecutionError()).not.toThrow();
});

test.each([1, 'one', { name: '!' }])('Displays title %s', message => {
test.each([1, 'one', { name: '!' }])('Displays title %s', (message) => {
const error = new CommandExecutionError(message);

expect(error.name).toStrictEqual('CommandExecutionError');
Expand Down
2 changes: 1 addition & 1 deletion src/model/error/not-implemented-exception.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('NotImplementedException', () => {
expect(() => new NotImplementedException()).not.toThrow();
});

test.each([1, 'one', { name: '!' }])('Displays title %s', message => {
test.each([1, 'one', { name: '!' }])('Displays title %s', (message) => {
const error = new NotImplementedException(message);

expect(error.name).toStrictEqual('NotImplementedException');
Expand Down
2 changes: 1 addition & 1 deletion src/model/error/validation-error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('ValidationError', () => {
expect(() => new ValidationError()).not.toThrow();
});

test.each([1, 'one', { name: '!' }])('Displays title %s', message => {
test.each([1, 'one', { name: '!' }])('Displays title %s', (message) => {
const error = new ValidationError(message);

expect(error.name).toStrictEqual('ValidationError');
Expand Down
6 changes: 3 additions & 3 deletions src/model/image-tag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ describe('UnityImageVersion', () => {
expect(image.builderPlatform).toStrictEqual(some.builderPlatform);
});

test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', version => {
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', (version) => {
expect(() => new ImageTag({ version, platform: some.platform })).not.toThrow();
});

test.each(['some version', '', 1, null])('throws for incorrect versions %p', version => {
test.each(['some version', '', 1])('throws for incorrect versions %p', (version) => {
const { platform } = some;
expect(() => new ImageTag({ version, platform })).toThrow();
});

test.each([undefined, 'nonExisting'])('throws for unsupported target %p', platform => {
test.each([undefined, 'nonExisting'])('throws for unsupported target %p', (platform) => {
expect(() => new ImageTag({ platform })).toThrow();
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/model/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Index', () => {
'Platform',
'Project',
'Unity',
])('exports %s', exportedModule => {
])('exports %s', (exportedModule) => {
expect(Index[exportedModule]).toBeEitherAFunctionOrAnObject();
});
});
6 changes: 3 additions & 3 deletions src/model/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ class System {
let debug = '';

const listeners = {
stdout: dataBuffer => {
stdout: (dataBuffer) => {
result += dataBuffer.toString();
},
stderr: dataBuffer => {
stderr: (dataBuffer) => {
error += dataBuffer.toString();
},
debug: dataString => {
debug: (dataString) => {
debug += dataString.toString();
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/model/versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ export default class Versioning {
static async getTotalNumberOfCommits() {
const numberOfCommitsAsString = await System.run('git', ['rev-list', '--count', 'HEAD']);

return parseInt(numberOfCommitsAsString, 10);
return Number.parseInt(numberOfCommitsAsString, 10);
}
}
38 changes: 25 additions & 13 deletions src/model/versioning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,33 @@ describe('Versioning', () => {
});
});

describe('headRef', () => {
it('does not throw', () => {
expect(() => Versioning.headRef).not.toThrow();
});
});

describe('ref', () => {
it('does not throw', () => {
expect(() => Versioning.ref).not.toThrow();
});
});

describe('descriptionRegex', () => {
it('is a valid regex', () => {
expect(Versioning.descriptionRegex).toBeInstanceOf(RegExp);
});

test.each(['v1.1-1-g12345678', 'v0.1-2-g12345678', 'v0.0-500-gA9B6C3D0-dirty'])(
'is happy with valid %s',
description => {
(description) => {
expect(Versioning.descriptionRegex.test(description)).toBeTruthy();
},
);

test.each([null, undefined, 'v0', 'v0.1', 'v0.1.2', 'v0.1-2', 'v0.1-2-g'])(
test.each([undefined, 'v0', 'v0.1', 'v0.1.2', 'v0.1-2', 'v0.1-2-g'])(
'does not like %s',
description => {
(description) => {
expect(Versioning.descriptionRegex.test(description)).toBeFalsy();
// Also never expect without the v to work for any of these cases.
expect(Versioning.descriptionRegex.test(description?.substr(1))).toBeFalsy();
Expand All @@ -101,9 +113,9 @@ describe('Versioning', () => {
});

describe('determineVersion', () => {
test.each([null, undefined, 0, 'somethingRandom'])(
test.each([undefined, 0, 'somethingRandom'])(
'throws for invalid strategy %s',
async strategy => {
async (strategy) => {
await expect(Versioning.determineVersion(strategy)).rejects.toThrowErrorMatchingSnapshot();
},
);
Expand All @@ -117,9 +129,9 @@ describe('Versioning', () => {
});

describe('custom strategy', () => {
test.each([null, undefined, 0, 'v0.1', '1', 'CamelCase', 'dashed-version'])(
test.each([undefined, 0, 'v0.1', '1', 'CamelCase', 'dashed-version'])(
'returns the inputVersion for %s',
async inputVersion => {
async (inputVersion) => {
await expect(Versioning.determineVersion('Custom', inputVersion)).resolves.toStrictEqual(
inputVersion,
);
Expand Down Expand Up @@ -198,16 +210,16 @@ describe('Versioning', () => {
describe('fetch', () => {
it('awaits the command', async () => {
jest.spyOn(core, 'warning').mockImplementation(() => {});
jest.spyOn(System, 'run').mockResolvedValue(null);
jest.spyOn(System, 'run').mockResolvedValue(undefined);
await expect(Versioning.fetch()).resolves.not.toThrow();
});

it('falls back to the second strategy when the first fails', async () => {
jest.spyOn(core, 'warning').mockImplementation(() => {});
const gitFetch = jest
.spyOn(System, 'run')
.mockResolvedValue(null)
.mockRejectedValueOnce(null);
.mockResolvedValue(undefined)
.mockRejectedValueOnce(undefined);

await expect(Versioning.fetch()).resolves.not.toThrow();
expect(gitFetch).toHaveBeenCalledTimes(2);
Expand All @@ -216,7 +228,7 @@ describe('Versioning', () => {

describe('generateSemanticVersion', () => {
it('returns a proper version from description', async () => {
jest.spyOn(System, 'run').mockResolvedValue(null);
jest.spyOn(System, 'run').mockResolvedValue(undefined);
jest.spyOn(core, 'info').mockImplementation(() => {});
jest.spyOn(Versioning, 'isDirty').mockResolvedValue(false);
jest.spyOn(Versioning, 'hasAnyVersionTags').mockResolvedValue(true);
Expand All @@ -232,15 +244,15 @@ describe('Versioning', () => {
});

it('throws when dirty', async () => {
jest.spyOn(System, 'run').mockResolvedValue(null);
jest.spyOn(System, 'run').mockResolvedValue(undefined);
jest.spyOn(core, 'info').mockImplementation(() => {});
jest.spyOn(Versioning, 'isDirty').mockResolvedValue(true);
await expect(Versioning.generateSemanticVersion()).rejects.toThrowError();
});

it('falls back to commits only, when no tags are present', async () => {
const commits = Math.round(Math.random() * 10);
jest.spyOn(System, 'run').mockResolvedValue(null);
jest.spyOn(System, 'run').mockResolvedValue(undefined);
jest.spyOn(core, 'info').mockImplementation(() => {});
jest.spyOn(Versioning, 'isDirty').mockResolvedValue(false);
jest.spyOn(Versioning, 'hasAnyVersionTags').mockResolvedValue(false);
Expand Down
Loading