Skip to content

Commit

Permalink
Merge pull request #331 from multiversx/globally-install-rust
Browse files Browse the repository at this point in the history
Install rust globally
  • Loading branch information
popenta authored Oct 2, 2023
2 parents 51a7318 + d8bb7a4 commit 4cfcf50
Show file tree
Hide file tree
Showing 21 changed files with 262 additions and 310 deletions.
78 changes: 39 additions & 39 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,54 @@ name: build

on:
pull_request:
branches: [ main, feat/* ]
branches: [main, feat/*]
workflow_dispatch:

jobs:
build:
name: Build and Test mxpy for ${{ matrix.os }}, python ${{ matrix.python-version }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [windows-2019]
python-version: [3.8]
python-version: [3.11]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install pytest
- name: Set github_api_token
shell: bash
run: |
mkdir ~/multiversx-sdk
export PYTHONPATH=.
python3 -m multiversx_sdk_cli.cli config new test
python3 -m multiversx_sdk_cli.cli config set github_api_token ${{ secrets.GITHUB_TOKEN }}
- name: Setup test dependencies
shell: bash
run: |
python3 -m multiversx_sdk_cli.cli deps install testwallets
- name: Run unit tests
shell: bash
run: |
export PYTHONPATH=.
pytest -m "not skip_on_windows" .
- name: Run CLI tests
shell: bash
run: |
export PROXY=https://testnet-gateway.multiversx.com
export CHAIN_ID=T
cd ./multiversx_sdk_cli/tests
source ./test_cli_tx.sh && testAll || return 1
source ./test_cli_dns.sh && testOffline || return 1
source ./test_cli_validators.sh && testAll || return 1
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install pytest
- name: Set github_api_token
shell: bash
run: |
mkdir ~/multiversx-sdk
export PYTHONPATH=.
python3 -m multiversx_sdk_cli.cli config new test
python3 -m multiversx_sdk_cli.cli config set github_api_token ${{ secrets.GITHUB_TOKEN }}
- name: Setup test dependencies
shell: bash
run: |
python3 -m multiversx_sdk_cli.cli deps install testwallets
- name: Run unit tests
shell: bash
run: |
export PYTHONPATH=.
pytest -m "not skip_on_windows" .
- name: Run CLI tests
shell: bash
run: |
export PROXY=https://testnet-gateway.multiversx.com
export CHAIN_ID=T
cd ./multiversx_sdk_cli/tests
source ./test_cli_tx.sh && testAll || return 1
source ./test_cli_dns.sh && testOffline || return 1
source ./test_cli_validators.sh && testAll || return 1
75 changes: 37 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,52 @@ name: build

on:
pull_request:
branches: [ main, feat/* ]
branches: [main, feat/*]
workflow_dispatch:

jobs:
build:
name: Build and Test mxpy for ${{ matrix.os }}, python ${{ matrix.python-version }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.8, 3.11]
python-version: [3.11]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install pytest
- name: Install libtinfo5
if: ${{ matrix.os != 'macos-latest' }}
run: |
sudo apt update
sudo apt install -y libtinfo5
- name: Set github_api_token
run: |
mkdir ~/multiversx-sdk
export PYTHONPATH=.
python3 -m multiversx_sdk_cli.cli config new test
python3 -m multiversx_sdk_cli.cli config set github_api_token ${{ secrets.GITHUB_TOKEN }}
- name: Setup test dependencies
run: |
python3 -m multiversx_sdk_cli.cli deps install testwallets
python3 -m multiversx_sdk_cli.cli deps install wasm-opt
- name: Run unit tests
run: |
export PYTHONPATH=.
pytest .
- name: Run CLI tests
run: |
python3 -m multiversx_sdk_cli.cli config set dependencies.vmtools.tag v1.4.60
cd ./multiversx_sdk_cli/tests
source ./test_cli_contracts.sh && testAll || return 1
source ./test_cli_dns.sh && testOffline || return 1
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install pytest
- name: Install libtinfo5
if: ${{ matrix.os != 'macos-latest' }}
run: |
sudo apt update
sudo apt install -y libtinfo5
- name: Set github_api_token
run: |
mkdir ~/multiversx-sdk
export PYTHONPATH=.
python3 -m multiversx_sdk_cli.cli config new test
python3 -m multiversx_sdk_cli.cli config set github_api_token ${{ secrets.GITHUB_TOKEN }}
- name: Setup test dependencies
run: |
python3 -m multiversx_sdk_cli.cli deps install testwallets
- name: Run unit tests
run: |
export PYTHONPATH=.
pytest .
- name: Run CLI tests
run: |
python3 -m multiversx_sdk_cli.cli config set dependencies.vmtools.tag v1.4.60
cd ./multiversx_sdk_cli/tests
source ./test_cli_contracts.sh && testAll || return 1
source ./test_cli_dns.sh && testOffline || return 1
4 changes: 2 additions & 2 deletions .github/workflows/install-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
workflow_dispatch:

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
install:
runs-on: macos-latest

strategy:
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
workflow_dispatch:

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
install:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
workflow_dispatch:

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
install:
runs-on: windows-2019

strategy:
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
5 changes: 2 additions & 3 deletions multiversx_sdk_cli/cli_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def setup_parser(subparsers: Any) -> Any:
sub = cli_shared.add_command_subparser(subparsers, "deps", "install", "Install dependencies or multiversx-sdk modules.")
sub.add_argument("name", choices=choices, help="the dependency to install")
sub.add_argument("--overwrite", action="store_true", default=False, help="whether to overwrite an existing installation")
sub.add_argument("--tag", help="the tag or version to install")
sub.set_defaults(func=install)

sub = cli_shared.add_command_subparser(subparsers, "deps", "check", "Check whether a dependency is installed.")
Expand All @@ -30,9 +29,8 @@ def setup_parser(subparsers: Any) -> Any:

def install(args: Any):
name: str = args.name
tag: str = args.tag
overwrite: bool = args.overwrite
dependencies.install_module(name, tag, overwrite)
dependencies.install_module(name, overwrite)


def check(args: Any):
Expand All @@ -42,6 +40,7 @@ def check(args: Any):
default_tag: str = config.get_dependency_tag(module.key)
tag_to_check = tag or default_tag
resolution: str = config.get_dependency_resolution(module.key)
resolution = resolution if resolution else "HOST"

logger.info(f"Checking dependency: module = {module.key}, tag = {tag_to_check}; default tag = {default_tag}, resolution = {resolution}")

Expand Down
13 changes: 2 additions & 11 deletions multiversx_sdk_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,19 @@ def get_defaults() -> Dict[str, Any]:
"dependencies.vmtools.urlTemplate.linux": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz",
"dependencies.vmtools.urlTemplate.osx": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz",
"dependencies.vmtools.urlTemplate.windows": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz",
"dependencies.llvm.tag": "v9-19feb",
# ide.elrond.com will be removed, TBD if clang will still be downloaded
"dependencies.llvm.urlTemplate.linux": "https://ide.elrond.com/vendor-llvm/{TAG}/linux-amd64.tar.gz?t=19feb",
"dependencies.llvm.urlTemplate.osx": "https://ide.elrond.com/vendor-llvm/{TAG}/darwin-amd64.tar.gz?t=19feb",
"dependencies.rust.resolution": "SDK",
"dependencies.rust.tag": "nightly-2023-05-26",
"dependencies.golang.resolution": "SDK",
"dependencies.golang.tag": "go1.20.7",
"dependencies.golang.urlTemplate.linux": "https://golang.org/dl/{TAG}.linux-amd64.tar.gz",
"dependencies.golang.urlTemplate.osx": "https://golang.org/dl/{TAG}.darwin-amd64.tar.gz",
"dependencies.golang.urlTemplate.windows": "https://golang.org/dl/{TAG}.windows-amd64.zip",
"dependencies.wasm-opt.tag": "latest",
"dependencies.twiggy.tag": "latest",
"dependencies.sc-meta.tag": "latest",
"dependencies.testwallets.tag": "latest",
"dependencies.testwallets.urlTemplate.linux": "https://github.com/multiversx/mx-sdk-testwallets/archive/{TAG}.tar.gz",
"dependencies.testwallets.urlTemplate.osx": "https://github.com/multiversx/mx-sdk-testwallets/archive/{TAG}.tar.gz",
"dependencies.testwallets.urlTemplate.windows": "https://github.com/multiversx/mx-sdk-testwallets/archive/{TAG}.tar.gz",
"dependencies.wasm-opt.resolution": "SDK",
"dependencies.wasm-opt.tag": "version_112",
"dependencies.wasm-opt.urlTemplate.linux": "https://github.com/WebAssembly/binaryen/releases/download/{TAG}/binaryen-{TAG}-x86_64-linux.tar.gz",
"dependencies.wasm-opt.urlTemplate.osx": "https://github.com/WebAssembly/binaryen/releases/download/{TAG}/binaryen-{TAG}-x86_64-macos.tar.gz",
"dependencies.wasm-opt.urlTemplate.windows": "https://github.com/WebAssembly/binaryen/releases/download/{TAG}/binaryen-{TAG}-x86_64-windows.tar.gz",
"dependencies.wasm-opt.tag": "0.112.0",
"github_api_token": "",
}

Expand Down
30 changes: 8 additions & 22 deletions multiversx_sdk_cli/dependencies/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
from typing import Dict, List

from multiversx_sdk_cli import config, errors
from multiversx_sdk_cli.dependencies.modules import (CargoModule, TestWalletsModule, VMToolsModule,
DependencyModule, GolangModule, Rust, StandaloneModule, WasmOptModule)
from multiversx_sdk_cli.dependencies.modules import (DependencyModule,
GolangModule, Rust,
TestWalletsModule,
VMToolsModule)

logger = logging.getLogger("install")


def install_module(key: str, tag: str = "", overwrite: bool = False):
def install_module(key: str, overwrite: bool = False):
if key == 'all':
modules = _get_implicitly_installable_deps()
modules = _get_all_deps()
else:
modules = [get_module_by_key(key)]

for module in modules:
module.install(tag, overwrite)
module.install(overwrite)


def get_module_directory(key: str) -> Path:
Expand Down Expand Up @@ -46,26 +48,10 @@ def get_deps_dict() -> Dict[str, DependencyModule]:


def _get_all_deps() -> List[DependencyModule]:
return _get_explicitly_installable_deps() + _get_implicitly_installable_deps()


def _get_explicitly_installable_deps() -> List[DependencyModule]:
return [
StandaloneModule(key="llvm", aliases=["clang", "cpp"]),
Rust(key="rust"),
GolangModule(key="golang")
]


def _get_implicitly_installable_deps() -> List[DependencyModule]:
# See: https://github.com/multiversx/mx-sdk-py-cli/pull/55

return [
GolangModule(key="golang"),
VMToolsModule(key="vmtools"),
StandaloneModule(key="mx_chain_go", repo_name="mx-chain-go", organisation="multiversx"),
StandaloneModule(key="mx_chain_proxy_go", repo_name="mx-chain-proxy-go", organisation="multiversx"),
WasmOptModule(key="wasm-opt"),
CargoModule(key="twiggy"),
TestWalletsModule(key="testwallets")
]

Expand Down
Loading

0 comments on commit 4cfcf50

Please sign in to comment.