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

Contract actions #1

Merged
merged 26 commits into from
Mar 24, 2022
Merged

Contract actions #1

merged 26 commits into from
Mar 24, 2022

Conversation

claudiu725
Copy link
Contributor

  • Add contracts.yml
    • Add inputs
      • for specifying rust / vmtools versions
      • for providing extra build arguments (such as --ignore-eei-checks)
    • Integrate erdpy contract report
      • Install twiggy
    • General improvements
      • Made sure the same rust version is used across all 3 jobs
      • Moved the contents of the env file inside contracts.yml
      • Removed the need for ./build-wasm.sh by using the recursive argument for erdpy: erdpy contract build -r
      • Upgraded actions/checkout@v2 -> v3
  • Update README.md
    • Added an usage example
  • Tested workflow
    • In pull requests
      • when the base branch doesn't contain a report
      • when it does
    • After a merge to master (push event)
    • In external pull requests, where github token access is limited

Copy link
Contributor

@andreibancioiu andreibancioiu left a comment

Choose a reason for hiding this comment

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

Nice work!

README.md Show resolved Hide resolved
contracts:
name: Contracts
uses: ElrondNetwork/elrond-actions/.github/workflows/contracts.yml@v1
with:
Copy link
Contributor

Choose a reason for hiding this comment

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

🌟

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably wasm-opt logic / version has an impact on deterministic builds, as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably erdpy version can be specified as well (optional field)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 erdpy contract report. The latest wasm-opt should be fine.
The versions which are fixed at the moment (rust nightly, vmtools) are fixed because we've had broken builds in the past because of changes in those two.
The rust nightly is volatile and since our code depends on a lot of features. For vmtools the outputs of the mandos tests may differ - so upgrades have to be done manually.
I added the possibility to specify the erdpy version and added information about the extra option to the README.md

erdpy deps install vmtools

erdpy deps install nodejs
erdpy deps install wasm-opt
Copy link
Contributor

Choose a reason for hiding this comment

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

--tag=...

Copy link
Contributor Author

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

pip3 install erdpy
mkdir $HOME/elrondsdk
erdpy config set dependencies.vmtools.tag ${{ inputs.vmtools-version }}
erdpy deps install vmtools
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, can use the flag --tag instead of erdpy config set (can also stay as it is).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

run: erdpy contract report --skip-build --output-format json --output-file report.json

- name: Upload the report json
uses: actions/upload-artifact@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps also conditionally (what conditions?) upload the generated /output, as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 output folder can be done in a follow-up PR.

path: report.json

- name: Download the base report
uses: dawidd6/action-download-artifact@v2
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use the official action, actions/download-artifact@v2, instead?

https://github.com/ElrondNetwork/sc-dex-rs/blob/main/.github/workflows/release.yml#L58

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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).
What I need is the artifact from the base branch (same workflow but a different build) - only dawidd6/action-download-artifact@v2 allows me to specify this.


- name: Render the report from the template
id: template
uses: chuhlomin/render-template@v1.2
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

path: report.md

- name: Find the comment containing the report
id: fc
Copy link
Contributor

Choose a reason for hiding this comment

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

Step ID? Is this name fixed or can we change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.


- name: Find the comment containing the report
id: fc
uses: peter-evans/find-comment@v1
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

with:
rust-toolchain: nightly-2022-01-17
vmtools-version: v1.4.43
extra-build-args: --ignore-eei-checks
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. In a future PR it is then 👍

@claudiu725 claudiu725 merged commit c66c139 into main Mar 24, 2022
@claudiu725 claudiu725 deleted the contract-actions branch March 24, 2022 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants