Simplifies offline building with AppImage

Uses Conan packaged as AppImage for offline builds
This commit is contained in:
Dmitry Vedenko 2022-11-08 16:03:26 +03:00
parent c1eb7102f9
commit f7569aa124

View File

@ -1,5 +1,6 @@
const core = require('@actions/core');
const artifact = require('@actions/artifact');
const toolCache = require('@actions/tool-cache');
const fs = require('fs');
const path = require('path');
@ -7,81 +8,30 @@ const path = require('path');
const helpers = require('../lib/helpers.js');
const offlineCacheLocation = path.join(workspaceDir, '.offline');
const pipDownloadCacheLocation = path.join(offlineCacheLocation, 'pip');
const conanVenvLocation = path.join(workspaceDir, '.venv');
const conanCacheLocation = path.join(offlineCacheLocation, 'conan');
const conanDownloadCacheLocation = path.join(conanCacheLocation, 'download_cache');
const packages = [
'conan',
'setuptools',
'wheel',
'Cython',
'setuptools_scm',
'flit_core'
]
async function getPip() {
try {
await helpers.execWithLog('pip3', ['--version']);
return 'pip3';
} catch(e) {
await helpers.execWithLog('pip', ['--version']);
return 'pip';
async function downloadConan(version) {
const cached_path = await toolCache.downloadTool(`https://github.com/audacity/conan-appimage/releases/download/v${version}/conan-${version}-x86_64.AppImage`)
const bin_path = path.join(offlineCacheLocation, 'bin');
if (!fs.existsSync(bin_path)) {
fs.mkdirSync(bin_path, { recursive: true });
}
const conan_path = path.join(bin_path, 'conan');
fs.copyFileSync(cached_path, conan_path);
console.log(conan_path);
fs.chmodSync(conan_path, '755');
return conan_path;
}
async function getPython() {
try {
await helpers.execWithLog('python3', ['--version']);
return 'python3';
} catch(e) {
await helpers.execWithLog('python', ['--version']);
return 'python';
}
}
async function prepareEnvironment(additionalPyhtonPackages) {
let pip = await getPip();
let python = await getPython();
// Predowload packages
await helpers.execWithLog(pip, [
'download',
'--dest', pipDownloadCacheLocation,
'--no-binary=:all:',
...packages,
...(additionalPyhtonPackages || [])
]);
// Prepare venev
if (fs.existsSync(conanVenvLocation)) {
await fs.promises.rm(conanVenvLocation, { recursive: true, force: true });
}
await helpers.execWithLog(python, [
'-m', 'venv', conanVenvLocation
]);
core.exportVariable('VIRTUAL_ENV', conanVenvLocation);
pip = path.join(conanVenvLocation, 'bin', pip );
python = path.join(conanVenvLocation, 'bin', python);
await fs.promises.mkdir(pipDownloadCacheLocation, { recursive: true });
await helpers.execWithLog(pip, [
'install', '--no-index',
'--find-links', pipDownloadCacheLocation,
'setuptools>=65.0.0', 'wheel', 'Cython', 'markupsafe'
]);
await helpers.execWithLog(pip, [
'install', '--no-index',
'--find-links', pipDownloadCacheLocation,
'conan'
]);
core.addPath(path.join(conanVenvLocation, 'bin'));
async function prepareEnvironment() {
conan = await downloadConan('1.54.0');
core.exportVariable('CONAN_USER_HOME', conanCacheLocation);
@ -89,15 +39,15 @@ async function prepareEnvironment(additionalPyhtonPackages) {
'config', 'init'
]);
await helpers.execWithLog('conan', [
await helpers.execWithLog(conan, [
'config', 'set',
`storage.download_cache=${conanDownloadCacheLocation}`
]);
const compiler = (await helpers.getExecOutput('conan', ['profile', 'get', 'settings.compiler', 'default'])).stdout.trim();
const compiler = (await helpers.getExecOutput(conan, ['profile', 'get', 'settings.compiler', 'default'])).stdout.trim();
if (compiler === 'gcc') {
await helpers.execWithLog('conan', [
await helpers.execWithLog(conan, [
'profile',
'update',
'settings.compiler.libcxx=libstdc++11',