runner icon indicating copy to clipboard operation
runner copied to clipboard

Required checks not passing for reusable workflows

Open adrielldagasuan opened this issue 3 years ago • 14 comments

Describe the bug Required checks do not pass for reusable workflows

To Reproduce Steps to reproduce the behavior:

  1. Create a status check for a job name (ie pipeline)
  2. Create a reusable workflow with a job similar to the required check (ie. pipeline)
  3. Create a new workflow using the reusable workflow

Expected behavior The required status check should acknowledge the workflow run

Runner Version and Platform

Version of your runner? 2.292.0

OS of the machine running the runner? Linux

What's not working?

The workflow runs but the required check is still waiting: image

The required check is docker. The job in the reusable workflow is docker. The job that calls the reusable workflow is docker.

adrielldagasuan avatar May 26 '22 11:05 adrielldagasuan

I just got into this problem today, the reusable workflow seems to have name constructed as <parent_job_name> / <reusable_workflow_name> but when I want to use that for status check it is not possible to find it

iwo-polanski-brainly avatar May 27 '22 14:05 iwo-polanski-brainly

I just got into this problem today, the reusable workflow seems to have name constructed as <parent_job_name> / <reusable_workflow_name> but when I want to use that for status check it is not possible to find it

How were you able to resolve that?

KausarNaqvi avatar Aug 06 '22 19:08 KausarNaqvi

I think the problem is with the events on the workflow. Github is detecting status checks only if the workflow has a on: pull_request event. The way around would be moving the reusable workflow to a reusable action and then adding it to a workflow with a job_id as the status check name.

dvj1988 avatar Aug 09 '22 04:08 dvj1988

Same story, I have two different workflows for different head branches, so how should I add them to Status checks that are required.?

rkhaslarov avatar Sep 19 '22 14:09 rkhaslarov

I think this should just not be configured in the UI (which has a terrible UX by the way), but be configurable in the yml file. I also think that by default all checks should be required that run as part of the PR. The only reason we configure the required check is because it's a prerequisite for having the check that makes sure the branch is up-to-date (and I don't understand why this prerequisite is there at all...).

sblask avatar Oct 11 '22 05:10 sblask

I my case it was because I was using a job name and the branch name with a variable(github was showing the job name in the rules tab). After I removed the name It worked ok

WilmanVasquez avatar Feb 01 '23 20:02 WilmanVasquez

Ran into this too. Why is it not possible to have reusable workflow as a requirement check for merging into master? This is absolutely basic functionality. Why then even have reusable workflows when I can just shove it all into one insanely huge yAML to work around this?

🤦‍♂️ I am regretting ever having to use github actions. We can now write a book about how terrible it is.

lunemec avatar Feb 14 '23 09:02 lunemec

Is this bug still not resolved? Do y'all know any workaround besides just turning those required checks off? I think @dvj1988 might've had something here although in our case, we actually containerize our CICD with our own Docker images so we have to use re-usable workflows instead of actions.

LuWang1983 avatar Apr 20 '23 15:04 LuWang1983

Actually I may have a workaround for y'all. Instead of configure multiple required checks using re-usable workflows, add a final step (e.g. name: CI Workflow Status) that collects all the previous workflow statuses using GHA plugin martialonline/workflow-status@v4 and don't use a re-usable workflow for that step.

In the repo branch protection rule, configure only that step CI Workflow Status in the required checks. This step basically will fail if any of the dependencies fails and will succeed and allows to merge if every step before succeeds.

Just a few more lines of code in the script with no major overhaul but at least it resolves the required checks being stuck. Hope this helps!

LuWang1983 avatar Apr 20 '23 19:04 LuWang1983

No fix yet? 1 year birthday on May 26th.

felipedummer avatar May 11 '23 15:05 felipedummer

We were able to fix this by making sure the call to the reusable workflow follow the "actions" syntax: {org}/{repo}/.github/workflow/action.yaml@master just ensure your GITTOKEN has access to the local repos, as an example. If we tried to call the action/workflow locally .github/worksflows/etc.... it matched what @adrielldagasuan posted above. Why this works I have no idea but it solved our issue. You can also self reference your own workflow locally if you don't store your global actions in a separate repo

MarkEnverus avatar May 11 '23 16:05 MarkEnverus

I think we have this issue too. Any updates from the Github team?

sandstrom avatar Feb 05 '24 15:02 sandstrom

Have the same issue. Any updates?

ArtemSliusarenko avatar Feb 07 '24 08:02 ArtemSliusarenko

same issue here :\

Ron-Be avatar Aug 13 '24 12:08 Ron-Be

@LuWang1983 thanks for workaround!

IlyaGulya avatar Oct 15 '24 14:10 IlyaGulya

A simpler workaround is to have a follow-up job that depends on the reusable workflow and mirrors its results. Here's a complete example:

name: My workflow

on:
  pull_request:
    branches:
      - main

jobs:
  run-reusable-workflow:
    uses: myorg/reusable-workflow-library/.github/workflows/awesome-workflow-v1.yaml@main

  check-result:
    needs: run-reusable-workflow
    if: always()
    runs-on: ubuntu-latest
    steps:
      - run: exit ${{ needs.run-reusable-workflow.result != 'success' && '1' || '0' }}

This works pretty well for us.

Allon-Guralnek avatar Nov 28 '24 00:11 Allon-Guralnek

If someone needs follow-up job to pass in case dependent is skipped, here's how I check it:

name: My workflow

on:
  pull_request:
    branches:
      - main

jobs:
  run-reusable-workflow:
    uses: myorg/reusable-workflow-library/.github/workflows/awesome-workflow-v1.yaml@main

  check-result:
    needs: run-reusable-workflow
    if: always()
    runs-on: ubuntu-latest
    steps:
      - run: exit 1
        if: ${{ contains(fromJSON('["failure", "cancelled"]'), needs.run-reusable-workflow.result) }}

IlyaGulya avatar Jan 20 '25 14:01 IlyaGulya