Describe the bug
Jobs with a build matrix configuration can be skipped from the top level, before expanding the matrix. This is problematic when the inner-matrix jobs are set as required status checks for a branch protection rule, resulting in the Pull Request hanging forever.
The current dirty fix for this is copying the top level if conditional, for each and every step inside the job, which results in a lot of duplicated code, as well as still having to create and run each inner-matrix job, even though every step is skipped. Additionally, this has the downside of setting the job result to success, instead of skipped. This may be unwanted behaviour in cases where another job would depend on this one, and on it's result being skipped for some conditions.
It would be possible to instead only require the whole matrix as the single status check, but this is not ideal in cases where only some of the inner-matrix jobs are actually a requirement. Again, splitting off into two jobs, with required checks and optional checks, would present a lot of duplicated code, as well as extra internal work for creating the additional top level job.
It would be a lot more efficient to internally expand the job matrix, without running all the jobs, and instantly skipping them in such cases.
The Pull Request that demonstrates this behaviour can be found here, with the workflow code here.
To Reproduce
Steps to reproduce the behavior:
- Create a job, with conditional
if: false, and a build matrix strategy.
- Create a branch protection rule for
main, and add one of the inner matrix jobs as a required status check
- Branch off
main, push a commit, and create a Pull Request from the new branch into main.
- The workflow is now hanging, as the top level job was skipped, and it is waiting for the inner-matrix job.
Expected behavior
The workflow would realise that the whole matrix job was skipped, and thus all it's inner-matrix jobs are implicitly skipped as well, and the Pull Request would not hang.
Runner Version and Platform
GitHub-hosted runner, on ubuntu-latest.
What's not working?
The Pull Request is hanging, as the job was skipped.
Describe the bug
Jobs with a build matrix configuration can be skipped from the top level, before expanding the matrix. This is problematic when the inner-matrix jobs are set as required status checks for a branch protection rule, resulting in the Pull Request hanging forever.
The current dirty fix for this is copying the top level
ifconditional, for each and every step inside the job, which results in a lot of duplicated code, as well as still having to create and run each inner-matrix job, even though every step is skipped. Additionally, this has the downside of setting the job result to success, instead of skipped. This may be unwanted behaviour in cases where another job would depend on this one, and on it's result being skipped for some conditions.It would be possible to instead only require the whole matrix as the single status check, but this is not ideal in cases where only some of the inner-matrix jobs are actually a requirement. Again, splitting off into two jobs, with required checks and optional checks, would present a lot of duplicated code, as well as extra internal work for creating the additional top level job.
It would be a lot more efficient to internally expand the job matrix, without running all the jobs, and instantly skipping them in such cases.
The Pull Request that demonstrates this behaviour can be found here, with the workflow code here.
To Reproduce
Steps to reproduce the behavior:
if: false, and a buildmatrixstrategy.main, and add one of the inner matrix jobs as a required status checkmain, push a commit, and create a Pull Request from the new branch intomain.Expected behavior
The workflow would realise that the whole matrix job was skipped, and thus all it's inner-matrix jobs are implicitly skipped as well, and the Pull Request would not hang.
Runner Version and Platform
GitHub-hosted runner, on ubuntu-latest.
What's not working?
The Pull Request is hanging, as the job was skipped.