Compare commits

...

2 Commits

Author SHA1 Message Date
Sascha Mann
fac69f5780 Add TODO 2020-06-25 13:46:40 +02:00
Sascha Mann
ead3831d7a Cache artifacts directory by default 2020-06-25 13:39:22 +02:00
7 changed files with 169 additions and 7 deletions

View File

@@ -13,6 +13,13 @@ inputs:
description: 'Display InteractiveUtils.versioninfo() after installing'
required: false
default: 'false'
cache-artifacts:
description: 'Cache ~/.julia/artifacts. Will fail if no file matches **/Project.toml.'
required: false
default: 'true'
outputs:
artifacts-cache-id:
description: 'The cache id of the artifacts cache.'
runs:
using: 'node12'
main: 'dist/index.js'

40
lib/caching.js generated Normal file
View File

@@ -0,0 +1,40 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const cache = __importStar(require("@actions/cache"));
const glob = __importStar(require("@actions/glob"));
const path = __importStar(require("path"));
// TODO: Change to hashFiles once https://github.com/actions/toolkit/issues/472 has been resolved
const md5File = __importStar(require("md5-file"));
const JULIA_HOME = path.join(`${process.env.HOME}`, '.julia');
/**
* Cache the ~/.julia/artifacts directory.
*/
function cacheArtifacts() {
return __awaiter(this, void 0, void 0, function* () {
// TODO: Add error handling in case no Project.toml files are present
const projectFiles = yield (yield glob.create('**/Project.toml')).glob();
let projectsHash = '';
projectFiles.forEach((f) => {
projectsHash.concat('-', md5File.sync(f));
});
const paths = [path.join(JULIA_HOME, 'artifacts')];
const key = `artifacts-${process.env.RUNNER_OS}-${projectsHash}`;
return cache.saveCache(paths, key);
});
}
exports.cacheArtifacts = cacheArtifacts;

7
lib/setup-julia.js generated
View File

@@ -20,6 +20,7 @@ const exec = __importStar(require("@actions/exec"));
const tc = __importStar(require("@actions/tool-cache"));
const path = __importStar(require("path"));
const installer = __importStar(require("./installer"));
const jlcache = __importStar(require("./caching"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
@@ -49,6 +50,12 @@ function run() {
if (core.getInput('show-versioninfo') == 'true') {
exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
}
// Create caches
if (core.getInput('cache-artifacts') == 'true') {
core.debug('caching artifacts directory...');
const cacheId = yield jlcache.cacheArtifacts();
core.setOutput('artifacts-cache-id', cacheId.toString());
}
}
catch (error) {
core.setFailed(error.message);

85
package-lock.json generated
View File

@@ -1,9 +1,48 @@
{
"name": "setup-julia",
"version": "1.1.5",
"version": "1.1.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@actions/cache": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-0.2.1.tgz",
"integrity": "sha512-CV2D9zp+d+nL7o6XK/I7vVh350JglPMp/jHi9ppRUkdBHPUeP0UHVUfygZaAs8WmxhhWY1MI0gWah+t0QYu3Fg==",
"requires": {
"@actions/core": "^1.2.4",
"@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0",
"@actions/http-client": "^1.0.8",
"@actions/io": "^1.0.1",
"semver": "^6.1.0",
"uuid": "^3.3.3"
},
"dependencies": {
"@actions/core": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.4.tgz",
"integrity": "sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg=="
},
"@actions/exec": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz",
"integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==",
"requires": {
"@actions/io": "^1.0.1"
}
},
"@actions/io": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz",
"integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg=="
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
}
}
},
"@actions/core": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.0.0.tgz",
@@ -14,6 +53,37 @@
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.0.tgz",
"integrity": "sha512-nquH0+XKng+Ll7rZfCojN7NWSbnGh+ltwUJhzfbLkmOJgxocGX2/yXcZLMyT9fa7+tByEow/NSTrBExNlEj9fw=="
},
"@actions/glob": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.1.0.tgz",
"integrity": "sha512-lx8SzyQ2FE9+UUvjqY1f28QbTJv+w8qP7kHHbfQRhphrlcx0Mdmm1tZdGJzfxv1jxREa/sLW4Oy8CbGQKCJySA==",
"requires": {
"@actions/core": "^1.2.0",
"minimatch": "^3.0.4"
},
"dependencies": {
"@actions/core": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.4.tgz",
"integrity": "sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg=="
}
}
},
"@actions/http-client": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz",
"integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==",
"requires": {
"tunnel": "0.0.6"
},
"dependencies": {
"tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
}
}
},
"@actions/io": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.0.tgz",
@@ -1738,8 +1808,7 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"base": {
"version": "0.11.2",
@@ -1825,7 +1894,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -2071,8 +2139,7 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"convert-source-map": {
"version": "1.7.0",
@@ -5315,6 +5382,11 @@
"object-visit": "^1.0.0"
}
},
"md5-file": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/md5-file/-/md5-file-5.0.0.tgz",
"integrity": "sha512-xbEFXCYVWrSx/gEKS1VPlg84h/4L20znVIulKw6kMfmBUAZNAnF00eczz9ICMl+/hjQGo5KSXRxbL/47X3rmMw=="
},
"merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@@ -5361,7 +5433,6 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}

View File

@@ -21,10 +21,13 @@
"author": "Sascha Mann <git@mail.saschamann.eu>",
"license": "MIT",
"dependencies": {
"@actions/cache": "^0.2.1",
"@actions/core": "^1.0.0",
"@actions/exec": "^1.0.0",
"@actions/glob": "^0.1.0",
"@actions/io": "^1.0.0",
"@actions/tool-cache": "^1.0.0",
"md5-file": "^5.0.0",
"semver": "^6.3.0"
},
"devDependencies": {

26
src/caching.ts Normal file
View File

@@ -0,0 +1,26 @@
import * as cache from '@actions/cache'
import * as glob from '@actions/glob'
import * as path from 'path'
// TODO: Change to hashFiles once https://github.com/actions/toolkit/issues/472 has been resolved
import * as md5File from 'md5-file'
const JULIA_HOME = path.join(`${process.env.HOME}`, '.julia')
/**
* Cache the ~/.julia/artifacts directory.
*/
export async function cacheArtifacts(): Promise<number> {
// TODO: Add error handling in case no Project.toml files are present
const projectFiles = await (await glob.create('**/Project.toml')).glob()
let projectsHash = ''
projectFiles.forEach((f) => {
projectsHash.concat('-', md5File.sync(f))
})
const paths = [path.join(JULIA_HOME, 'artifacts')]
const key = `artifacts-${process.env.RUNNER_OS}-${projectsHash}`
return cache.saveCache(paths, key)
}

View File

@@ -5,6 +5,7 @@ import * as tc from '@actions/tool-cache'
import * as path from 'path'
import * as installer from './installer'
import * as jlcache from './caching'
async function run() {
try {
@@ -39,6 +40,13 @@ async function run() {
if (core.getInput('show-versioninfo') == 'true') {
exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()'])
}
// Create caches
if (core.getInput('cache-artifacts') == 'true') {
core.debug('caching artifacts directory...')
const cacheId = await jlcache.cacheArtifacts()
core.setOutput('artifacts-cache-id', cacheId.toString())
}
} catch (error) {
core.setFailed(error.message)
}