diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 48f15ff..42af5f1 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -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 () => {}); }); diff --git a/action.yml b/action.yml index 2b3b1b0..8fce9cd 100644 --- a/action.yml +++ b/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 ' 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' diff --git a/lib/file.js b/lib/file.js new file mode 100644 index 0000000..b829781 --- /dev/null +++ b/lib/file.js @@ -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 diff --git a/lib/setup-julia.js b/lib/setup-julia.js new file mode 100644 index 0000000..e12c5c3 --- /dev/null +++ b/lib/setup-julia.js @@ -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(); diff --git a/package-lock.json b/package-lock.json index 6e4d6b5..a3ace98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "node12-template-action", - "version": "0.0.0", + "name": "setup-julia", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 37620dc..57646fa 100644 --- a/package.json +++ b/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" } diff --git a/src/main.ts b/src/main.ts deleted file mode 100644 index fae8b12..0000000 --- a/src/main.ts +++ /dev/null @@ -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(); diff --git a/src/setup-julia.ts b/src/setup-julia.ts new file mode 100644 index 0000000..f1b84cc --- /dev/null +++ b/src/setup-julia.ts @@ -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();