docs icon indicating copy to clipboard operation
docs copied to clipboard

Comment in Creating dependent jobs section is vague and confusing

Open gsrohde opened this issue 4 years ago • 4 comments

What article on docs.github.com is affected?

https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#creating-dependent-jobs and/or https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds

What part(s) of the article would you like to see updated?

In https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#creating-dependent-jobs, the possibility of constraining jobs to run sequentially without the failure of earlier jobs in the sequence preventing the later jobs from running: If one of the jobs fails, all dependent jobs are skipped; however, if you need the jobs to continue, you can define this using the if conditional statement.

I had expected, thus, to see an example of how to do this, either directly here or in one of the two linked-to articles (either https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif or https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds).

It is not clear what sort of "if" statement is called for, nor whether it should supplement or replace the "needs" directive. The https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds article reiterates the possibility of constraining jobs to run in sequence without failing jobs preventing later jobs from running: If a job fails, all jobs that need it are skipped unless the jobs use a conditional statement that causes the job to continue. This at least suggests that the "if" statement supplements the "needs" directive, but again, there is no example given of how to do this.

Since the Creating dependent jobs article occurs in the Learn GitHub Actions section of the documentation, it would probably be better to just omit the comment about allowing dependent jobs to run when their precursors fail, or at least to provide or link to an example the clarifies how to set this up.

Additional information

Content Plan

Linked here

gsrohde avatar Oct 23 '20 19:10 gsrohde

Thanks so much for opening an issue @gsrohde! I'll get this triaged for review.

janiceilene avatar Oct 23 '20 23:10 janiceilene

Thanks for pointing this out @gsrohde !

Here is an example of a job continuing based on a conditional even though it needs a job that failed:

name: need-fail-continue

on: [push, workflow_dispatch]

jobs:
  job1:
    runs-on: ubuntu-latest
    steps: 
      - run: exit 1 # This will cause job1 to fail
  
  job2:
    needs: [job1]
    if: ${{ always() }} # This makes job2 run even if job1 fails
    runs-on: ubuntu-latest
    steps: 
      - run: echo '...'
  

I agree with your assessment in the OP of where this example should be added. You or anyone is welcome to open a PR to address this issue!

skedwards88 avatar Dec 03 '20 16:12 skedwards88

Perlukan dector penyensaian masalah

nazarmaddin avatar Dec 10 '20 15:12 nazarmaddin

It should also be made clear, with examples, that the (Job status check functions)[https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#job-status-check-functions] apply to jobs as well as steps.

tonyhallett avatar Mar 25 '21 17:03 tonyhallett

A job should be fully explained I don't know what to figure out how to get it all done and will be trying new things in the internet to get it done 👍

The1onlyit avatar Aug 15 '23 09:08 The1onlyit

As far as I can tell, this issue has been fixed by the many updates to the Actions docs since this was originally raised.

felicitymay avatar Sep 19 '23 14:09 felicitymay