Make ossutil executable
This commit is contained in:
@@ -12,16 +12,18 @@ import * as installer from '../src/installer'
|
||||
|
||||
const FILE_NAME = process.platform === 'win32' ? 'ossutil.exe' : 'ossutil'
|
||||
|
||||
jest.setTimeout(60000)
|
||||
|
||||
describe('installer tests', () => {
|
||||
beforeAll(async () => {
|
||||
await io.rmRF(TOOL_DIR)
|
||||
await io.rmRF(TEMP_DIR)
|
||||
}, 60000)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await io.rmRF(TOOL_DIR)
|
||||
await io.rmRF(TEMP_DIR)
|
||||
}, 60000)
|
||||
})
|
||||
|
||||
it('install ossutil 1.6.10', async () => {
|
||||
const version = '1.6.10'
|
||||
@@ -32,7 +34,9 @@ describe('installer tests', () => {
|
||||
|
||||
const exist = fs.existsSync(path.join(ossutilDir, FILE_NAME))
|
||||
expect(exist).toBe(true)
|
||||
}, 60000)
|
||||
|
||||
expect(await io.which('ossutil', true)).toBeTruthy()
|
||||
})
|
||||
|
||||
it('throw if wrong version', async () => {
|
||||
let thrown = false
|
||||
|
||||
10
dist/index.js
vendored
10
dist/index.js
vendored
@@ -4013,6 +4013,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const tc = __importStar(__webpack_require__(533));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const TOOL_NAME = 'ossutil';
|
||||
/**
|
||||
* Get ossutil ready for use
|
||||
@@ -4025,7 +4026,7 @@ function getOssutil(version) {
|
||||
// download, extract, cache
|
||||
toolPath = yield acquireOssutil(version);
|
||||
}
|
||||
core.info(`ossutil is cached under ${toolPath}`);
|
||||
core.debug(`ossutil is cached under ${toolPath}`);
|
||||
core.addPath(toolPath);
|
||||
});
|
||||
}
|
||||
@@ -4056,6 +4057,7 @@ function acquireOssutil(version) {
|
||||
toolFile = path.join(extractFolder, 'ossutil64', 'ossutil64.exe');
|
||||
core.debug(`ossutil extracted to: ${toolFile}`);
|
||||
}
|
||||
fs.chmodSync(toolFile, 0o755);
|
||||
// cache
|
||||
const fileName = process.platform === 'win32' ? 'ossutil.exe' : 'ossutil';
|
||||
const toolPath = yield tc.cacheFile(toolFile, fileName, TOOL_NAME, version);
|
||||
@@ -4163,6 +4165,7 @@ function run() {
|
||||
// download
|
||||
const version = core.getInput('ossutil-version');
|
||||
yield installer.getOssutil(version);
|
||||
core.info('ossutil is successfully installed');
|
||||
// config
|
||||
const endpoint = core.getInput('endpoint');
|
||||
const accessKeyId = core.getInput('access-key-id');
|
||||
@@ -4178,7 +4181,10 @@ function run() {
|
||||
'--sts-token',
|
||||
stsToken
|
||||
];
|
||||
yield exec.exec('ossutil', args);
|
||||
const exitCode = yield exec.exec('ossutil', args);
|
||||
if (exitCode === 0) {
|
||||
core.info('ossutil config is done');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
const TOOL_NAME = 'ossutil'
|
||||
|
||||
@@ -15,7 +16,7 @@ export async function getOssutil(version: string): Promise<void> {
|
||||
toolPath = await acquireOssutil(version)
|
||||
}
|
||||
|
||||
core.info(`ossutil is cached under ${toolPath}`)
|
||||
core.debug(`ossutil is cached under ${toolPath}`)
|
||||
core.addPath(toolPath)
|
||||
}
|
||||
|
||||
@@ -44,6 +45,7 @@ async function acquireOssutil(version: string): Promise<string> {
|
||||
toolFile = path.join(extractFolder, 'ossutil64', 'ossutil64.exe')
|
||||
core.debug(`ossutil extracted to: ${toolFile}`)
|
||||
}
|
||||
fs.chmodSync(toolFile, 0o755)
|
||||
|
||||
// cache
|
||||
const fileName = process.platform === 'win32' ? 'ossutil.exe' : 'ossutil'
|
||||
|
||||
@@ -7,6 +7,7 @@ async function run(): Promise<void> {
|
||||
// download
|
||||
const version = core.getInput('ossutil-version')
|
||||
await installer.getOssutil(version)
|
||||
core.info('ossutil is successfully installed')
|
||||
|
||||
// config
|
||||
const endpoint = core.getInput('endpoint')
|
||||
@@ -23,7 +24,10 @@ async function run(): Promise<void> {
|
||||
'--sts-token',
|
||||
stsToken
|
||||
]
|
||||
await exec.exec('ossutil', args)
|
||||
const exitCode = await exec.exec('ossutil', args)
|
||||
if (exitCode === 0) {
|
||||
core.info('ossutil config is done')
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user