removes token check on leo add command

- loggin for leo add was not necessary
- login/logout CI is separated
- add/remove checked together w/o logging in
This commit is contained in:
Damir Shamanaev 2021-01-27 15:33:01 +03:00
parent 9fbfebbdfe
commit d4a765398c
3 changed files with 50 additions and 10 deletions

View File

@ -34,13 +34,9 @@ jobs:
command: install
args: --path .
- name: 'leo login & add'
env:
USER: ${{ secrets.ALEO_PM_USERNAME }}
PASS: ${{ secrets.ALEO_PM_PASSWORD }}
- name: 'leo add (w/o login) & remove'
run: |
cd .. && leo new my-app && cd my-app
leo login -u "$USER" -p "$PASS"
leo add argus4130/xnor
leo remove xnor
leo clean

48
.github/workflows/leo-login-logout.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: leo-login-logout
on:
pull_request:
push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'documentation/**'
env:
RUST_BACKTRACE: 1
jobs:
add:
name: Add Package ('leo add')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- name: Install Leo
uses: actions-rs/cargo@v1
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
with:
command: install
args: --path .
- name: 'leo login & logout'
env:
USER: ${{ secrets.ALEO_PM_USERNAME }}
PASS: ${{ secrets.ALEO_PM_PASSWORD }}
run: |
cd .. && leo new my-app && cd my-app
leo login -u "$USER" -p "$PASS"
leo add argus4130/xnor
leo remove xnor
leo clean
leo logout

View File

@ -115,10 +115,6 @@ impl CLI for AddCommand {
// Begin "Adding" context for console logging
let span = tracing::span!(tracing::Level::INFO, "Adding");
let _enter = span.enter();
// token can only be there if user has signed into Aleo PM
// so we need to verify that token exists before doing anything else
let token = read_token().map_err(|_| -> CLIError { NotAuthorized.into() })?;
let path = current_dir()?;
// Enforce that the current directory is a leo package
@ -137,7 +133,7 @@ impl CLI for AddCommand {
json.insert("version", version);
}
match client.post(&url).bearer_auth(token).json(&json).send() {
match client.post(&url).json(&json).send() {
Ok(response) => (response, package_name),
//Cannot connect to the server
Err(_error) => {