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

[Bug/Question]: Does not work when jobs are in the same file? #754

Closed
jimduchek opened this issue Apr 12, 2024 · 4 comments · Fixed by #755
Closed

[Bug/Question]: Does not work when jobs are in the same file? #754

jimduchek opened this issue Apr 12, 2024 · 4 comments · Fixed by #755
Assignees
Labels
bug Something isn't working

Comments

@jimduchek
Copy link

What happened?

Stripped down to the following test:

name: Testing Wait Other Jobs

on:
    push:
        branches:
            - main
            - staging
            - development
        paths:
            - ".github/workflows/wait_other_job_test.yml"  
    workflow_dispatch:

permissions:
    contents: read # Since v2
    checks: read
    actions: read

jobs:
    job1:
        runs-on: ubuntu-latest

        steps:
            - name: Test 1
              shell: bash
              run: |
                sleep 60

    job2:
        runs-on: ubuntu-latest

        steps:
            - name: Wait
              uses: kachick/wait-other-jobs@v2

I expect job2 NOT to finish first. But it does, the very first poll passes, despite job1 not being done. If job1 and job2 are in separate yml files, it works as expected. Behavior is no different if specifying @v1, though THAT does have the interesting log output:

Get own job_id
  {
    "ownJobIDs": [
      23740674348,
      23740674474
    ]
  }

It seems perhaps it thinks other jobs in the same file are also itself (and therefore shouldn't wait)?

It's actually probably best for me to split my jobs into separate files anyway, but if this is the case (not sure if GH maybe changed something very recently), several of the examples ought not to work either.

Version

v2.0.4

Permissions

GITHUB_TOKEN Permissions
Actions: read
Checks: read
Contents: read
Metadata: read

Parameters

{
    "triggeredCommitSha": "3d0694542d6540fcb92347237727284e13fcafbb",
    "runId": 8657670048,
    "repositoryInfo": {
      "owner": "XXX",
      "repo": "XXX"
    },
    "waitSecondsBeforeFirstPolling": 10,
    "minIntervalSeconds": [15],
    "retryMethod": "equal_intervals",
    "attemptLimits": 1000,
    "isEarlyExit": true,
    "isDryRun": false,
    "waitList": [],
    "skipList": []
  }

Relevant log output

Not really useful -- it waits 10 seconds, polls, decides to continue:

Wait about 10 seconds before first polling.
Polling 1: 2024-04-12T06:09:52.142Z
  all jobs passed
@jimduchek jimduchek added the bug Something isn't working label Apr 12, 2024
@kachick
Copy link
Owner

kachick commented Apr 12, 2024

Thanks for this report!

It seems perhaps it thinks other jobs in the same file are also itself (and therefore shouldn't wait)?

I didn't expect the behavior, I'll check!

kachick added a commit that referenced this issue Apr 12, 2024
…e workflow (#755)

This is a bug, but I bumped the major version for the behavior changes.

Add a new option `skip-same-workflow` to keep the behavior as v2 era.
A workflow that has multiple `wait-other-jobs` patterns appears frequently in my use.
And the `skip-list` can't track file name changes, so adding an option will fit here.

Other changes are chore tasks, refactored, and added a minimum changelog.

Fixes #754
@kachick
Copy link
Owner

kachick commented Apr 12, 2024

Fixed in #755 and released with v3.0.0 🙏

@jimduchek
Copy link
Author

Excellent, this fixes that, but introduces two new issues that don't show in v2... isn't that the way it always goes :D

  1. If "wait-list" is used, and that job doesn't run at all (in my case, the job I'm waiting for doesn't always need to run), we get: throw new Error("No targets found except wait-other-jobs itself"); I think perhaps the proper fix here, if possible, might be to add a third parameter to wait-list to indicate the job is optional, or (much easier) just an overall "jobs-might-not-exist" parameter that skips that Throw? Because if it's not optional, this new behavior is actually Not A Bug But A Feature, as it catches misspelled job names and such.
  2. If "wait-list" is NOT used, and the job is a matrix, it deadlocks. Adding it's own workflowFile and jobName to skip-list does NOT fix it. So I guess it's somehow seeing matrix jobs as a 'different job'.

@kachick
Copy link
Owner

kachick commented Apr 12, 2024

Thanks for your testing and reports! I have extracted the problems to #760 and #761.

I don't have enough time in this weekend, but should be resolved in next versions 🙏

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
Archived in project
2 participants