Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format everything #2

Merged
merged 1 commit into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

Features

* Add `asdf-vm/actions/install`
- Add `asdf-vm/actions/install`

Action for installing your plugins and tool-versions.

* Add `asdf-vm/actions/plugin-test`
- Add `asdf-vm/actions/plugin-test`

Action for testing new asdf plugins.

* Add `asdf-vm/actions/plugin-add`
- Add `asdf-vm/actions/plugin-add`

Lower lever action for installing the plugins from official repos.

* Add `asdf-vm/actions/setup`
- Add `asdf-vm/actions/setup`

Lower level action for installing asdf itself.


8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This repo provides a collection of asdf related actions for use in your workflow

These two actions are probaly the most useful:

* `asdf-vm/actions/install` - Install your `.tool-versions` plugins and tools.
- `asdf-vm/actions/install` - Install your `.tool-versions` plugins and tools.

```yaml
steps:
Expand All @@ -16,7 +16,7 @@ These two actions are probaly the most useful:

See [action.yml](install/action.yml) inputs.

* `asdf-vm/actions/plugin-test` - Test your shiny new asdf plugin.
- `asdf-vm/actions/plugin-test` - Test your shiny new asdf plugin.

```yaml
steps:
Expand All @@ -35,10 +35,10 @@ These two actions are probaly the most useful:
These actions are used internally by the above ones. And you wont need
to use them directly, unless you actually want ;)

* `asdf-vm/actions/plugins-add` - Only install plugins, not tool versions.
- `asdf-vm/actions/plugins-add` - Only install plugins, not tool versions.

See [action.yml](plugins-add/action.yml) inputs.

* `asdf-vm/actions/setup` - Just installs asdf itself.
- `asdf-vm/actions/setup` - Just installs asdf itself.

See [action.yml](setup/action.yml) inputs.
10 changes: 5 additions & 5 deletions install/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'AsdfInstall'
description: 'Install your versioned tools with asdf'
author: 'Victor Borja <vborja@apache.org>'
name: "AsdfInstall"
description: "Install your versioned tools with asdf"
author: "Victor Borja <vborja@apache.org>"
runs:
using: 'node12'
main: 'index.js'
using: "node12"
main: "index.js"
inputs:
tool_versions:
description: "If present, this value will be written to the .tool-versions file."
Expand Down
8 changes: 3 additions & 5 deletions lib/install/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as path from "path";
import pluginsAdd from "../plugins-add";


const toolsInstall = async () => {
await pluginsAdd();

const before = core.getInput("before_install", {required: false});
const before = core.getInput("before_install", { required: false });
if (before) {
await exec.exec('bash', ['-c', before]);
await exec.exec("bash", ["-c", before]);
}
await exec.exec('asdf', ['install']);
await exec.exec("asdf", ["install"]);
};

export default toolsInstall;
32 changes: 21 additions & 11 deletions lib/plugin-test/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as path from "path";
import setupAsdf from "../setup";


