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

Update contracts workflow #26

Merged
merged 9 commits into from
Mar 21, 2024
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
73 changes: 33 additions & 40 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,31 @@ on:
default: 'nightly'
required: false
type: string
vmtools-version:
description: 'vmtools version to use'
default: 'latest'
required: false
type: string
vmtools-repository:
description: 'vmtools repository to use'
default: 'https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz'
required: false
type: string
pip-mxpy-args:
description: 'pip mxpy install arguments'
default: 'multiversx-sdk-cli==v9.2.0'
default: 'multiversx-sdk-cli==v9.5.2'
required: false
type: string
sc-meta-version:
description: 'multiversx-sc-meta version'
default: ''
required: false
type: string
mx-scenario-go-version:
description: 'sc-scenario-go version'
default: ''
required: false
type: string
path-to-sc-meta:
description: 'multiversx-sc-meta from local'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good - since it will be used in mx-sdk-rs.

default: ''
required: false
type: string
clippy-args:
description: 'cargo clippy arguments'
default: '--all-targets --all-features'
required: false
type: string
install-libtinfo5:
description: 'install libtinfo5'
default: false
required: false
type: boolean
binaryen-version:
description: 'binaryen (wasm-opt) version to use'
default: 'version_112'
Expand Down Expand Up @@ -66,42 +61,41 @@ jobs:
toolchain: ${{ inputs.rust-toolchain }}
target: wasm32-unknown-unknown

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

- name: Install prerequisites
run: |
pip3 install ${{ inputs.pip-mxpy-args }}
mkdir $HOME/multiversx-sdk
python3 -m multiversx_sdk_cli.cli config set "dependencies.vmtools.urlTemplate.linux" ${{ inputs.vmtools-repository }}
python3 -m multiversx_sdk_cli.cli config set "dependencies.vmtools.tag" ${{ inputs.vmtools-version }}
Comment on lines -77 to -78
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Legacy.

python3 -m multiversx_sdk_cli.cli deps install vmtools --overwrite

pipx install ${{ inputs.pip-mxpy-args }}

wget -O binaryen.tar.gz https://github.com/WebAssembly/binaryen/releases/download/${{ inputs.binaryen-version }}/binaryen-${{ inputs.binaryen-version }}-x86_64-linux.tar.gz
tar -xf binaryen.tar.gz
cp binaryen-${{ inputs.binaryen-version }}/bin/wasm-opt $HOME/.local/bin

sudo apt install -y wabt=${{ inputs.wabt-version }}

cargo install wasm-opt
cargo install twiggy

if [[ "${{ inputs.path-to-sc-meta }}" ]];
then
cargo install --path ${{ inputs.path-to-sc-meta }}
fi

if [[ -z "${{ inputs.sc-meta-version }}" ]];
then
cargo install multiversx-sc-meta --locked
else
cargo install multiversx-sc-meta --version ${{ inputs.sc-meta-version }} --locked
fi

which wasm-opt
which wasm2wat
which run-scenarios
if [[ -z "${{ inputs.mx-scenario-go-version }}" ]];
then
sc-meta install mx-scenario-go
else
sc-meta install mx-scenario-go --tag ${{ inputs.mx-scenario-go-version }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 The thing that triggered this change.

fi

- name: Install libtinfo5
if: inputs.install-libtinfo5
run: |
sudo apt update
sudo apt install -y libtinfo5
which mxpy
which wasm-opt
which mx-scenario-go

- name: Build the wasm contracts
env:
Expand All @@ -111,15 +105,14 @@ jobs:
- name: Run the wasm tests
env:
RUSTFLAGS: ""
run:
cargo test --features multiversx-sc-scenario/run-go-tests
run: cargo test --features multiversx-sc-scenario/run-go-tests

- name: Generate the contract report
env:
RUSTFLAGS: ""
run: |
sc-meta all build-dbg --twiggy-paths --target-dir $(pwd)/target --path .
python3 -m multiversx_sdk_cli.cli contract report --skip-build --skip-twiggy --output-format json --output-file report.json
mxpy contract report --skip-build --skip-twiggy --output-format json --output-file report.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since reports aren't yet implemented by sc-meta (as far as we know).


- name: Upload the report json
uses: actions/upload-artifact@v3
Expand All @@ -144,9 +137,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
python3 -m multiversx_sdk_cli.cli 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
python3 -m multiversx_sdk_cli.cli 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 Expand Up @@ -213,5 +206,5 @@ jobs:
env:
RUSTFLAGS: ""
with:
github_token: ${{ secrets.token }}
github_token: ${{ github.token }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so before was secrets.token. Interesting that the change was necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no difference

clippy_flags: ${{ inputs.clippy-args }}
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ permissions:
jobs:
contracts:
name: Contracts
uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v2
uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we release it as a new major version.

with:
rust-toolchain: nightly-2022-12-08
vmtools-version: v1.4.60
rust-toolchain: nightly-2023-12-11
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
```

This uses fixed versions of rust and vmtools.
This uses a fixed version of rust.
See [contracts.yml](.github/workflows/contracts.yml) for more details on which other arguments are supported.

### Main branch notes
Expand Down Expand Up @@ -71,15 +70,6 @@ The mxpy version can be specified by providing:
pip-mxpy-args: multiversx-sdk-cli==1.2.3
```

### Installing libtinfo5

When building smart contracts written in C, on ubuntu, the libtinfo5 has to be installed as clang requires this.
This can be optionally enabled by specifying:
```yml
install-libtinfo5: true
```
Note: if using a matrix build with multiple operating systems, enable this only for ubuntu.

## Usage of `reproducible-build.yml`

See [reproducible-build.yml](.github/workflows/reproducible-build.yml).
Expand Down