-
Notifications
You must be signed in to change notification settings - Fork 4
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
Contract actions #1
Changes from all commits
2f35761
d5aba91
76d01ba
6300b74
3e38111
2bcfdfc
e8c9668
b3cc695
ad9d991
2e3c13e
6fc9542
d5c07be
2c8afab
52be594
0122484
b8ba2ea
4395937
3f3f8b5
a15525f
12b653d
0de1e60
2832316
5770eb4
dd57fd9
efc9e00
dd04ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
name: Contracts builds and tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
rust-toolchain: | ||
description: 'Rust toolchain to use' | ||
default: 'nightly' | ||
required: false | ||
type: string | ||
vmtools-version: | ||
description: 'vmtools version to use' | ||
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 | ||
secrets: | ||
token: | ||
description: 'Github token' | ||
required: true | ||
|
||
jobs: | ||
wasm_test: | ||
name: Wasm tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
default: true | ||
toolchain: "${{ inputs.rust-toolchain }}" | ||
|
||
- name: Setup the PATH variable | ||
run: echo "PATH=$HOME/.local/bin:$HOME/elrondsdk/vmtools:$PATH" >> $GITHUB_ENV | ||
|
||
- name: Install prerequisites | ||
run: | | ||
pip3 install ${{ inputs.pip-erdpy-args }} | ||
mkdir $HOME/elrondsdk | ||
erdpy deps install vmtools --tag ${{ inputs.vmtools-version }} | ||
|
||
erdpy deps install nodejs | ||
erdpy deps install wasm-opt | ||
|
||
cargo install twiggy | ||
|
||
- name: Build the wasm contracts | ||
run: erdpy contract build -r ${{ inputs.extra-build-args }} | ||
|
||
- name: Run the wasm tests | ||
run: cargo test --features elrond-wasm-debug/mandos-go-tests | ||
|
||
- name: Generate the contract report | ||
run: erdpy contract report --skip-build --output-format json --output-file report.json | ||
|
||
- name: Upload the report json | ||
uses: actions/upload-artifact@v3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps also conditionally (what conditions?) upload the generated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now I focused on porting the existing functionality - I think uploading the contracts from the |
||
with: | ||
name: report | ||
path: report.json | ||
|
||
- name: Download the base report | ||
uses: dawidd6/action-download-artifact@v2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to use the official action, https://github.com/ElrondNetwork/sc-dex-rs/blob/main/.github/workflows/release.yml#L58 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The official action is fairly limited (only allows configuring the artifact name and destination path) and only supports downloading artifacts from the same workflow (from the current commit). |
||
if: github.event_name == 'pull_request' | ||
continue-on-error: true | ||
with: | ||
workflow: actions.yml | ||
name: report | ||
commit: ${{ github.event.pull_request.base.sha }} | ||
path: base-report | ||
|
||
- name: Generate the report template | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
echo "Contract comparison - from {{ .base }} to {{ .head }}" > report.md | ||
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 | ||
else | ||
erdpy 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 | ||
|
||
- name: Render the report from the template | ||
id: template | ||
uses: chuhlomin/render-template@v1.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another community action. Isn't there a simple find & replace command / Python (inline script) that we can use, instead? |
||
if: github.event_name == 'pull_request' | ||
with: | ||
template: report.md | ||
vars: | | ||
base: ${{ github.event.pull_request.base.sha }} | ||
head: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Upload the report markdown | ||
uses: actions/upload-artifact@v3 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
name: report-markdown | ||
path: report.md | ||
|
||
- name: Find the comment containing the report | ||
id: fc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step ID? Is this name fixed or can we change it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think of this ID as a local variable - it's used below in one of the next steps. We can change it if you want - I'm fine with either this or another name. |
||
uses: peter-evans/find-comment@v1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure whether we should depend on community (not Github official) actions or use our own code. @camilbancioiu, @bogdan-rosianu? |
||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: 'Contract comparison' | ||
|
||
- name: Create or update the report comment | ||
uses: peter-evans/create-or-update-comment@v1 | ||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: ${{ steps.template.outputs.result }} | ||
edit-mode: replace | ||
|
||
rust_test: | ||
name: Rust tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
default: true | ||
toolchain: ${{ inputs.rust-toolchain }} | ||
|
||
- name: Run the rust tests | ||
run: cargo test | ||
|
||
clippy_check: | ||
name: Clippy linter check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ inputs.rust-toolchain }} | ||
components: clippy | ||
default: true | ||
- uses: actions-rs/clippy-check@v1 | ||
with: | ||
token: ${{ secrets.token }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
# elrond-actions | ||
Github actions for smart contracts | ||
# Github Actions for smart contracts | ||
|
||
A Github Action for smart contracts which: | ||
- builds the wasm files | ||
- runs mandos-rs and mandos-go tests | ||
- 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. | ||
claudiu725 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Ignores `eei` checks which allows the contracts to use features which are not live on the elrond mainnet yet. | ||
|
||
```yml | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
contracts: | ||
name: Contracts | ||
uses: ElrondNetwork/elrond-actions/.github/workflows/contracts.yml@v1 | ||
with: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🌟 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably erdpy version can be specified as well (optional field)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment the aim is not to make the build deterministic (anyway, this is done through docker images), but only to port the existing functionality and to integrate |
||
rust-toolchain: nightly-2022-01-17 | ||
vmtools-version: v1.4.43 | ||
extra-build-args: --ignore-eei-checks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps in a next PR, there could be a new action, more specific to deterministic builds, which would rely on the frozen docker images? https://github.com/ElrondNetwork/sc-dex-rs/blob/main/.github/workflows/release.yml#L24 And also use a fixed location for the build: https://github.com/ElrondNetwork/sc-dex-rs/blob/main/.github/workflows/release.yml#L31 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. In a future PR it is then 👍 |
||
secrets: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
|
||
### Additional options | ||
|
||
The erdpy version can be specified by providing: | ||
```yml | ||
pip-erdpy-args: erdpy==1.2.3 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--tag=...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasm-opt
should use the latest version