Skip to content

Commit

Permalink
release v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Sep 5, 2019
1 parent 6a4e2d1 commit c77e145
Show file tree
Hide file tree
Showing 176 changed files with 13,575 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/node_modules/
/lib/
/__test__/runner/
/__test__/runner/
46 changes: 46 additions & 0 deletions lib/__test__/installer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use strict";
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 io = require("@actions/io");
const path = require("path");
const os = require("os");
const fs = require("fs");
const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
// const dataDir = path.join(__dirname, 'data');
process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir;
const installer = __importStar(require("../src/installer"));
const IS_WINDOWS = process.platform === 'win32';
describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 100000);
afterAll(async () => {
try {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}
catch {
console.log('Failed to remove test directories');
}
}, 100000);
it('Acquires version of Perl if no matching version is installed', async () => {
await installer.getPerl('5.30');
const perlDir = path.join(toolDir, 'perl', '5.30', os.arch());
expect(fs.existsSync(`${perlDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(perlDir, 'bin', 'perl.exe'))).toBe(true);
}
else {
expect(fs.existsSync(path.join(perlDir, 'bin', 'perl'))).toBe(true);
}
}, 100000);
});
11 changes: 11 additions & 0 deletions lib/installer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
async function getPerl(version) {
await acquirePerl(version);
}
exports.getPerl = getPerl;
async function acquirePerl(version) {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
}
26 changes: 26 additions & 0 deletions lib/setup-perl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";
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 core = __importStar(require("@actions/core"));
const installer = __importStar(require("./installer"));
const path = __importStar(require("path"));
async function run() {
try {
const version = core.getInput('perl-version');
if (version) {
await installer.getPerl(version);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'perl.json')}`);
}
catch (error) {
core.setFailed(error.message);
}
}
run();
72 changes: 72 additions & 0 deletions lib/src/installer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use strict";
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 });
// Load tempDirectory before it gets wiped by tool-cache
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
const core = __importStar(require("@actions/core"));
const tc = __importStar(require("@actions/tool-cache"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const actionVersion = 'v0.0.1-alpha';
const osPlat = os.platform();
const osArch = os.arch();
if (!tempDirectory) {
let baseLocation;
if (process.platform === 'win32') {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else if (process.platform === 'darwin') {
baseLocation = '/Users';
}
else {
baseLocation = '/home';
}
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
async function getPerl(version) {
await acquirePerl(version);
}
exports.getPerl = getPerl;
async function acquirePerl(version) {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
const fileName = getFileName(version);
const downloadUrl = getDownloadUrl(fileName);
let downloadPath = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
}
catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
//
// Extract
//
let extPath = tempDirectory;
if (!extPath) {
throw new Error('Temp directory not set');
}
if (osPlat == 'win32') {
extPath = await tc.extractZip(downloadPath);
}
else {
extPath = await tc.extractTar(downloadPath);
}
const toolRoot = path.join(extPath, 'go');
return await tc.cacheDir(toolRoot, 'perl', version);
}
function getFileName(version) {
return `perl-${version}-${osPlat}-${osArch}.tar.gz`;
}
function getDownloadUrl(filename) {
return `https://github.com/shogo82148/actions-setup-perl/releases/download/${actionVersion}/${filename}`;
}
26 changes: 26 additions & 0 deletions lib/src/setup-perl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";
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 core = __importStar(require("@actions/core"));
const installer = __importStar(require("./installer"));
const path = __importStar(require("path"));
async function run() {
try {
const version = core.getInput('perl-version');
if (version) {
await installer.getPerl(version);
}
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'perl.json')}`);
}
catch (error) {
core.setFailed(error.message);
}
}
run();
7 changes: 7 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c77e145

Please sign in to comment.