Skip to content

ci(pr): add file type filter to regulate testing jobs#1031

Merged
codejedi365 merged 1 commit intopython-semantic-release:masterfrom
codejedi365:ci/filter-by-changed-files
Sep 26, 2024
Merged

ci(pr): add file type filter to regulate testing jobs#1031
codejedi365 merged 1 commit intopython-semantic-release:masterfrom
codejedi365:ci/filter-by-changed-files

Conversation

@codejedi365
Copy link
Copy Markdown
Contributor

@codejedi365 codejedi365 commented Sep 25, 2024

Purpose

  • Limit the amount of unimportant jobs the CI does

Rationale

I was able to use a file changes detection action that would distinguish what files changed on a PR and subsequently use conditional statements to turn off the long testing jobs (windows) when it was not relevant. This is obvious when you have a bunch of documentation changes but then the CI would run the entire test suite even though no source code or test code was touched.

I determined to break up the parts of the repository into a few categories: build, ci, doc, src, & test. A less than obvious choice I made but the rationale was to include pyproject.toml in the list of source code files because this is the file in which the dependencies are defined. The dependencies might as well be a part of the source as it will be when at runtime. Furthermore this ensures that all Dependabot PRs will execute the test suite which is super important. It is unfortunate that all other project setting changes will cause tests to run as I cannot isolate just the dependency list itself.

Secondly I used the file-change results to enable the lint job upon any of the file categories but it will not run when files outside of any categories are changed. Testing jobs will execute if there is a source code change, a test code change, or CI reconfigurations. Commitlint job will always run because it is irrelevant to what files were changed but always needs to be enforced.

How did you test?

I opened up PRs on my fork with this PR already in main. I used 3 PRs which had different file changes to make sure each set of jobs executed as expected. codejedi365#2 used non-categorized changes which only ran evaluate-changes and commitlint jobs as expected. codejedi365#3 evaluated that document changes would only add the lint job to the set of jobs of the workflow but not tests. codejedi365#4 evaluated that when the source code changed all the tests executed with the rest of the jobs previously required.

How to Verify

Review the pipeline actions or manually re execute the steps described above to open PRs that fit the criteria and ensure that the workflows act as intended.

As you can also see from this PR itself is that the CI file changes were detected and ensured that the test suites were executed along with lint & commitlint.

@codejedi365 codejedi365 merged commit 1fa0e70 into python-semantic-release:master Sep 26, 2024
@codejedi365 codejedi365 deleted the ci/filter-by-changed-files branch September 26, 2024 00:28
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.

1 participant