Skip to content

[WIP] feat: Filter copr_build jobs based on paths and files changed #2780

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

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

Conversation

LecrisUT
Copy link
Contributor

@LecrisUT LecrisUT commented Apr 16, 2025

TODO:

  • Skip the check if /packit command is used
  • Actually check the files changed
  • Write new tests or update the old ones to cover new functionality.
  • Update or write new documentation in packit/packit.dev.

Fixes packit/packit#1997
Fixes #2006

RELEASE NOTES BEGIN

copr_build jobs are triggered only if there are changed files under the paths field

RELEASE NOTES END

Comment on lines +170 to +174
# FIXME: Implement the relevant git diff
return []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently stuck on this part. Isn't the git repo cloned somewhere when the package_config was evaluated? I was hoping on using that to do the git diff, but I haven't navigated to such a part. Should that be an interface in ogr instead?

Copy link
Member

Choose a reason for hiding this comment

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

LocalProjectMixin should give you self.local_project.git_repo which is git.Repo.

class LocalProjectMixin(Config):
_local_project: Optional[LocalProject] = None
@property
def local_project(self) -> LocalProject:
if not self._local_project:
builder = LocalProjectBuilder(
cache=(
RepositoryCache(
cache_path=self.service_config.repository_cache,
add_new=self.service_config.add_repositories_to_repository_cache,
)
if self.service_config.repository_cache
else None
),
)
working_dir = Path(
Path(self.service_config.command_handler_work_dir) / SANDCASTLE_LOCAL_PROJECT_DIR,
)
kwargs = {
"repo_name": CALCULATE,
"full_name": CALCULATE,
"namespace": CALCULATE,
"working_dir": working_dir,
"git_repo": CALCULATE,
}
if self.project:
kwargs["git_project"] = self.project
else:
kwargs["git_url"] = self.project_url
self._local_project = builder.build(**kwargs)
return self._local_project

Copy link
Member

Choose a reason for hiding this comment

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

on our arch meeting we were discussing we could get this rather via API, this would mean implementing the method for getting a commit in ogr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can go either way on LocalProject vs ogr

ogr

pro

  • easier interface
  • don't have to deal with fork fetches

con

  • it downloads the diff content thatis ignored
  • may be slower and rate limited because it goes through web api

LocalProject

pro

  • already used by osh (didn't check if we would be reusing it though)
  • still downloads the diffs, but it's more efficient at that
  • no rate/file limits

con

  • handling PRs is a bit clunky
  • if the git is not cached it could be more expensive to re-clone the project every time

I am leaning towards the ogr approach. What's your thoughts on the choice of these 2?

Copy link
Member

@lbarcziova lbarcziova Apr 17, 2025

Choose a reason for hiding this comment

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

+1 for the ogr/API approach, we would be checking this only if this is configured in the config, so I believe it would not be such a big additional API load in the end, and sounds more straightforward; I don't like cloning the repo already in the pre-check that much

Copy link
Contributor

Copy link
Contributor

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.

[RFE] Filter copr builds on path change When using monorepo, react only on changes done to configured paths
3 participants