Often PRs only modify documentation (the top doc/ directory) so there isn't a point in running the unit or integration tests, we should create a script that allows us to determine if a PR is exclusively modifying doc/ and nothing else.
The API should work as follows
python -m pkgmt.ensure_modified --base-branch {BASE} --only {PATH}
For example, to check if the current branch only modified doc/ with respect to the main branch, I can run:
python -m pkgmt.ensure_modified --base-branch main --only doc/
If the current branch has only modified doc/ the command should finish with exit code 0, if files outside doc/ have been modified, it should finish with exit code 1.
Inside Python, we can use subprocess to run git commands and find out. We already have a similar workflow that checks if CHANGELOG.md has been modified but the logic is written in bash, for this issue, we should write the logic in Python as it's easier to maintain. Sample git commands to determine the modified files can be found here.
Note that we need to make a slight modification and add the ... operator, since we're only interested in changes introduced by the current branch (not the ones introduced by the BASE_BRANCH:
git diff --exit-code "$BASE_BRANCH..." doc/
Often PRs only modify documentation (the top
doc/directory) so there isn't a point in running the unit or integration tests, we should create a script that allows us to determine if a PR is exclusively modifyingdoc/and nothing else.The API should work as follows
python -m pkgmt.ensure_modified --base-branch {BASE} --only {PATH}For example, to check if the current branch only modified
doc/with respect to themainbranch, I can run:If the current branch has only modified
doc/the command should finish with exit code 0, if files outsidedoc/have been modified, it should finish with exit code 1.Inside Python, we can use
subprocessto rungitcommands and find out. We already have a similar workflow that checks if CHANGELOG.md has been modified but the logic is written in bash, for this issue, we should write the logic in Python as it's easier to maintain. Sample git commands to determine the modified files can be found here.Note that we need to make a slight modification and add the
...operator, since we're only interested in changes introduced by the current branch (not the ones introduced by theBASE_BRANCH:git diff --exit-code "$BASE_BRANCH..." doc/