Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve validation of needs output object #151

Closed
Bertg opened this issue Jun 8, 2022 · 1 comment
Closed

Improve validation of needs output object #151

Bertg opened this issue Jun 8, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Bertg
Copy link

Bertg commented Jun 8, 2022

Given the following workflow file:

name: Simplified CI example

on: [push]

jobs:
  detect_changes:
    name: "🔎 Detect Changes"
    runs-on: ubuntu-latest
    # outputs will always be strings
    outputs:
      graph: ${{ steps.graph_changes.outputs.change }}
    steps:
      - name: "📫 Checkout with history"
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - id: graph_changes
        name: "🔎 Check for graph changes"
        uses: younited/detect-branch-changes-action@v0.1.3
        with:
          pathspec: "graph/"

  build_graph:
    name: "🧱 Graph"
    needs:
      - detect_changes
    runs-on: ubuntu-latest
    steps:
      - name: "🔬 Example test"
        run: echo OK

  test_graph_dumped_correctly:
    name: "🧪 Graph dumped correctly"
    needs:
      - build_graph
    runs-on: ubuntu-latest
    env:
      GEMS_CACHE_DIR: /tmp/bundle
    steps:
      - name: "🦘 Skipping?"
        if: needs.detect_changes.outputs.graph == 'false'
        run: echo Skipped
      - name: "📫 Checkout"
        if: needs.detect_changes.outputs.graph == 'true'
        uses: actions/checkout@v2
      - name: "🔬 Example test"
        if: needs.detect_changes.outputs.graph == 'true'
        run: echo OK

This file passes validation, but has a fairly big bug in it. The job test_graph_dumped_correctly uses needs.detect_changes but it is not defined in the the needs section of that job.
The bug is subtle, as the jobs will be executed in the expected order (due to the build_graph job in between). However the GitHub docs are clear that an explicit needs is required.

Job outputs are available to all downstream jobs that depend on this job.
https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs#overview

It would be great if this check could be added as well.

@rhysd rhysd added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Aug 12, 2022
@rhysd rhysd closed this as completed in d1ffd58 Aug 28, 2022
@rhysd
Copy link
Owner

rhysd commented Aug 28, 2022

This was fixed in v1.6.17.

rhysd added a commit that referenced this issue Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants