-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix source code packaging #19
Merged
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
706c072
Exclude "meta/Cargo.lock" from the packaged source code.
andreibancioiu 2836c96
In the packaged source code file, sort entries by path (ascending).
andreibancioiu 52db5b7
Improve unit tests.
andreibancioiu 424fa64
Split tests, order files.
andreibancioiu af984f7
Include whole project, if necessary.
andreibancioiu e212710
Adjust condition for building a specific contract.
andreibancioiu 6959c1b
Add extra tests.
andreibancioiu ef6a4bc
Bump version.
andreibancioiu ee8ac06
Handle both "elrond.json" and "multiversx.json".
andreibancioiu de60e98
Save a "context" name in the artifacts (to keep e.g. the Docker image…
andreibancioiu b81713e
Do not create zip archives of the source code anymore.
andreibancioiu 63e8bc0
Add some test data (for contracts with local dependencies).
andreibancioiu 3fe8b39
Rename, refactor, add source code size warning back.
andreibancioiu 35d7417
Include local dependencies in packaged SRC.
andreibancioiu bbaf069
Add unit test.
andreibancioiu 431ff55
Use "cargo metadata" to get local dependencies.
andreibancioiu 4b7dba4
Handle recursive dependencies (code hash does not match).
andreibancioiu a4d7127
Cleanup before unwrap.
andreibancioiu dc815d4
Properly pass CONTEXT.
andreibancioiu 7bf87a8
Sketch workflow for build and test.
andreibancioiu df35be2
Reproduce previous builds (as a test). Do not force CARGO_TARGET_DIR …
andreibancioiu 485685b
Merge workflow steps.
andreibancioiu 9e47c8d
Fix docker build for tests.
andreibancioiu c42c2c9
Re-create cargo lock.
andreibancioiu a484e3a
Test additional past builds.
andreibancioiu 374f322
Add extra tests (past builds to reproduce).
andreibancioiu 7b70a88
Add extra release to check.
andreibancioiu dde97f5
Add extra previous builds to reproduce (tests).
andreibancioiu 8dea537
Update readme.
andreibancioiu e78718d
Add support script: linking deployed contracts to github releases.
andreibancioiu cfaf6bf
Bit of refactoring, code movement.
andreibancioiu c2998d8
Fix workflow trigger.
andreibancioiu ddd58a0
Adjust tests.
andreibancioiu 6f2e54a
Add new integration test.
andreibancioiu 7574933
Fix worflows for integration tests.
andreibancioiu cda63cc
Enable long integration tests.
andreibancioiu 938765c
Refactor, cleanup tests.
andreibancioiu 1cb3a47
Fix after self-review, fix de-duplication.
andreibancioiu 2e1cd07
Ignore mock dependencies listed in cargo metadata.
andreibancioiu a77f632
Ignore mock packages.
andreibancioiu 976f48e
Debugging.
andreibancioiu 9131cbf
WIP: Cleanup workspace before starting to build (remove tests, dev-de…
andreibancioiu 8ca509c
Some test optimizations etc.
andreibancioiu 19f5a5b
Fix imports.
andreibancioiu 06c3e73
Refactor, fix after self-review.
andreibancioiu 2c327e4
Adjust versions
andreibancioiu 28ec1fe
Merge pull request #20 from multiversx/debug-19
andreibancioiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Long integration tests | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build image | ||
run: | | ||
docker buildx build --output type=docker --no-cache . -t sdk-rust-contract-builder:next -f ./Dockerfile | ||
|
||
- name: Build | ||
run: | | ||
export PYTHONPATH=. | ||
python ./integration_tests/test_previous_builds_are_reproducible.py --selected-builds "a.1" "a.2" "a.3" "b.1" "b.2" "b.3" "c.1" "c.2" "c.3" "c.4" "c.5" "d.1" "e.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Regular integration tests | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build image | ||
run: | | ||
docker buildx build --output type=docker --no-cache . -t sdk-rust-contract-builder:next -f ./Dockerfile | ||
|
||
- name: Build | ||
run: | | ||
export PYTHONPATH=. | ||
python ./integration_tests/test_project_folder_and_packaged_src_are_equivalent.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,4 +132,6 @@ dmypy.json | |
typings/** | ||
|
||
# Test data | ||
testdata/**/output | ||
testdata/input/extracted | ||
testdata/output | ||
testdata/rust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,66 @@ | ||
# mx-sdk-build-contract | ||
# mx-sdk-rust-contract-builder | ||
|
||
Docker image (and wrappers) for reproducible contract builds (Rust). See [docs.multiversx.com](https://docs.multiversx.com/developers/reproducible-contract-builds/). | ||
|
||
## Build the Docker image | ||
|
||
We use `docker buildx` to build the image: | ||
|
||
``` | ||
docker buildx build --output type=docker --no-cache . -t sdk-rust-contract-builder:next -f ./Dockerfile | ||
``` | ||
docker buildx build --no-cache . -t sdk-rust-contract-builder:experimental -f ./Dockerfile | ||
|
||
Maintainers can publish the image as follows: | ||
|
||
``` | ||
docker buildx create --name multiarch --use | ||
|
||
docker buildx build --no-cache --push --platform=linux/amd64,linux/arm64 . -t multiversx/sdk-rust-contract-builder:next -f ./Dockerfile | ||
|
||
docker buildx rm multiarch | ||
``` | ||
|
||
For the above to work properly, make sure to install `tonistiigi/binfmt` beforehand. Please follow the official Docker documentation [here](https://docs.docker.com/build/building/multi-platform/). | ||
|
||
Though, note that currently (January 2023) we recommend against using the `linux/arm64` image for performing reproducible contract builds. This is because, in some (possibly rare) circumstances, a WASM binary generated on the `linux/amd64` image _might_ differ (at the bytecode level) from one generated on the `linux/arm64` image - probably due to distinct (unfortunate) bytecode-emitting logic in the Rust compiler. | ||
|
||
## Build contract using the wrapper | ||
|
||
Without providing `cargo-target-dir`: | ||
If you are using a Mac with ARM64, we _recommend_ setting the following variable beforehand (contract builds will be slower, but this eliminates the risk of not being able to reproduce the build on Linux): | ||
|
||
``` | ||
python3 ./build_with_docker.py --image=sdk-rust-contract-builder:experimental \ | ||
--project=~/contracts/reproducible-contract-build-example \ | ||
--output=~/contracts/output-from-docker | ||
export DOCKER_DEFAULT_PLATFORM=linux/amd64 | ||
``` | ||
|
||
With providing `cargo-target-dir`: | ||
Building from a project folder: | ||
|
||
``` | ||
python3 ./build_with_docker.py --image=sdk-rust-contract-builder:experimental \ | ||
--project=~/contracts/reproducible-contract-build-example \ | ||
--output=~/contracts/output-from-docker \ | ||
--cargo-target-dir=~/cargo-target-dir-docker | ||
python3 ./build_with_docker.py --image=sdk-rust-contract-builder:next \ | ||
--project=~/contracts/example \ | ||
--output=~/contracts/output-from-docker | ||
``` | ||
|
||
Building from a packaged source code: | ||
|
||
``` | ||
python3 ./build_with_docker.py --image=sdk-rust-contract-builder:experimental \ | ||
python3 ./build_with_docker.py --image=sdk-rust-contract-builder:next \ | ||
--packaged-src=~/contracts/example-0.0.0.source.json \ | ||
--output=~/contracts/output-from-docker | ||
``` | ||
|
||
## Build contract using the Docker inner script | ||
|
||
This is useful for useful for testing, debugging and reviewing the script. | ||
## Run unit tests (without Docker) | ||
|
||
``` | ||
export PROJECT=${HOME}/contracts/reproducible-contract-build-example | ||
export OUTPUT=${HOME}/contracts/output | ||
export CARGO_TARGET_DIR=${HOME}/cargo-target-dir | ||
export PATH=${HOME}/multiversx-sdk/vendor-rust/bin:${HOME}/multiversx-sdk/wabt/latest/bin:${PATH} | ||
export RUSTUP_HOME=${HOME}/multiversx-sdk/vendor-rust | ||
export CARGO_HOME=${HOME}/multiversx-sdk/vendor-rust | ||
|
||
pytest . | ||
``` | ||
|
||
Build a project: | ||
## Run integration tests (with Docker) | ||
|
||
``` | ||
python3 ./build_within_docker.py --project=${PROJECT} --output=${OUTPUT} \ | ||
--cargo-target-dir=${CARGO_TARGET_DIR} | ||
python3 ./integration_tests/test_previous_builds_are_reproducible.py --selected-builds "a.1" [...] | ||
python3 ./integration_tests/test_project_folder_and_packaged_src_are_equivalent.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__all__ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pathlib import Path | ||
|
||
DOWNLOADS_FOLDER = Path("./testdata/downloads").resolve() | ||
EXTRACTED_FOLDER = Path("./testdata/input/extracted").resolve() | ||
PARENT_OUTPUT_FOLDER = Path("./testdata/output").resolve() | ||
CARGO_TARGET_DIR = Path("./testdata/rust/cargo_target_dir").resolve() | ||
RUST_REGISTRY = Path("./testdata/rust/registry").resolve() | ||
RUST_GIT = Path("./testdata/rust/git").resolve() | ||
RUST_TMP = Path("./testdata/rust/tmp").resolve() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since
/rust/cargo-target-dir
is used in the Docker image.