-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update package version to 0.1.0-rc40.1
- Loading branch information
Showing
9 changed files
with
2,445 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: "Test Operate Installation E2E" | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
- main | ||
pull_request: | ||
jobs: | ||
test: | ||
continue-on-error: False | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-12, macos-14] | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20.11" | ||
- name: Setup | ||
run: | | ||
npm install | ||
# Uninstall brew | ||
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" | ||
- name: Run Test | ||
run: | | ||
node electron/test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// Installation helpers. | ||
|
||
const https = require('https'); | ||
const path = require('path'); | ||
const nfs = require('node:fs') | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
const sudo = require('sudo-prompt'); | ||
|
@@ -10,13 +9,14 @@ const axios = require('axios'); | |
|
||
const Docker = require('dockerode'); | ||
const { spawnSync } = require('child_process'); | ||
const { BrewScript } = require("./scripts") | ||
|
||
/** | ||
* current version of the pearl release | ||
* - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" | ||
* - use "alpha" for alpha release, for example "0.1.0rc26-alpha" | ||
*/ | ||
const OlasMiddlewareVersion = '0.1.0rc35'; | ||
const OlasMiddlewareVersion = '0.1.0rc40'; | ||
const OperateDirectory = `${os.homedir()}/.operate`; | ||
const VenvDir = `${OperateDirectory}/venv`; | ||
const TempDir = `${OperateDirectory}/temp`; | ||
|
@@ -80,23 +80,15 @@ function runCmdUnix(command, options) { | |
throw new Error(`Command ${command} not found; Path : ${Env.PATH}`); | ||
} | ||
let output = spawnSync(bin, options); | ||
if (output.stdout) { | ||
appendLog(output.stdout.toString()); | ||
} | ||
if (output.stderr) { | ||
appendLog(output.stdout.toString()); | ||
} | ||
if (output.error) { | ||
throw new Error( | ||
`Error running ${command} with options ${options}; | ||
Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`, | ||
); | ||
} | ||
return { | ||
error: output.error, | ||
stdout: output.stdout?.toString(), | ||
stderr: output.stderr?.toString(), | ||
}; | ||
console.log(appendLog(`Executed ${command} ${options} with`)) | ||
console.log(appendLog(`===== stdout ===== \n${output.stdout}`)) | ||
console.log(appendLog(`===== stderr ===== \n${output.stderr}`)) | ||
} | ||
|
||
function runSudoUnix(command, options) { | ||
|
@@ -109,11 +101,21 @@ function runSudoUnix(command, options) { | |
`${bin} ${options}`, | ||
SudoOptions, | ||
function (error, stdout, stderr) { | ||
resolve({ | ||
let output = { | ||
error: error, | ||
stdout: stdout, | ||
stderr: stderr, | ||
}); | ||
}; | ||
if (output.error) { | ||
throw new Error( | ||
`Error running ${command} with options ${options}; | ||
Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`, | ||
); | ||
} | ||
console.log(appendLog(`Executed ${command} ${options} with`)) | ||
console.log(appendLog(`===== stdout ===== \n${output.stdout}`)) | ||
console.log(appendLog(`===== stderr ===== \n${output.stderr}`)) | ||
resolve() | ||
}, | ||
); | ||
}); | ||
|
@@ -123,11 +125,38 @@ function isBrewInstalled() { | |
return Boolean(getBinPath(getBinPath('brew'))); | ||
} | ||
|
||
function installBrew() { | ||
return runCmdUnix('bash', [ | ||
'-c', | ||
'$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)', | ||
]); | ||
async function installBrew() { | ||
console.log(appendLog("Fetching homebrew source")) | ||
let outdir = `${os.homedir()}/homebrew` | ||
let outfile = `${os.homedir()}/homebrew.tar` | ||
|
||
// Make temporary source dir | ||
fs.mkdirSync(outdir) | ||
|
||
// Fetch brew source | ||
runCmdUnix("curl", ["-L", "https://github.com/Homebrew/brew/tarball/master", "--output", outfile]) | ||
runCmdUnix("tar", ["-xvf", outfile, "--strip-components", "1", "-C", outdir]) | ||
|
||
// Check for cache and uninstall leftovers | ||
if (fs.existsSync("/opt/homebrew")) { | ||
console.log(appendLog("Removing homebrew leftovers")) | ||
if (!Env.CI) { | ||
await runSudoUnix("rm", `-rf /opt/homebrew`) | ||
} else { | ||
fs.rmdirSync("/opt/homebrew") | ||
} | ||
} | ||
|
||
console.log(appendLog("Installing homebrew")) | ||
if (!Env.CI) { | ||
await runSudoUnix("mv", `${outdir} /opt/homebrew`) | ||
await runSudoUnix("chown", `-R ${os.userInfo().username} /opt/homebrew`) | ||
} else { | ||
runCmdUnix("mv", [outdir, "/opt/homebrew"]) | ||
runCmdUnix("chown", ["-R", os.userInfo().username, "/opt/homebrew"]) | ||
} | ||
runCmdUnix("brew", ["doctor"]) | ||
fs.rmSync(outfile) | ||
} | ||
|
||
function isTendermintInstalledUnix() { | ||
|
@@ -148,7 +177,7 @@ async function downloadFile(url, dest) { | |
writer.on('error', reject); | ||
}); | ||
} catch (err) { | ||
fs.unlink(dest, () => {}); // Delete the file if there is an error | ||
fs.unlink(dest, () => { }); // Delete the file if there is an error | ||
console.error('Error downloading the file:', err.message); | ||
} | ||
} | ||
|
@@ -166,8 +195,15 @@ async function installTendermintUnix() { | |
await downloadFile(url, `${TempDir}/tendermint.tar.gz`); | ||
|
||
console.log(appendLog(`Installing tendermint binary`)); | ||
await runCmdUnix('tar', ['-xvf', 'tendermint.tar.gz']); | ||
await runSudoUnix('install', 'tendermint /usr/local/bin'); | ||
runCmdUnix('tar', ['-xvf', 'tendermint.tar.gz']); | ||
|
||
// TOFIX: Install tendermint in .operate instead of globally | ||
if (!Env.CI) { | ||
if (!fs.existsSync("/usr/local/bin")) { | ||
await runSudoUnix('mkdir', '/usr/local/bin') | ||
} | ||
await runSudoUnix('install', 'tendermint /usr/local/bin/tendermint'); | ||
} | ||
process.chdir(cwd); | ||
} | ||
|
||
|
@@ -176,7 +212,7 @@ function isDockerInstalledDarwin() { | |
} | ||
|
||
function installDockerDarwin() { | ||
return runCmdUnix('brew', ['install', 'docker']); | ||
runCmdUnix('brew', ['install', 'docker']); | ||
} | ||
|
||
function isDockerInstalledUbuntu() { | ||
|
@@ -192,11 +228,11 @@ function isPythonInstalledDarwin() { | |
} | ||
|
||
function installPythonDarwin() { | ||
return runCmdUnix('brew', ['install', '[email protected]']); | ||
runCmdUnix('brew', ['install', '[email protected]']); | ||
} | ||
|
||
function createVirtualEnvUnix(path) { | ||
return runCmdUnix('python3.10', ['-m', 'venv', path]); | ||
runCmdUnix('python3.10', ['-m', 'venv', path]); | ||
} | ||
|
||
function isPythonInstalledUbuntu() { | ||
|
@@ -216,11 +252,11 @@ function installGitUbuntu() { | |
} | ||
|
||
function createVirtualEnvUbuntu(path) { | ||
return runCmdUnix('python3.10', ['-m', 'venv', path]); | ||
runCmdUnix('python3.10', ['-m', 'venv', path]); | ||
} | ||
|
||
function installOperatePackageUnix(path) { | ||
return runCmdUnix(`${path}/venv/bin/python3.10`, [ | ||
runCmdUnix(`${path}/venv/bin/python3.10`, [ | ||
'-m', | ||
'pip', | ||
'install', | ||
|
@@ -230,7 +266,7 @@ function installOperatePackageUnix(path) { | |
|
||
function reInstallOperatePackageUnix(path) { | ||
console.log(appendLog('Reinstalling pearl CLI')); | ||
return runCmdUnix(`${path}/venv/bin/python3.10`, [ | ||
runCmdUnix(`${path}/venv/bin/python3.10`, [ | ||
'-m', | ||
'pip', | ||
'install', | ||
|
@@ -300,7 +336,7 @@ async function setupDarwin(ipcChannel) { | |
if (!isBrewInstalled()) { | ||
ipcChannel.send('response', 'Installing Pearl Daemon'); | ||
console.log(appendLog('Installing brew')); | ||
installBrew(); | ||
await installBrew(); | ||
} | ||
|
||
console.log(appendLog('Checking python installation')); | ||
|
@@ -443,4 +479,4 @@ module.exports = { | |
LogFile, | ||
OperateInstallationLog, | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.