Jobs Run if a Required Job is Filtered

To clarify, a filtered job is a job with a “filter” field that does not match, and does not run in a workflow.

It seems reasonable to expect that if a job has one or more requirements on filtered jobs, then it also won’t run. And this is the case when EVERY required job is filtered.

However, if a job in a workflow has multiple requirements, and at least one of them does run, then it will also run.

This allows dependencies to be completely bypassed and leads to unexpected behavior.

For example, here’s a workflow that works as expected:

workflows:
  version: 2
  build:
    jobs:
      - lint
      - build:
          filters:
            branches:
              only:
                - master
          requires:
            - lint
      - publish:
          requires:
            - build

On the master branch, [lint, build, publish] all run. On every other branch, only [lint] runs.

However, the following behaves super bizarrely:

workflows:
  version: 2
  build:
    jobs:
      - lint
      - build:
          filters:
            branches:
              only:
                - master
      - publish:
          requires:
            - lint
            - build

On master, [lint, build, publish] all run as expected. On every other branch, [lint, publish!] run.

One workaround is to have a filter on every single job in the workflow, but it would be nice to have somewhat less verbose configuration, and it would also be nice to not have some crazy inconsistent behavior with only a slight difference in configuration.

I believe this behavior is more of a feature than a bug. I want a job to run when any applicable requirements are completed. So, if your publish job is not applicable to master, give it a master-only filter.