Skip to content

Commit

Permalink
Merge pull request #7 from multiversx/migrate-v2
Browse files Browse the repository at this point in the history
Migrate to `mxpy`, use `sc-meta` for builds
  • Loading branch information
claudiu725 authored Jan 26, 2023
2 parents 21d2863 + 890b9da commit 9c19d1a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
46 changes: 21 additions & 25 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,9 @@ on:
default: 'latest'
required: false
type: string
pip-erdpy-args:
description: 'pip erdpy install arguments'
default: 'erdpy'
required: false
type: string
extra-build-args:
description: 'extra build arguments'
default: ''
required: false
type: string
wasm-tests-args:
description: 'wasm tests arguments'
default: '--features elrond-wasm-debug/mandos-go-tests'
pip-mxpy-args:
description: 'pip mxpy install arguments'
default: 'multiversx-sdk-cli'
required: false
type: string
clippy-args:
Expand Down Expand Up @@ -53,37 +43,43 @@ jobs:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
default: true
toolchain: "${{ inputs.rust-toolchain }}"
toolchain: ${{ inputs.rust-toolchain }}
target: wasm32-unknown-unknown

- name: Setup the PATH variable
run: echo "PATH=$HOME/.local/bin:$HOME/elrondsdk/vmtools:$PATH" >> $GITHUB_ENV
run: echo "PATH=$HOME/.local/bin:$HOME/multiversx-sdk/vmtools:$HOME/multiversx-sdk/nodejs/latest/bin:$PATH" >> $GITHUB_ENV

- name: Install prerequisites
run: |
pip3 install ${{ inputs.pip-erdpy-args }}
mkdir $HOME/elrondsdk
erdpy deps install vmtools --tag ${{ inputs.vmtools-version }}
pip3 install ${{ inputs.pip-mxpy-args }}
mkdir $HOME/multiversx-sdk
mxpy deps install vmtools --tag ${{ inputs.vmtools-version }}
erdpy deps install nodejs
erdpy deps install wasm-opt
mxpy deps install nodejs
mxpy deps install wasm-opt
cargo install twiggy
cargo install multiversx-sc-meta
- name: Install libtinfo5
if: inputs.install-libtinfo5
run: |
sudo apt update
sudo apt install -y libtinfo5
- name: Build the wasm contracts
run: erdpy contract build -r ${{ inputs.extra-build-args }}
run: sc-meta all build --no-imports --target-dir $(pwd)/target --path .

- name: Run the wasm tests
run: cargo test ${{ inputs.wasm-tests-args }}
run: cargo test --features multiversx-sc-scenario/run-go-tests

- name: Generate the contract report
run: erdpy contract report --skip-build --output-format json --output-file report.json
run: |
sc-meta all build-dbg --twiggy-paths --target-dir $(pwd)/target --path .
mxpy contract report --skip-build --skip-twiggy --output-format json --output-file report.json
- name: Upload the report json
uses: actions/upload-artifact@v3
Expand All @@ -108,9 +104,9 @@ jobs:
if [ ! -f base-report/report.json ]
then
echo ":warning: Warning: Could not download the report for the base branch. Displaying only the report for the current branch. :warning:" >> report.md
erdpy contract report --compare report.json --output-format github-markdown --output-file report-table.md
mxpy contract report --compare report.json --output-format github-markdown --output-file report-table.md
else
erdpy contract report --compare base-report/report.json report.json --output-format github-markdown --output-file report-table.md
mxpy contract report --compare base-report/report.json report.json --output-format github-markdown --output-file report-table.md
fi
cat report-table.md >> report.md
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

A Github Action for smart contracts which:
- builds the wasm files
- runs mandos-rs and mandos-go tests
- runs both the rust and go testing scenarios
- does a clippy check
- provides a report containing details about the smart contracts

## Usage

### Standard build

See [contracts.yml](.github/workflows/contracts.yml)
This uses fixed versions of rust and vmtools.
Ignores `eei` checks which allows the contracts to use features which are not live on the elrond mainnet yet.

Create a new file under `.github/workflows/actions.yml` with the following contents:
```yml
name: CI

Expand All @@ -30,15 +27,17 @@ permissions:
jobs:
contracts:
name: Contracts
uses: ElrondNetwork/elrond-actions/.github/workflows/contracts.yml@v1
uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v2
with:
rust-toolchain: nightly-2022-01-17
vmtools-version: v1.4.43
extra-build-args: --ignore-eei-checks
rust-toolchain: nightly-2022-12-08
vmtools-version: v1.4.60
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
```
This uses fixed versions of rust and vmtools.
See [contracts.yml](.github/workflows/contracts.yml) for more details on which other arguments are supported.
### Main branch notes
When using the action, pay attention to the branch naming under the push event and use either `main` or `master` accordingly. Using the wrong main branch name will cause the github actions build to be skipped, without displaying an error message.
Expand All @@ -65,11 +64,11 @@ permissions:

## Additional options

### Using a custom erdpy version
### Using a custom mxpy version

The erdpy version can be specified by providing:
The mxpy version can be specified by providing:
```yml
pip-erdpy-args: erdpy==1.2.3
pip-mxpy-args: multiversx-sdk-cli==1.2.3
```

### Installing libtinfo5
Expand Down

0 comments on commit 9c19d1a

Please sign in to comment.