Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide node-manager command #22

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
RUSTFLAGS: "-D warnings"
CLIENT_VERSION: 0.77.27
NODE_VERSION: 0.83.25
NODE_MANAGER_VERSION: 0.1.8
TESTNET_VERSION: 0.1.29

jobs:
Expand Down Expand Up @@ -140,6 +141,7 @@ jobs:
run: |
cargo run -- client --version $env:CLIENT_VERSION
cargo run -- node --version $env:NODE_VERSION
cargo run -- node-manager --version $env:NODE_MANAGER_VERSION
cargo run -- testnet --version $env:TESTNET_VERSION
- name: Check if binaries are available in new shell session
shell: pwsh
Expand All @@ -152,6 +154,10 @@ jobs:
Write-Host "safenode.exe does not exist"
exit 1
}
if (!(Test-Path "$env:USERPROFILE\safe\safenode-manager.exe")) {
Write-Host "safenode-manager.exe does not exist"
exit 1
}
if (!(Test-Path "$env:USERPROFILE\safe\testnet.exe")) {
Write-Host "testnet.exe does not exist"
exit 1
Expand Down Expand Up @@ -185,6 +191,18 @@ jobs:
exit 1
}

$output = & "${env:USERPROFILE}\safe\safenode-manager.exe" --version
$version = $output | Select-String -Pattern "sn-node-manager (\d+\.\d+\.\d+)"
$versionNumber = $version.Matches.Groups[1].Value
if ($versionNumber -eq "$env:NODE_MANAGER_VERSION") {
Write-Host "The correct version of safenode-manager has been installed"
} else {
Write-Host "The correct version of safenode-manager has not been installed"
Write-Host "We expected version $env:NODE_MANAGER_VERSION"
Write-Host "The downloaded binary has $versionNumber"
exit 1
}

$output = & "${env:USERPROFILE}\safe\testnet.exe" --version
$version = $output | Select-String -Pattern "testnet (\d+\.\d+\.\d+)"
$versionNumber = $version.Matches.Groups[1].Value
Expand Down Expand Up @@ -213,6 +231,7 @@ jobs:
run: |
cargo run -- client --version $CLIENT_VERSION
cargo run -- node --version $NODE_VERSION
cargo run -- node-manager --version $NODE_MANAGER_VERSION
cargo run -- testnet --version $TESTNET_VERSION
- name: Check if binaries are available in new shell session
shell: bash
Expand All @@ -228,6 +247,7 @@ jobs:

[[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/testnet" ]] || { echo "testnet not in expected location"; exit 1; }

version=$(safe --version | awk '{ print $2 }')
Expand All @@ -250,6 +270,16 @@ jobs:
exit 1
fi

version=$(safenode-manager --version | awk '{ print $2 }')
if [[ "$version" == "$NODE_MANAGER_VERSION" ]]; then
echo "The correct version of safenode-manager has been installed"
else
echo "The correct version of safenode-manager has not been installed"
echo "We expected $NODE_MANAGER_VERSION"
echo "The downloaded binary has $version"
exit 1
fi

version=$(testnet --version | awk '{ print $2 }')
if [[ "$version" == "$TESTNET_VERSION" ]]; then
echo "The correct version of testnet has been installed"
Expand All @@ -275,6 +305,7 @@ jobs:
run: |
cargo run -- client --version $CLIENT_VERSION
cargo run -- node --version $NODE_VERSION
cargo run -- node-manager --version $NODE_MANAGER_VERSION
cargo run -- testnet --version $TESTNET_VERSION
- name: Check if binaries are available in new shell session
run: |
Expand All @@ -283,6 +314,7 @@ jobs:

[[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/testnet" ]] || { echo "testnet not in expected location"; exit 1; }

version=$(safe --version | awk '{ print $2 }')
Expand All @@ -305,6 +337,16 @@ jobs:
exit 1
fi

version=$(safenode-manager --version | awk '{ print $2 }')
if [[ "$version" == "$NODE_MANAGER_VERSION" ]]; then
echo "The correct version of safenode-manager has been installed"
else
echo "The correct version of safenode-manager has not been installed"
echo "We expected $NODE_MANAGER_VERSION"
echo "The downloaded binary has $version"
exit 1
fi

version=$(testnet --version | awk '{ print $2 }')
if [[ "$version" == "$TESTNET_VERSION" ]]; then
echo "The correct version of testnet has been installed"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/artifacts/
/deploy/

/.vagrant/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ semver = "1.0.4"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tar = "0.4"
sn-releases = "0.1.5"
tempfile = "3.8.1"
textwrap = "0.16.0"
tokio = { version = "1.26", features = ["full"] }

Expand All @@ -35,5 +36,6 @@ winreg = "0.7"
[dev-dependencies]
assert_fs = "~1.0"
assert_matches = "1.5.0"
httpmock = "0.6"
async-trait = "0.1"
mockall = "0.11.3"
predicates = "2.0"
64 changes: 64 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2204"
config.vm.provider :libvirt do |libvirt|
libvirt.memory = 4096
end
config.vm.synced_folder ".",
"/vagrant",
type: "9p",
accessmode: "mapped",
mount_options: ['rw', 'trans=virtio', 'version=9p2000.L']
config.vm.provision "file", source: "~/.ssh/id_rsa", destination: "/home/vagrant/.ssh/id_rsa"
config.vm.provision "shell", inline: "apt-get update -y"
config.vm.provision "shell", inline: "apt-get install -y build-essential"
config.vm.provision "shell", privileged: false, inline: <<-SHELL
curl -L -O https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x rustup-init
./rustup-init --default-toolchain stable --no-modify-path -y
echo "source ~/.cargo/env" >> ~/.bashrc
SHELL
config.vm.provision "shell", inline: <<-SHELL
curl -L -O https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x rustup-init
./rustup-init --default-toolchain stable --no-modify-path -y
echo "source ~/.cargo/env" >> ~/.bashrc
# Copy the binaries to a system-wide location for running tests as the root user
sudo cp ~/.cargo/bin/** /usr/local/bin
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
mkdir -p ~/.vim/tmp/ ~/.vim/backup
cat <<'EOF' > ~/.vimrc
set nocompatible

let mapleader=" "
syntax on

set background=dark
set backspace=indent,eol,start
set backupdir=~/.vim/tmp//
set directory=~/.vim/backup
set expandtab
set foldlevel=1
set foldmethod=indent
set foldnestmax=10
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set nobackup
set nofoldenable
set nowrap
set number relativenumber
set ruler
set shiftwidth=4
set smartindent
set showcmd
set shortmess+=A
set tabstop=4
set viminfo+=!

nnoremap j gj
nnoremap k gk
EOF
SHELL
end
Loading
Loading