Failed workflows don't re-run on next commit if path's do not match

We have a monorepo with a small example where we have frontend and backend, and we have two separate workflows that run tests if the files match the path.

This works 95% of the time, but there are some really ugly edge cases.

Scenario:

  • Commit broken code to frontend repo
  • Commit working code to backend repo

The PR will be marked as passing, because the last commit only ran the backend workflow, but if merged, we will have a failing master due to the broken frontend code.

How can we deal with this in our codebase without running both the workflows all the time?

I think this can be resolved by using on: pull_request, and then always running all workflows on push to the main branch. I had been using on: push this whole time.