Skip to content

Commit

Permalink
chore: Update package version to 0.1.0-rc40.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Jun 12, 2024
2 parents 7b8b11f + f9332cd commit cd87ef3
Show file tree
Hide file tree
Showing 9 changed files with 2,445 additions and 163 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/e2e.yml
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
8 changes: 7 additions & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ e7de9ce0b902ed6d68f8c5b033d044f39b08f5a1:operate/data/contracts/service_staking_
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:405
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:406
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:454
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:455
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:455
d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-key:45591ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454
99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:405
99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:406
99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:454
99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:455
91ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454
100 changes: 68 additions & 32 deletions electron/install.js
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');
Expand All @@ -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`;
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
},
);
});
Expand All @@ -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() {
Expand All @@ -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);
}
}
Expand All @@ -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);
}

Expand All @@ -176,7 +212,7 @@ function isDockerInstalledDarwin() {
}

function installDockerDarwin() {
return runCmdUnix('brew', ['install', 'docker']);
runCmdUnix('brew', ['install', 'docker']);
}

function isDockerInstalledUbuntu() {
Expand All @@ -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() {
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -443,4 +479,4 @@ module.exports = {
LogFile,
OperateInstallationLog,
},
};
};
Loading

0 comments on commit cd87ef3

Please sign in to comment.