Skip to content
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

Filter workflow steps depending on file changes #5721

Conversation

prathamVaidya
Copy link
Contributor

What this PR does

Fixes #5720

This is an optimization on the CI workflow ci.yml. By filtering some steps based on file changes we can reduce the workflow execution time.

For Example: If only a javascript file is changed then there is no need to run Ruby tests.

Changes

  • I have updated the ci.yml to use dorny/paths-filter@v3 github action.
  • Created file-filters.yml that will have all the filter tags that can be used to check if a step should run or not.

Current file-filters.yml contents are:

backend:
      - '!app/assets/**'
      - '!app/views/**'
      - '!public/**'
      - '!training_content/**'
      - '!.github/**'

Here a backend filter is defined. The codebase has ruby files everywhere so I have defined the backend is everything other than frontend code, .github and training_content. The more definite this list will be the better it is. Let me know any other paths that needed to be defined here. (One can be all the markdowns *.md)

Ruby tests that took 30 mins will be skipped on all these folders. I have taken inspiration from how sentry repository used this.

I have tested the workflow on my fork at this branch.

Here are some examples of successful workflows:

On Push -> https://github.com/prathamVaidya/WikiEduDashboard/actions/runs/8403231749
On Pull Request -> https://github.com/prathamVaidya/WikiEduDashboard/actions/runs/8403275731 (It failed because it ran flaky RSpecs which it should have because there was a modified ruby file)

@ragesoss Let me know if there is a breaking change associated with this feature. Especially on my assumption that the files in training_content, app/assets do not affect the ruby tests.

@ragesoss
Copy link
Member

Many of the ruby tests are browser-based feature specs, which test against both the JS frontend and the Ruby backend. I prefer to just run the entire test suite for every change, except perhaps changes that are exclusively to docs.

@prathamVaidya
Copy link
Contributor Author

Oh I missed that point completely. I was really thinking why such an obvious optimization has not been done and now I know why. Anyways do you want me to close this PR or update this for docs only?

@ragesoss
Copy link
Member

Let's close it, thanks.

@ragesoss ragesoss closed this Mar 25, 2024
@prathamVaidya prathamVaidya deleted the optimize-workflow branch March 29, 2024 06:54
@prathamVaidya prathamVaidya restored the optimize-workflow branch March 29, 2024 06:54
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.

Optimizing Workflow and Rspec Test Suite
2 participants