Add cache for Library
parent
d5552eaa01
commit
1ce0de19e0
File diff suppressed because one or more lines are too long
|
@ -14,7 +14,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.0",
|
||||||
"@actions/exec": "1.0.2",
|
"@actions/exec": "1.0.2",
|
||||||
"@actions/github": "^2.0.0"
|
"@actions/github": "^2.0.0",
|
||||||
|
"@actions/tool-cache": "1.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "7.7.5",
|
"@babel/cli": "7.7.5",
|
||||||
|
|
12
src/index.js
12
src/index.js
|
@ -1,14 +1,13 @@
|
||||||
import Action from './model/action';
|
import { Action, Docker, Input, ImageTag, BuildParameters, Cache } from './model';
|
||||||
import Docker from './model/docker';
|
|
||||||
import ImageTag from './model/image-tag';
|
|
||||||
import Input from './model/input';
|
|
||||||
import BuildParameters from './model/build-parameters';
|
|
||||||
|
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
|
||||||
async function action() {
|
async function action() {
|
||||||
Action.checkCompatibility();
|
Action.checkCompatibility();
|
||||||
|
|
||||||
|
// Load cache
|
||||||
|
await Cache.load();
|
||||||
|
|
||||||
const { dockerfile, workspace, builderFolder } = Action;
|
const { dockerfile, workspace, builderFolder } = Action;
|
||||||
const buildParameters = BuildParameters.create(Input.getFromUser());
|
const buildParameters = BuildParameters.create(Input.getFromUser());
|
||||||
const baseImage = new ImageTag(buildParameters);
|
const baseImage = new ImageTag(buildParameters);
|
||||||
|
@ -18,6 +17,9 @@ async function action() {
|
||||||
|
|
||||||
// Run docker image
|
// Run docker image
|
||||||
await Docker.run(builtImage, { workspace, ...buildParameters });
|
await Docker.run(builtImage, { workspace, ...buildParameters });
|
||||||
|
|
||||||
|
// Save cache
|
||||||
|
await Cache.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
action().catch(error => {
|
action().catch(error => {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import Input from './input';
|
||||||
|
import Unity from './unity';
|
||||||
|
|
||||||
|
const tc = require('@actions/tool-cache');
|
||||||
|
const core = require('@actions/core');
|
||||||
|
|
||||||
|
class Cache {
|
||||||
|
static get libraryKey() {
|
||||||
|
const { projectPath } = Input.getFromUser();
|
||||||
|
|
||||||
|
return `${projectPath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async load() {
|
||||||
|
const libraryFolder = await tc.find('library', this.libraryKey);
|
||||||
|
|
||||||
|
await core.addPath(libraryFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async save() {
|
||||||
|
await tc.cacheDir(Unity.libraryFolder, 'library', this.libraryKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Cache;
|
|
@ -0,0 +1,9 @@
|
||||||
|
import Cache from './cache';
|
||||||
|
|
||||||
|
describe('Cache', () => {
|
||||||
|
describe('keys', () => {
|
||||||
|
it('returns a string', () => {
|
||||||
|
expect(typeof Cache.libraryKey).toBe('string');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,10 @@
|
||||||
|
import Action from './action';
|
||||||
|
import BuildParameters from './build-parameters';
|
||||||
|
import Cache from './cache';
|
||||||
|
import Docker from './docker';
|
||||||
|
import Input from './input';
|
||||||
|
import ImageTag from './image-tag';
|
||||||
|
import Platform from './platform';
|
||||||
|
import Unity from './unity';
|
||||||
|
|
||||||
|
export { Action, BuildParameters, Cache, Docker, Input, ImageTag, Platform, Unity };
|
|
@ -7,7 +7,7 @@ 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 projectPath = 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
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
class Unity {
|
||||||
|
static get libraryFolder() {
|
||||||
|
return 'Library';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Unity;
|
33
yarn.lock
33
yarn.lock
|
@ -14,6 +14,13 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/io" "^1.0.1"
|
"@actions/io" "^1.0.1"
|
||||||
|
|
||||||
|
"@actions/exec@^1.0.0":
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.0.3.tgz#b967f8700d6ff011dcc91243b58bafc1bb9ab95f"
|
||||||
|
integrity sha512-TogJGnueOmM7ntCi0ASTUj4LapRRtDfj57Ja4IhPmg2fls28uVOPbAn8N+JifaOumN2UG3oEO/Ixek2A4NcYSA==
|
||||||
|
dependencies:
|
||||||
|
"@actions/io" "^1.0.1"
|
||||||
|
|
||||||
"@actions/github@^2.0.0":
|
"@actions/github@^2.0.0":
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@actions/github/-/github-2.0.0.tgz#5b066b1a8747bbf48d47a058d9c241a2e37d5ee7"
|
resolved "https://registry.yarnpkg.com/@actions/github/-/github-2.0.0.tgz#5b066b1a8747bbf48d47a058d9c241a2e37d5ee7"
|
||||||
|
@ -22,11 +29,30 @@
|
||||||
"@octokit/graphql" "^4.3.1"
|
"@octokit/graphql" "^4.3.1"
|
||||||
"@octokit/rest" "^16.15.0"
|
"@octokit/rest" "^16.15.0"
|
||||||
|
|
||||||
|
"@actions/http-client@^1.0.3":
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.3.tgz#b5239d3d8c72378bdcef4d26bb15fa2a01d537fd"
|
||||||
|
integrity sha512-wFwh1U4adB/Zsk4cc9kVqaBOHoknhp/pJQk+aWTocbAZWpIl4Zx/At83WFRLXvxB+5HVTWOACM6qjULMZfQSfw==
|
||||||
|
dependencies:
|
||||||
|
tunnel "0.0.6"
|
||||||
|
|
||||||
"@actions/io@^1.0.1":
|
"@actions/io@^1.0.1":
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.1.tgz#81a9418fe2bbdef2d2717a8e9f85188b9c565aca"
|
resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.1.tgz#81a9418fe2bbdef2d2717a8e9f85188b9c565aca"
|
||||||
integrity sha512-rhq+tfZukbtaus7xyUtwKfuiCRXd1hWSfmJNEpFgBQJ4woqPEpsBw04awicjwz9tyG2/MVhAEMfVn664Cri5zA==
|
integrity sha512-rhq+tfZukbtaus7xyUtwKfuiCRXd1hWSfmJNEpFgBQJ4woqPEpsBw04awicjwz9tyG2/MVhAEMfVn664Cri5zA==
|
||||||
|
|
||||||
|
"@actions/tool-cache@1.3.1":
|
||||||
|
version "1.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-1.3.1.tgz#0db440cefaa7d797d28e2892065b04bfcc1b697f"
|
||||||
|
integrity sha512-sKoEJv0/c7WzjPEq2PO12Sc8QdEp58XIBHMm3c4lUn/iZWgLz9HBeCuFGpLQjDvXJNfLZ4g+WD+rMjgOmpH4Ag==
|
||||||
|
dependencies:
|
||||||
|
"@actions/core" "^1.2.0"
|
||||||
|
"@actions/exec" "^1.0.0"
|
||||||
|
"@actions/http-client" "^1.0.3"
|
||||||
|
"@actions/io" "^1.0.1"
|
||||||
|
semver "^6.1.0"
|
||||||
|
uuid "^3.3.2"
|
||||||
|
|
||||||
"@babel/cli@7.7.5":
|
"@babel/cli@7.7.5":
|
||||||
version "7.7.5"
|
version "7.7.5"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.7.5.tgz#25702cc65418efc06989af3727897b9f4c8690b6"
|
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.7.5.tgz#25702cc65418efc06989af3727897b9f4c8690b6"
|
||||||
|
@ -5089,7 +5115,7 @@ semver@7.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
|
||||||
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
|
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
|
||||||
|
|
||||||
semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
|
semver@^6.0.0, semver@^6.1.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
|
||||||
version "6.3.0"
|
version "6.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||||
|
@ -5583,6 +5609,11 @@ tunnel-agent@^0.6.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
safe-buffer "^5.0.1"
|
safe-buffer "^5.0.1"
|
||||||
|
|
||||||
|
tunnel@0.0.6:
|
||||||
|
version "0.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
|
||||||
|
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
|
||||||
|
|
||||||
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
|
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
|
||||||
version "0.14.5"
|
version "0.14.5"
|
||||||
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
|
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
|
||||||
|
|
Loading…
Reference in New Issue