Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6c3a916ee | ||
|
|
ecd3566c81 | ||
|
|
f73439ca62 | ||
|
|
bf955761b2 | ||
|
|
98bf7786db | ||
|
|
42a7ee2bf3 | ||
|
|
3268a385e5 | ||
|
|
c0bf818478 | ||
|
|
61f4c9c927 | ||
|
|
7be9d34ace | ||
|
|
06c58cac8f | ||
|
|
15706adc71 | ||
|
|
0050aaf8ea | ||
|
|
4b20200534 | ||
|
|
c29f440249 |
@@ -1,7 +1,21 @@
|
|||||||
import {runCommand} from '../src/install'
|
import {install, runCommand} from '../src/install'
|
||||||
|
import * as core from '@actions/core'
|
||||||
|
|
||||||
import {expect, test} from '@jest/globals'
|
import {expect, test} from '@jest/globals'
|
||||||
|
|
||||||
test('runCommand', async () => {
|
test('runCommand', async () => {
|
||||||
const result = await runCommand('echo foo bar')
|
const result = await runCommand('echo foo bar')
|
||||||
expect(result).toBe('foo bar')
|
expect(result).toBe('foo bar')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function testVersion(version: string) {
|
||||||
|
const commandPath = await install(version)
|
||||||
|
core.addPath(commandPath)
|
||||||
|
const result = await runCommand('docker-compose version')
|
||||||
|
expect(result).toContain(version)
|
||||||
|
}
|
||||||
|
|
||||||
|
test('Install the right version', async () => {
|
||||||
|
await testVersion('1.29.1')
|
||||||
|
await testVersion('1.29.2')
|
||||||
|
})
|
||||||
|
|||||||
13
dist/index.js
vendored
13
dist/index.js
vendored
@@ -22,7 +22,7 @@ const exec_1 = __nccwpck_require__(514);
|
|||||||
function runCommand(command) {
|
function runCommand(command) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let output = '';
|
let output = '';
|
||||||
const result = yield exec_1.exec(command, [], {
|
const result = yield (0, exec_1.exec)(command, [], {
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
output += data.toString();
|
output += data.toString();
|
||||||
@@ -41,9 +41,10 @@ function installOnLinux(version) {
|
|||||||
const system = runCommand('uname -s');
|
const system = runCommand('uname -s');
|
||||||
const hardware = runCommand('uname -m');
|
const hardware = runCommand('uname -m');
|
||||||
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${yield system}-${yield hardware}`;
|
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${yield system}-${yield hardware}`;
|
||||||
const installerPath = yield tool_cache_1.downloadTool(url);
|
const installerPath = yield (0, tool_cache_1.downloadTool)(url);
|
||||||
yield exec_1.exec(`chmod +x ${installerPath}`);
|
yield (0, exec_1.exec)(`chmod +x ${installerPath}`);
|
||||||
return installerPath;
|
const cachedPath = yield (0, tool_cache_1.cacheFile)(installerPath, 'docker-compose', 'docker-compose', version);
|
||||||
|
return cachedPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function install(version) {
|
function install(version) {
|
||||||
@@ -103,11 +104,11 @@ function run() {
|
|||||||
const version = core.getInput('version', {
|
const version = core.getInput('version', {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
const commandPath = yield install_1.install(version);
|
const commandPath = yield (0, install_1.install)(version);
|
||||||
core.addPath(commandPath);
|
core.addPath(commandPath);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error instanceof Error ? error.message : 'Unknown error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
1825
package-lock.json
generated
1825
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kengotoda/actions-setup-docker-compose",
|
"name": "@kengotoda/actions-setup-docker-compose",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"description": "the GitHub Action setting up docker-compose command",
|
"description": "the GitHub Action setting up docker-compose command",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"private": false,
|
"private": false,
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"@semantic-release/git": "^9.0.0",
|
"@semantic-release/git": "^9.0.0",
|
||||||
"@types/node": "^16.3.2",
|
"@types/node": "^16.3.2",
|
||||||
"@typescript-eslint/parser": "^4.28.3",
|
"@typescript-eslint/parser": "^4.28.3",
|
||||||
"@vercel/ncc": "^0.29.0",
|
"@vercel/ncc": "^0.30.0",
|
||||||
"eslint": "^7.30.0",
|
"eslint": "^7.30.0",
|
||||||
"eslint-plugin-github": "^4.1.3",
|
"eslint-plugin-github": "^4.1.3",
|
||||||
"eslint-plugin-jest": "^24.3.6",
|
"eslint-plugin-jest": "^24.3.6",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {downloadTool} from '@actions/tool-cache'
|
import {cacheFile, downloadTool} from '@actions/tool-cache'
|
||||||
import {exec} from '@actions/exec'
|
import {exec} from '@actions/exec'
|
||||||
|
|
||||||
export async function runCommand(command: string): Promise<string> {
|
export async function runCommand(command: string): Promise<string> {
|
||||||
@@ -22,7 +22,13 @@ async function installOnLinux(version: string): Promise<string> {
|
|||||||
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${await system}-${await hardware}`
|
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${await system}-${await hardware}`
|
||||||
const installerPath = await downloadTool(url)
|
const installerPath = await downloadTool(url)
|
||||||
await exec(`chmod +x ${installerPath}`)
|
await exec(`chmod +x ${installerPath}`)
|
||||||
return installerPath
|
const cachedPath = await cacheFile(
|
||||||
|
installerPath,
|
||||||
|
'docker-compose',
|
||||||
|
'docker-compose',
|
||||||
|
version
|
||||||
|
)
|
||||||
|
return cachedPath
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function install(version: string): Promise<string> {
|
export async function install(version: string): Promise<string> {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ async function run(): Promise<void> {
|
|||||||
const commandPath = await install(version)
|
const commandPath = await install(version)
|
||||||
core.addPath(commandPath)
|
core.addPath(commandPath)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error instanceof Error ? error.message : 'Unknown error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user