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

Handle symlinks #56

Merged
merged 6 commits into from
Feb 20, 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
33 changes: 0 additions & 33 deletions .github/workflows/run_regular_integration_tests.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Long integration tests
name: Tests

on:
workflow_dispatch:
Expand All @@ -19,15 +19,21 @@ jobs:
run: |
docker buildx build --output type=docker --no-cache . -t sdk-rust-contract-builder:next -f ./Dockerfile

- name: Build
- name: Install dependencies
run: |
pip install pytest

- name: Run tests
run: |
export PYTHONPATH=.
pytest .
python ./integration_tests/test_project_folder_and_packaged_src_are_equivalent.py
python ./integration_tests/test_previous_builds_are_reproducible.py --selected-builds "a.1" "a.2" "a.3" "a.4"

- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: testdata_output_long_integration_tests
name: testdata_output
path: |
./testdata/output/**/*.*
if-no-files-found: error
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:22.04

# Constants
ARG BUILDER_NAME="multiversx/sdk-rust-contract-builder:v6.1.0"
ARG BUILDER_NAME="multiversx/sdk-rust-contract-builder:v6.1.1"
ARG VERSION_RUST="nightly-2023-12-11"
ARG VERSION_BINARYEN="version_112"
ARG DOWNLOAD_URL_BINARYEN="https://github.com/WebAssembly/binaryen/releases/download/${VERSION_BINARYEN}/binaryen-${VERSION_BINARYEN}-x86_64-linux.tar.gz"
Expand Down
33 changes: 33 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import shutil

from integration_tests.config import PARENT_OUTPUT_FOLDER
from integration_tests.shared import download_project_repository, run_docker


def test_with_symlinks():
workspace_parent = download_project_repository("https://github.com/multiversx/mx-contracts-rs/archive/refs/tags/v0.45.2.2.zip", "test_with_symlinks")
workspace = workspace_parent / "mx-contracts-rs-0.45.2.2"

output_folder = PARENT_OUTPUT_FOLDER / "test_with_symlinks"
shutil.rmtree(output_folder, ignore_errors=True)
output_folder.mkdir(parents=True, exist_ok=True)

# In the workspace, create a symlink towards something outside it:
dummy_file = workspace_parent / "dummy"
dummy_file.write_text("dummy")
os.symlink(dummy_file, workspace / "dummy")

# But also a symlink towards something inside the workspace:
os.symlink(workspace / ".github", workspace / "github_symlink", target_is_directory=True)

# Symlinks should be ignored, and the build should succeed.
run_docker(
project_path=workspace,
packaged_src_path=None,
contract_name="adder",
image="sdk-rust-contract-builder:next",
output_folder=output_folder
)

assert (output_folder / "artifacts.json").exists()
1 change: 1 addition & 0 deletions integration_tests/test_previous_builds_are_reproducible.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def main(cli_args: List[str]):
contract_name=build.contract_name,
image=build.docker_image,
output_folder=output_folder)

check_code_hashes(build, output_folder)


Expand Down
7 changes: 6 additions & 1 deletion multiversx_sdk_rust_contract_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ def ensure_distinct_contract_names(contracts_folders: List[Path]):
def copy_project_folder_to_build_folder(project_folder: Path, build_root_folder: Path):
shutil.rmtree(build_root_folder, ignore_errors=True)
build_root_folder.mkdir()
shutil.copytree(project_folder, build_root_folder, dirs_exist_ok=True)

shutil.copytree(
project_folder, build_root_folder,
dirs_exist_ok=True, symlinks=True, ignore_dangling_symlinks=True
)

return build_root_folder


Expand Down
Loading