const pluginTest = async () => {
await setupAsdf();
const command = core.getInput("command", {required: true});
const version = core.getInput("version", {required: true});
const plugin = (core.getInput("plugin", {required: false}) || process.env.GITHUB_REPOSITORY.split('/')[1]).replace('asdf-', '');
const giturl = (core.getInput("giturl", {required: false}) || `https://github.com/${process.env.GITHUB_REPOSITORY}`);
const gitref = (core.getInput("gitref", {required: false}) || process.env.GITHUB_SHA);
await exec.exec('asdf', [
'plugin-test',
plugin, giturl, '--asdf-tool-version', version, '--asdf-plugin-gitref', gitref, command
const command = core.getInput("command", { required: true });
const version = core.getInput("version", { required: true });
const plugin = (
core.getInput("plugin", { required: false }) ||
process.env.GITHUB_REPOSITORY.split("/")[1]
).replace("asdf-", "");
const giturl =
core.getInput("giturl", { required: false }) ||
`https://github.com/${process.env.GITHUB_REPOSITORY}`;
const gitref =
core.getInput("gitref", { required: false }) || process.env.GITHUB_SHA;
await exec.exec("asdf", [
"plugin-test",
plugin,
giturl,
"--asdf-tool-version",
version,
"--asdf-plugin-gitref",
gitref,
command
]);
};

const pluginTestAll = async () => {
core.startGroup('Test plugin');
core.startGroup("Test plugin");
await pluginTest();
core.endGroup();
};
Expand Down
22 changes: 10 additions & 12 deletions lib/plugins-add/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import * as core from "@actions/core";
import * as io from "@actions/io";
import * as exec from "@actions/exec";
import * as path from "path";
import {promises as fs} from 'fs';
import { promises as fs } from "fs";
import setupAsdf from "../setup";

const pluginsAdd = async () => {
await setupAsdf();
let tool_versions = core.getInput("tool_versions", {required: false});
let tool_versions = core.getInput("tool_versions", { required: false });

if (tool_versions) {
await fs.writeFile(".tool-versions", tool_versions, {encoding: 'utf8'});
await fs.writeFile(".tool-versions", tool_versions, { encoding: "utf8" });
} else {
tool_versions = await fs.readFile(".tool-versions", {encoding: 'utf8'});
tool_versions = await fs.readFile(".tool-versions", { encoding: "utf8" });
}

const pluginNames =
tool_versions.split("\n")
.map(x => x.replace(/#.*/, '').trim())
.filter(x => x.length > 0)
.map(x => x.split(' ')[0]);
const pluginNames = tool_versions
.split("\n")
.map(x => x.replace(/#.*/, "").trim())
.filter(x => x.length > 0)
.map(x => x.split(" ")[0]);

await pluginNames.reduce(async (promise, pluginName) => {
await promise;
return exec.exec('asdf', ["plugin-add", pluginName]);
return exec.exec("asdf", ["plugin-add", pluginName]);
}, Promise.resolve());
};

Expand Down
14 changes: 10 additions & 4 deletions lib/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ import * as io from "@actions/io";
import * as path from "path";

const setupAsdf = async () => {
const asdfPath = await io.which('asdf', false);
if (asdfPath) { return; }
const asdfPath = await io.which("asdf", false);
if (asdfPath) {
return;
}
const asdfDir = path.join(process.env.HOME, ".asdf");
core.exportVariable("ASDF_DIR", asdfDir);
core.exportVariable("ASDF_DATA_DIR", asdfDir);
core.addPath(`${asdfDir}/bin`);
core.addPath(`${asdfDir}/shims`);
core.info(`Clonning asdf into ASDF_DIR: ${asdfDir}`);
const branch = core.getInput("asdf_branch", {required: true});
const branch = core.getInput("asdf_branch", { required: true });
await exec.exec("git", [
"clone", "--depth", "1", "--branch", branch,
"clone",
"--depth",
"1",
"--branch",
branch,
"https://github.com/asdf-vm/asdf.git",
asdfDir
]);
Expand Down
10 changes: 5 additions & 5 deletions plugin-test/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'TestPlugin'
description: 'Test your asdf plugin'
author: 'Victor Borja <vborja@apache.org>'
name: "TestPlugin"
description: "Test your asdf plugin"
author: "Victor Borja <vborja@apache.org>"
runs:
using: 'node12'
main: 'index.js'
using: "node12"
main: "index.js"
inputs:
command:
description: "Command used to test your plugin tool. Something with --version or --help"
Expand Down
10 changes: 5 additions & 5 deletions plugins-add/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'PluginsInstall'
description: 'Install the plugins listed on your .tool-versions file.'
author: 'Victor Borja <vborja@apache.org>'
name: "PluginsInstall"
description: "Install the plugins listed on your .tool-versions file."
author: "Victor Borja <vborja@apache.org>"
runs:
using: 'node12'
main: 'index.js'
using: "node12"
main: "index.js"
inputs:
asdf_branch:
description: "asdf branch to clone"
Expand Down
10 changes: 5 additions & 5 deletions setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'Setup asdf'
description: 'Install tools versioned with asdf'
author: 'Victor Borja <vborja@apache.org>'
name: "Setup asdf"
description: "Install tools versioned with asdf"
author: "Victor Borja <vborja@apache.org>"
runs:
using: 'node12'
main: 'index.js'
using: "node12"
main: "index.js"
inputs:
asdf_branch:
description: "asdf branch to clone"
Expand Down