Skip to content

Commit

Permalink
Merge pull request #18 from skalenetwork/develop
Browse files Browse the repository at this point in the history
Beta release 23/09/19
  • Loading branch information
dmytrotkk authored Sep 23, 2019
2 parents 28c7ffd + a41ac83 commit 611c1a6
Show file tree
Hide file tree
Showing 30 changed files with 505 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 100
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,venv
61 changes: 61 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
language: python
python:
- '3.6'
cache: pip
install:
- pip install -r requirements.txt
- pip install -r requirements-dev.txt
before_script:
- "flake8 ."
jobs:
include:
#- stage: test
- stage: deploy
if: branch IN (develop, beta, stable, master)
script:
- VERSION=$(BRANCH=$TRAVIS_BRANCH bash ./scripts/calculate_version.sh)
- echo "Version $VERSION"
- bash ./scripts/build.sh $VERSION $TRAVIS_BRANCH
- export OS=`uname -s`-`uname -m`
- export EXECUTABLE_NAME=skale-$VERSION-$OS
before_deploy:
# Set up git user name and tag this commit
- (
test ! $TRAVIS_TAG &&
git config --local user.name "skale-travis" &&
git config --local user.email "$GITHUB_EMAIL" &&
export TRAVIS_TAG=$VERSION &&
git tag "$TRAVIS_TAG" &&
git push https://[email protected]/$TRAVIS_REPO_SLUG.git $TRAVIS_TAG
) || true
deploy:
- provider: releases
api_key: "$GITHUB_OAUTH_TOKEN"
skip_cleanup: true
file:
- dist/$EXECUTABLE_NAME
on:
repo: skalenetwork/skaled
branch: stable
- provider: releases
api_key: "$GITHUB_OAUTH_TOKEN"
skip_cleanup: true
prerelease: true
file:
- dist/$EXECUTABLE_NAME
on:
repo: $TRAVIS_REPO_SLUG
branch:
- master
- develop
- beta
- provider: script
skip_cleanup: true
script: bash $TRAVIS_BUILD_DIR/scripts/upload_to_do.sh
on:
repo: $TRAVIS_REPO_SLUG
branch:
- master
- stable
- develop
- beta
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Exception handler now logs error stacktrace
- `--endpoint` option for `node init` and `node update` commands
- `skale info` command with information about current build
- `skale logs container` command that fetches logs from one of the node containers
- `skale logs dump` command that dumps all logs from the connected node


### Changed

Expand Down
54 changes: 48 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SKALE node CLI

[![Build Status](https://travis-ci.com/skalenetwork/skale-node-cli.svg?token=tLesVRTSHvWZxoyqXdoA&branch=develop)](https://travis-ci.com/skalenetwork/skale-node-cli)
[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)

SKALE Node CLI, part of the SKALE suite of validator tools, is the command line to setup, register and maintain your SKALE node.

## Table of Contents
Expand Down Expand Up @@ -370,6 +373,31 @@ Options:
- `--debug` - show debug logs; more detailed output


##### Container Logs (from 0.2.1)

Fetch logs from one of the node containers:

```bash
skale logs container [NAME]
```

Optional arguments:

- `--lines`, `-l` - Output specified number of lines at the end of logs


##### Dump Logs (from 0.2.2)

Dump all logs from the connected node:

```bash
skale logs dump [PATH]
```

Optional arguments:

- `--container`, `-c` - Dump logs only from specified container


### Validator commands (not implemented yet)

Expand All @@ -385,23 +413,37 @@ skale validator list

## Development

Requirements:
- PyInstaller 3.5+
### Setup repo

Create release:
##### Install development dependencies

```bash
bash build.sh patch/minor/major/keep
pip install -r requirements-dev.txt
```

Build executable:
##### Add flake8 git hook

In file `.git/hooks/pre-commit` add:

```bash
pyinstaller --onefile main.spec
#!/bin/sh
flake8 .
```

### Debugging

Run commands in dev mode:

```bash
ENV=dev python main.py YOUR_COMMAND
```

### Setting up Travis

Required environment variables:

- `ACCESS_KEY_ID` - DO Spaces/AWS S3 API Key ID
- `SECRET_ACCESS_KEY` - DO Spaces/AWS S3 Secret access key
- `GITHUB_EMAIL` - Email of GitHub user
- `GITHUB_OAUTH_TOKEN` - GitHub auth token

2 changes: 1 addition & 1 deletion cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.2.0'
__version__ = '0.3.0'

if __name__ == "__main__":
print(__version__)
3 changes: 2 additions & 1 deletion cli/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ def schains(all):
@login_required
def ls(all):
containers_list = get('skale_containers', {'all': all})
if not containers_list: return
if not containers_list:
return
print_containers(containers_list)
36 changes: 35 additions & 1 deletion cli/logs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import click
from core.helper import login_required, get, download_log_file, local_only
from core.helper import (login_required, get, download_log_file,
local_only, download_dump)
from core.print_formatters import print_logs

from configs.cli_logger import LOG_FILEPATH, DEBUG_LOG_FILEPATH


@click.group()
def logs_cli():
pass
Expand Down Expand Up @@ -43,3 +45,35 @@ def cli(debug):
filepath = DEBUG_LOG_FILEPATH if debug else LOG_FILEPATH
with open(filepath, 'r') as fin:
print(fin.read())


@logs.command(help="Download log file from container on the connected node")
@click.argument('name')
@click.option(
'--lines',
'-l',
help='Output specified number of lines at the end of logs',
default=None
)
@login_required
def container(name, lines):
params = {'container_name': name}
if lines:
params['lines'] = lines
container_logs = get('container_logs', params)
print(container_logs)


@logs.command(help="Dump all logs from the connected node")
@click.option(
'--container',
'-c',
help='Dump logs only from specified container',
default=None
)
@click.argument('path')
@login_required
def dump(container, path):
res = download_dump(path, container)
if res:
print(f'File {res} downloaded')
35 changes: 35 additions & 0 deletions cli/metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import click
from core.helper import login_required, get
from core.print_formatters import print_metrics


@click.group()
def metrics_cli():
pass


@metrics_cli.group('metrics', help="Node metrics commands")
def metrics():
pass


@metrics.command(help="List of bounties and metrics for the first year")
@login_required
def first():
print('Please wait - collecting metrics from blockchain...')
bounty_list = get('first-bounties')
if not bounty_list:
print('No bounties found')
return
print_metrics(bounty_list)


@metrics.command(help="List of bounties and metrics for the last year")
@login_required
def last():
print('Please wait - collecting metrics from blockchain...')
bounty_list = get('last-bounties')
if not bounty_list:
print('No bounties found')
return
print_metrics(bounty_list)
Loading

0 comments on commit 611c1a6

Please sign in to comment.