fix: Add docker-compose to PATH (#274)
* Expose command as `docker-compose` * Format and package
This commit is contained in:
@@ -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'
|
||||
|
||||
test('runCommand', async () => {
|
||||
const result = await runCommand('echo 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')
|
||||
})
|
||||
|
||||
5
dist/index.js
vendored
5
dist/index.js
vendored
@@ -43,7 +43,8 @@ function installOnLinux(version) {
|
||||
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${yield system}-${yield hardware}`;
|
||||
const installerPath = yield (0, tool_cache_1.downloadTool)(url);
|
||||
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) {
|
||||
@@ -107,7 +108,7 @@ function run() {
|
||||
core.addPath(commandPath);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error instanceof Error ? error.message : "Unknown error");
|
||||
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
@@ -1,4 +1,4 @@
|
||||
import {downloadTool} from '@actions/tool-cache'
|
||||
import {cacheFile, downloadTool} from '@actions/tool-cache'
|
||||
import {exec} from '@actions/exec'
|
||||
|
||||
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 installerPath = await downloadTool(url)
|
||||
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> {
|
||||
|
||||
Reference in New Issue
Block a user