WikiEducationFoundation / WikiEduDashboard

Wiki Education Foundation's Wikipedia course dashboard system
https://dashboard.wikiedu.org
MIT License
386 stars 620 forks source link

Filter workflow steps depending on file changes #5721

Closed prathamVaidya closed 6 months ago

prathamVaidya commented 6 months ago

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

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

Let's close it, thanks.