Skip to content

ci: run tests intelligently based on changes between consecutive commits #9017

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

Merged
merged 4 commits into from
Aug 11, 2023

Conversation

matifali
Copy link
Member

@matifali matifali commented Aug 10, 2023

We are using dorny/path-filter GitHub action to see which files are changed in our CI.
There is a scenario where it is not optimized.

Current behavior

  1. I change a go file in the first commit, and the path filter detects these changes and runs all go tests.
  2. In 2nd commit, I change some docs and push, the paths filter compares the current PR branch with the main and again detects that a go file and some docs are changed so it runs all go tests

Solution:

run on pushing to any branch.

on:
  push

This will allow using a base property to set the base as the current branch: github.ref and will detect changes between consecutive commits

This seems to work and is skipping other tests when only the .md file is changed
https://github.com/coder/coder/actions/workflows/ci.yaml?query=branch%3Amatifali%2Foptimize-ci

New Behavior

  1. I update a go file, changes is detected and and ci runs go tests.
  2. I update docs, ci detects that only docs are changed so go tests are skipped.
  3. I merge main and it has some go and ts files changes. ci runs all go and ts tests.
  4. I again update only docs, ci skip go and tss tests.

This can save us some ci minutes.

@matifali matifali changed the title ci: oprimize ci ci: optimize CI Aug 10, 2023
@matifali matifali requested a review from deansheather August 10, 2023 12:13
@matifali matifali marked this pull request as ready for review August 10, 2023 15:53
Copy link
Member

@ammario ammario left a comment

Choose a reason for hiding this comment

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

Interesting approach. PR title is a bit vague.

@matifali matifali changed the title ci: optimize CI ci: calculate file changes between consecutive commits Aug 11, 2023
@matifali matifali changed the title ci: calculate file changes between consecutive commits ci: run tests intelligently based on changes between consecutive commits Aug 11, 2023
@matifali matifali merged commit 4d8152d into main Aug 11, 2023
@matifali matifali deleted the matifali/optimize-ci branch August 11, 2023 10:48
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants