actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.65k stars 898 forks source link

Inconsistent behavior in the matrix `if` conditional #2675

Open franciscocpg opened 1 year ago

franciscocpg commented 1 year ago

Describe the bug

The matrix strategy has a bug when using the if condition. When the job is skipped due to the condition, it marks the "parent" job as Skipped, but when the jobs run, it marks the "child" jobs as Successful.

To Reproduce

For instance the job below:

on:
  pull_request:

jobs:
  integration-tests:
    name: Integration tests
    if: ${{ some_condition }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]

    steps:
    - name: Run integration tests
      uses: ./.github/actions/integration_tests

If the if condition is skipped, I'm going to see Integration tests as Skipped in the PR's check else I'm going to see Integration tests (ubuntu-latest) and Integration tests (ubuntu-latest) as Successful. The problem here is that if I configure Integration tests (ubuntu-latest) and Integration tests (ubuntu-latest) jobs as required and the if condition is skipped I'm unable to merge the PR, but skipped required jobs allows us to merge the PR. So I had to duplicate the configuration (use runs-on for each OS instead of using the matrix strategy) above to make it work, eg:

on:
  pull_request:

jobs:
  integration-tests-ubuntu:
    name: Integration tests (ubuntu-latest)
    runs-on: ubuntu-latest

    steps:
    - name: Run integration tests
      uses: ./.github/actions/integration_tests

  integration-tests-mac:
    name: Integration tests (macos-latest)
    runs-on: macos-latest

    steps:
    - name: Run integration tests
      uses: ./.github/actions/integration_tests

Expected behavior

I expected to see Integration tests (ubuntu-latest) and Integration tests (macos-latest) as Skipped instead of Integration tests so I wouldn't need to duplicate the configuration

Runner Version and Platform

Version of your runner? 20230619.1.0

OS of the machine running the runner? OSX/Linux/

What's not working?

Not applicable

Job Log Output

Not applicable

Runner and Worker's Diagnostic Logs

Not applicable

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 15 days.