actions / actions/runner

Jobs skipped when NEEDS job ran successfully

Open
#2,205 32 comments 92 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the bug
One or more jobs are skipped in a workflow when run after successfully running a job matching following conditions:

  • Job has NEEDS dependency on one or more preceding jobs. (i.e. needs: [job1, job2])
  • Job has if condition specifying behavior when NEEDS jobs are skipped. (i.e. if: always() && needs.job1.result == 'skipped')
  • Preceding job is skipped (i.e. job1)

To Reproduce
Create a workflow as follows:

name: Skipped Job Test

on:
  workflow_dispatch:
  
jobs:
  Skipped-Job:
    name: skipped job
    runs-on: [self-hosted]
    if: 1 != 1
    steps:
    - name: write to console 1
      run: Write-Host "I should be skipped"

  Needs-Job:
    name: needs conditional job
    needs: Skipped-Job
    if: always() && needs.Skipped-Job.result != 'failed' # this should run eventhough needs the skipped-job
    runs-on: [self-hosted]
    steps:
      - name: write to console 2
        run: Write-Host "Needs-Job completed"
  
  Next:
    name: Next job
    needs: Needs-Job
    # if: always() && needs.Needs-Job.result == 'success' # uncommenting this condition causes the job to not be skipped
    runs-on: [self-hosted]
    steps:
      - name: write to console 3
        run: Write-Host "I should print whenever Needs-Job succeeds"

Expected behavior
I'd expect the job "Next" to run, because the preceding job " Needs-Job" is completed successfully and is the only condition for this job to run (it needs Needs-Job), it is however skipped.
uncommenting the 3rd line in that job is a fix, but this feels hacky and shouldn't be needed.

Runner Version and Platform

Current runner version: '2.298.2'

Running on: Windows Server 2022 Standard
Version 21H2
OS build 20348.1006

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the workflow from the issue on the stated runner version and Windows Server 2022, focusing on the Skipped-Job, Needs-Job, and Next dependency chain. Compare the observed result with the expected behavior and the workaround using Next's if condition. Done means Next runs after Needs-Job succeeds without that workaround, with regression coverage for the workflow behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions
Domain
ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.