mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-12 11:06:53 +08:00
Add prototype action using exec and curl
* Downloads a fixed version Julia binary using curl * Adds it to PATH * Runs `julia --version` to test the installation
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
describe('TODO - Add a test suite', () => {
|
||||
it('TODO - Add a test', async () => {});
|
||||
describe("TODO - Add a test suite", () => {
|
||||
it("TODO - Add a test", async () => {});
|
||||
});
|
||||
|
||||
14
action.yml
14
action.yml
@@ -1,10 +1,10 @@
|
||||
name: 'Node 12 Template Action'
|
||||
description: 'Get started with Node actions'
|
||||
author: 'GitHub'
|
||||
name: 'Setup Julia environment'
|
||||
description: 'Setup a Julia environment and add it to the PATH'
|
||||
author: 'Sascha Mann <git@mail.saschamann.eu>'
|
||||
inputs:
|
||||
myInput:
|
||||
description: 'Input to use'
|
||||
default: 'world'
|
||||
version:
|
||||
description: 'The Julia version to download (if necessary) and use. Example: 1.0'
|
||||
default: '1.0'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/main.js'
|
||||
main: 'lib/setup-julia.js'
|
||||
|
||||
3
lib/file.js
Normal file
3
lib/file.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
// Apparently this satisfies the typescript compiler
|
||||
// https://stackoverflow.com/questions/41211566/tsconfig-json-buildno-inputs-were-found-in-config-file/45790421#45790421
|
||||
46
lib/setup-julia.js
Normal file
46
lib/setup-julia.js
Normal file
@@ -0,0 +1,46 @@
|
||||
"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 core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const os = __importStar(require("os"));
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const version = core.getInput("version");
|
||||
core.debug(`selected Julia version: ${version}`);
|
||||
// Store information about the environment
|
||||
const osPlat = os.platform();
|
||||
const osArch = os.arch();
|
||||
// For now, just download Linux x64 binaries
|
||||
yield exec.exec("curl", [
|
||||
"-O",
|
||||
"https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.1-linux-x86_64.tar.gz"
|
||||
]);
|
||||
yield exec.exec("tar xf julia-1.0.1-linux-x86_64.tar.gz");
|
||||
// Add the downloaded binary to path
|
||||
core.addPath("julia-1.0.1/bin");
|
||||
// Test if it worked
|
||||
yield exec.exec("julia", ["--version"]);
|
||||
yield exec.exec("julia", ["-e", "'using InteractiveUtils; versioninfo()'"]);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
run();
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node12-template-action",
|
||||
"version": "0.0.0",
|
||||
"name": "setup-julia",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
17
package.json
17
package.json
@@ -1,23 +1,25 @@
|
||||
{
|
||||
"name": "node12-template-action",
|
||||
"version": "0.0.0",
|
||||
"name": "setup-julia",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Node 12 template action",
|
||||
"main": "lib/main.js",
|
||||
"description": "setup Julia action",
|
||||
"main": "lib/setup-julia.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"test": "jest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/node12-template.git"
|
||||
"url": "git+https://github.com/julia-actions/setup-julia.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
"node",
|
||||
"julia",
|
||||
"setup"
|
||||
],
|
||||
"author": "GitHub",
|
||||
"author": "Sascha Mann",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.0.0",
|
||||
@@ -33,6 +35,7 @@
|
||||
"@types/semver": "^6.0.0",
|
||||
"jest": "^24.8.0",
|
||||
"jest-circus": "^24.7.1",
|
||||
"prettier": "^1.17.1",
|
||||
"ts-jest": "^24.0.2",
|
||||
"typescript": "^3.5.1"
|
||||
}
|
||||
|
||||
12
src/main.ts
12
src/main.ts
@@ -1,12 +0,0 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const myInput = core.getInput('myInput');
|
||||
core.debug(`Hello ${myInput}`);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
32
src/setup-julia.ts
Normal file
32
src/setup-julia.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
|
||||
import * as os from "os";
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const version = core.getInput("version");
|
||||
core.debug(`selected Julia version: ${version}`);
|
||||
|
||||
// Store information about the environment
|
||||
const osPlat = os.platform();
|
||||
const osArch = os.arch();
|
||||
|
||||
// For now, just download Linux x64 binaries
|
||||
await exec.exec("curl", [
|
||||
"-O",
|
||||
"https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.1-linux-x86_64.tar.gz"
|
||||
]);
|
||||
await exec.exec("tar xf julia-1.0.1-linux-x86_64.tar.gz");
|
||||
|
||||
// Add the downloaded binary to path
|
||||
core.addPath("julia-1.0.1/bin");
|
||||
|
||||
// Test if it worked
|
||||
await exec.exec("julia", ["--version"]);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user