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

Optional pinning of the deployment version to the project version #17

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CiottiGiorgio
Copy link
Member

This PR proposes modifying the template to allow the user to pin the deployment version to the project version.
The user would enable this feature by un-commenting a single line in deployment_config.py for each contract that they want to pin.
We resorted to reading the project version from pyproject.toml using tomllib (and not by installing an editable version in the local venv) because a TS deployer cannot access the version that way. Parsing the TOML makes more sense from a code parity standpoint.

At the point of writing this PR, the version is a string that is not used to determine if a deploy should result in an update/replace/append action.

This is still a work in progress. Items missing are:

  • Version pin at project level vs per each smart contract
  • Untyped dictionary from tomllib makes mypy complain
  • Determine if this version pin only makes sense for non-local networks (seen as the most likely scenario for LocalNet is that people deploy a new iteration of the contract without changing the project version) (this shouldn't be an issue because the version does not influence a deploy action)
  • TS deployer

Copy link
Collaborator

@aorumbayev aorumbayev left a comment

Choose a reason for hiding this comment

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

@CiottiGiorgio make sure to also regenerate example's folder ( by running poetry run pytest) which is also used as an artifacts root for snapshot testing.


def find_app_spec_file(output_dir: Path) -> str | None:
for file in output_dir.iterdir():
if file.is_file() and file.suffixes == [".arc32", ".json"]:
return file.name
return None


def find_pyproject_version(pyproject_toml: Path) -> str | None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about something like this instead

def find_pyproject_version(pyproject_toml: Path) -> str | None:
    """Finds the project version from a 'pyproject.toml' file.

    Args:
        pyproject_toml: The path to the 'pyproject.toml' file.

    Returns:
        The project version if found, otherwise None.
    """

    try:
        data = tomllib.load(pyproject_toml.open('rb'))
        return data.get('tool', {}).get('poetry', {}).get('version')
    except (FileNotFoundError, tomllib.TOMLDecodeError):
        return None 

@aorumbayev
Copy link
Collaborator

@CiottiGiorgio to patch last ci error make sure to run pre-commit to auto fix the code

@aorumbayev
Copy link
Collaborator

@CiottiGiorgio just checking in, whats the latest on the following ? Is this tracked against some reported issue? Can merge this as soon as the ci cd is fixed

@CiottiGiorgio
Copy link
Member Author

Hey sorry been busy with other tasks. I plan on resuming this work next week.
Is this blocking anything?

@aorumbayev
Copy link
Collaborator

@CiottiGiorgio no rush, not blocking - can re review as soon as you merge conflicts

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