Skip to content

Support optional flag in depends_on for workflows and steps#6461

Merged
6543 merged 22 commits into
woodpecker-ci:mainfrom
simonmeyerrr:feat/optional-depends-on
May 28, 2026
Merged

Support optional flag in depends_on for workflows and steps#6461
6543 merged 22 commits into
woodpecker-ci:mainfrom
simonmeyerrr:feat/optional-depends-on

Conversation

@simonmeyerrr
Copy link
Copy Markdown
Contributor

@simonmeyerrr simonmeyerrr commented Apr 17, 2026

Fixes #6457
Fixes #3823

Summary

Extends depends_on to accept objects with name and optional fields, at both workflow and step level. When optional: true, the dependency is silently dropped if the referenced workflow/step is not part of the pipeline (e.g. filtered out by when conditions). If present, it is enforced as usual.

This is useful in monorepos where workflows use when: path or when: evaluate to only run when relevant files change, but a downstream workflow (like deploy) needs to wait for all checks that actually ran.

Example

# .woodpecker/deploy.yaml
depends_on:
  - check-a
  - name: check-b
    optional: true
  - name: check-c
    optional: true

steps:
  - name: deploy
    image: alpine
    commands:
      - echo deploying

If check-b and check-c are filtered out by their when conditions, deploy runs after check-a succeeds. If they are present, deploy waits for all three.

The same syntax works at step level within a workflow.

All existing formats (string, string[]) remain fully backward compatible.

Changes

  • Add Dependency struct and DependsOn type (base/depends_on.go) with custom YAML marshal/unmarshal supporting string, string array, object array, and mixed array
  • Use DependsOn type in both Workflow and Container (step) structs
  • At build time, drop optional deps referencing non-existent workflows/steps (no runtime/queue changes needed)
  • Update DAG compiler to handle optional step dependencies
  • Update JSON schema, linter, and docs
  • Add unit tests for the new type (unmarshal, marshal, helpers), DAG compiler (3 step-level cases), and step builder (4 workflow-level cases)
  • Add e2e scenarios for both workflow-level and step-level optional dependencies

6543
6543 previously requested changes Apr 17, 2026
Copy link
Copy Markdown
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm against a new top level field and would rather alter tje depends on in a unified way ... so steps also can use it etc...

@6543
Copy link
Copy Markdown
Member

6543 commented Apr 17, 2026

e.g. current depends_on allows string and strin array.
new could also allow object with name and mode field ...

-> need more consensus by all maintainers first

@6543
Copy link
Copy Markdown
Member

6543 commented Apr 17, 2026

looking at #3823 (comment) there is already consensus howbit should look like

@qwerty287
Copy link
Copy Markdown
Contributor

Thanks! I also agree to @6543, would prefer a config like

depends_on: 
  - name: previous-step
    optional: true

And I think we should also support that on step level.

@simonmeyerrr simonmeyerrr changed the title feat: add optional_depends_on for workflows feat: support optional flag in depends_on for workflows and steps Apr 20, 2026
@simonmeyerrr
Copy link
Copy Markdown
Contributor Author

Updated per feedback from @6543 and @qwerty287.

The separate optional_depends_on field is gone. Instead, depends_on now accepts objects alongside strings:

depends_on:
  - check-a
  - name: check-b
    optional: true

This works at both workflow level and step level, as suggested. Plain strings and string arrays still work as before.

Implementation follows the approach from #3823 (comment). The new DependsOn type lives in base/depends_on.go and is shared by both Workflow and Container. Optional deps are resolved early (build time for workflows, compile time for steps), so no runtime/queue changes were needed.

@simonmeyerrr simonmeyerrr requested a review from 6543 April 20, 2026 12:01
@simonmeyerrr simonmeyerrr force-pushed the feat/optional-depends-on branch from e0602da to 2bc5771 Compare April 20, 2026 13:19
@6543 6543 added feature add new functionality engine change how the pipeline engine works labels Apr 20, 2026
@woodpecker-bot
Copy link
Copy Markdown
Contributor

woodpecker-bot commented Apr 20, 2026

Surge PR preview deployment was removed

@6543

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 92.36111% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.46%. Comparing base (b17515b) to head (3bf1aa9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pipeline/frontend/yaml/constraint/depends_on.go 90.72% 7 Missing and 2 partials ⚠️
pipeline/frontend/yaml/linter/linter.go 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6461      +/-   ##
==========================================
+ Coverage   42.15%   42.46%   +0.31%     
==========================================
  Files         433      434       +1     
  Lines       28927    29044     +117     
==========================================
+ Hits        12193    12334     +141     
+ Misses      15630    15610      -20     
+ Partials     1104     1100       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@6543 6543 dismissed their stale review May 1, 2026 13:43

outdated

Comment thread pipeline/frontend/yaml/constraint/depends_on.go
@6543
Copy link
Copy Markdown
Member

6543 commented May 27, 2026

we should make this ready ... i wana have this in for next release

@6543 6543 mentioned this pull request May 27, 2026
1 task
@qwerty287 qwerty287 mentioned this pull request May 27, 2026
16 tasks
@6543 6543 self-assigned this May 27, 2026
Copy link
Copy Markdown
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how it is ... but this is breaking ... for workflow dag!!

before if dep was missing we where ignoring it .... it looks like

need to look into it more

looks like it is as before ...

@6543 6543 changed the title feat: support optional flag in depends_on for workflows and steps Support optional flag in depends_on for workflows and steps May 27, 2026
@6543 6543 requested a review from qwerty287 May 27, 2026 17:45
@6543
Copy link
Copy Markdown
Member

6543 commented May 27, 2026

@qwerty287 I think it is ready ... but you as release manager should decide if we should merge it and release it now or in the next release ...

PS: on release docs pull need update ...

@qwerty287
Copy link
Copy Markdown
Contributor

I'll check it tomorrow.

Comment thread pipeline/frontend/yaml/constraint/depends_on.go Outdated
Comment thread pipeline/frontend/yaml/constraint/depends_on_test.go Outdated
qwerty287 added 2 commits May 28, 2026 09:08
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
@6543 6543 enabled auto-merge (squash) May 28, 2026 07:16
@6543 6543 merged commit 64d7ed8 into woodpecker-ci:main May 28, 2026
7 checks passed
6543 added a commit to 6543-forks/woodpecker that referenced this pull request May 28, 2026
…er-ci#6461)

Extends `depends_on` to accept objects with `name` and `optional` fields, at both workflow and step level. When `optional: true`, the dependency is silently dropped if the referenced workflow/step is not part of the pipeline (e.g. filtered out by `when` conditions). If present, it is enforced as usual.

Co-authored-by: 6543 <6543@obermui.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine change how the pipeline engine works feature add new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skipped workflows are not considered as succeed like documentation suggest it Allow depends_on to be optional

4 participants