Actions refactored to simplify further work

This commit is contained in:
Dmitry Vedenko 2022-02-01 13:49:34 +03:00
parent ce925b75ca
commit e03c1ec0c5
No known key found for this signature in database
GPG Key ID: F4C37A6204F983A2
4 changed files with 23 additions and 9 deletions

View File

@ -150,7 +150,7 @@ async function run() {
await conan.uploadBinaries();
await conan.cleanupConanBuilds();
} catch(error) {
helper.error(error.message);
helpers.error(error.message);
core.setFailed(error.message);
} finally {
if (saveCache) {
@ -158,7 +158,7 @@ async function run() {
}
}
} catch (error) {
helper.error(error.message);
helpers.error(error.message);
core.setFailed(error.message);
}
}

View File

@ -1,4 +1,3 @@
const md5 = require('md5');
const path = require('path');
const fs = require('fs');
@ -31,10 +30,8 @@ async function getCompilerVersion(generator) {
async function getConanCacheKeys(generator) {
const depsFile = path.join(workspaceDir, 'cmake-proxies/CMakeLists.txt');
// Evaluate Conan cache key
const depsContent = fs.readFileSync(depsFile);
const depsMD5 = md5(depsContent);
const depsMD5 = helpers.getMD5(depsFile);
const conanVersion = await getConanVersion();
const conanCacheKeyShort = [

View File

@ -2,6 +2,7 @@ const core = require('@actions/core');
const exec = require('@actions/exec');
const path = require('path');
const md5 = require('md5');
const runningOnCI = process.env['CI']
@ -65,6 +66,21 @@ async function awaitAll(array, functor) {
return await Promise.all(array.map(async (item) => functor(item)))
}
async function getMD5(filePath) {
const depsContent = await fs.promises.readFileSync(filePath);
return md5(depsContent);
}
function getDateString() {
const currentDate = new Date();
return [
currentDate.getFullYear(),
('0' + (currentDate.getMonth() + 1)).slice(-2),
('0' + currentDate.getDate()).slice(-2)
].join('')
}
const sleep = (waitTimeInMs) => new Promise(resolve => setTimeout(resolve, waitTimeInMs));
process.on('unhandledRejection', (reason, p) => {
@ -84,4 +100,6 @@ module.exports = {
getExecOutput: getExecOutput,
sleep: sleep,
awaitAll: awaitAll,
getMD5: getMD5,
getDateString: getDateString,
}

View File

@ -1,6 +1,5 @@
const core = require('@actions/core');
const artifact = require('@actions/artifact');
const exec = require('@actions/exec');
const fs = require('fs');
const path = require('path');
@ -90,7 +89,7 @@ async function getBuildSuffix() {
('0' + currentDate.getDate()).slice(-2)
].join('')
const revision = (await exec.getExecOutput('git', ['show', '-s', '--format=%h'])).stdout.trim();
const revision = (await helpers.getExecOutput('git', ['show', '-s', '--format=%h'])).stdout.trim();
return `-${BuildLevel.getBuildSuffix(buildLevel)}-${dateString}+${revision}`;
}