Skip to content

feat: Commit parser w/ path filter for monorepos #614

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

Open
lucasvieirasilva opened this issue Jun 26, 2023 · 6 comments
Open

feat: Commit parser w/ path filter for monorepos #614

lucasvieirasilva opened this issue Jun 26, 2023 · 6 comments
Labels
confirmed Prevent from becoming stale feature A new feature or a feature request

Comments

@lucasvieirasilva
Copy link

Description

Adding the use_only_cwd_commits config makes it possible to make the semantic release look for commits in the cwd folder only.

The default behavior is any commit in the repo can trigger a package release.

https://github.com/python-semantic-release/python-semantic-release/blob/master/semantic_release/vcs_helpers.py#L19-L26

_repo: Optional[Repo]
_sub_directory = ""
try:
    _repo = Repo(".", search_parent_directories=True)
    if config.get("use_only_cwd_commits") and config.get("version_source") == "commit":
        _sub_directory = os.path.relpath(os.getcwd(), _repo.working_dir)
except InvalidGitRepositoryError:
    _repo = None

it will be good to have a config option to define one or more folders in the repo to semantic release CLI look for commits.

Use cases

Monorepo: When you have multiple packages in the same repo, you can use use_only_cwd_commits to force the semantic release to look for commits only in the package folder.

However, when you have local dependencies that could potentially trigger the release of the application, it is required to look at multiple folders to decide if a release is necessary.

Issue reference: lucasvieirasilva/nx-plugins#122

Example:

- apps/app1/pyproject.toml
- libs/lib1/pyproject.toml

In this example, app1 references lib1 as a local dependency using the Poetry path reference https://python-poetry.org/docs/dependency-specification/#path-dependencies

...
[tool.poetry]
name = "app1"
...

    [tool.poetry.dependencies.lib1]
    path = "../../libs/lib1"
    develop = true
...

If something changes in the lib1 it should trigger the app1 release, however, the commit path is only in the libs/lib1 folder, not in the apps/app1 folder.

In this case, the use_only_cwd_commits config isn't gonna work.

If we have the option to specify multiple paths for the commit analyzer, I could explicitly reference libs/lib1 in the apps/app1/pyproject.toml semantic release config.

Possible implementation

  • a new config entry commit_paths that accepts a list of paths.
[tool.semantic_release]
version_variable = [
    "pyproject.toml:version"
]
branch = "main"
upload_to_pypi = false
upload_to_release = false
commit_paths = [
    "apps/app1",
    "libs/lib1"
]
@lucasvieirasilva lucasvieirasilva added the feature A new feature or a feature request label Jun 26, 2023
@github-actions github-actions bot added the stale label Mar 25, 2024
@codejedi365 codejedi365 added confirmed Prevent from becoming stale and removed stale labels Mar 29, 2024
@codejedi365 codejedi365 added this to the Monorepo support milestone Mar 30, 2024
@codejedi365 codejedi365 removed the confirmed Prevent from becoming stale label Mar 30, 2024
@github-actions github-actions bot added the stale label Jun 29, 2024
@codejedi365 codejedi365 removed the stale label Jun 29, 2024
@github-actions github-actions bot added the stale label Sep 28, 2024
@codejedi365 codejedi365 added confirmed Prevent from becoming stale and removed stale labels Oct 3, 2024
@codejedi365 codejedi365 changed the title Filter Paths Commits Analyzer feat: Commit parser w/ path filter for monorepos Oct 3, 2024
Copy link

github-actions bot commented Dec 3, 2024

It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?

@github-actions github-actions bot added the needs-update Needs status update from maintainers label Dec 3, 2024
@codejedi365
Copy link
Contributor

Still in backlog

@github-actions github-actions bot removed the needs-update Needs status update from maintainers label Dec 4, 2024
Copy link

github-actions bot commented Feb 3, 2025

It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?

@github-actions github-actions bot added the needs-update Needs status update from maintainers label Feb 3, 2025
@codejedi365
Copy link
Contributor

codejedi365 commented Feb 3, 2025

There is an open PR for this now, it needs automated testing and some updates but initially it works for an initial custom parser use.

Should be released over the next two months

@github-actions github-actions bot removed the needs-update Needs status update from maintainers label Feb 4, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Feb 23, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Feb 27, 2025
Copy link

github-actions bot commented Apr 6, 2025

It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?

@github-actions github-actions bot added the needs-update Needs status update from maintainers label Apr 6, 2025
@codejedi365
Copy link
Contributor

I haven't had enough time to finish this off but it is still will be completed soon.

@github-actions github-actions bot removed the needs-update Needs status update from maintainers label Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed Prevent from becoming stale feature A new feature or a feature request
Projects
None yet
Development

No branches or pull requests

2 participants