kachick / wait-other-jobs

⏳ Wait other jobs/workflows☕
https://github.com/marketplace/actions/wait-other-jobs
MIT License
9 stars 4 forks source link

[Question]: using this in a PR, workflow runs from push event are also considered #771

Closed chaporgin closed 6 months ago

chaporgin commented 6 months ago

What happened?

Hello! Thank you for the work!

I am having a commit merged into main, and then a PR with it, into release branch. Both push event from pushing into main and pull_request event from opening a PR into release branch trigger same workflow (console.yml).

The desired behavior is that action considers only pull_request event when running in respond to pull_request event.

The observed behavior: it considers both push and pull_request events that triggered workflow. That leads to "if the push related workflow run was not successfull, the action exits". Which is not expected.

Can this be tweaked? I see there are older versions, compared to what I'm using (I'm on 2.0.2). Has this behavior changed already?

Version

v2.0.4

Permissions

[debug]Starting: Set up job

Current runner version: '2.315.0' Operating System Runner Image Runner Image Provisioner GITHUB_TOKEN Permissions Secret source: Actions

[debug]Primary repository: neondatabase/cloud

Prepare workflow directory

[debug]Creating pipeline directory: '/home/runner/work/cloud'

[debug]Creating workspace directory: '/home/runner/work/cloud/cloud'

[debug]Update context data

[debug]Evaluating job-level environment variables

[debug]Evaluating job container

[debug]Evaluating job service containers

[debug]Evaluating job defaults

Prepare all required actions Getting action download info Download action repository 'actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11' (SHA:b4ffde65f46336ab88eb53be808477a3936bae11)

[debug]Copied action archive '/opt/actionarchivecache/actions_checkout/b4ffde65f46336ab88eb53be808477a3936bae11.tar.gz' to '/home/runner/work/_actions/_temp_2893241d-c2be-46e5-aede-12f137636ef1/c44ca64f-d7b7-482b-b100-7fb3fa71336b.tar.gz'

[debug]Unwrap 'actions-checkout-b4ffde6' to '/home/runner/work/_actions/actions/checkout/b4ffde65f46336ab88eb53be808477a3936bae11'

[debug]Archive '/home/runner/work/_actions/_temp_2893241d-c2be-46e5-aede-12f137636ef1/c44ca64f-d7b7-482b-b100-7fb3fa71336b.tar.gz' has been unzipped into '/home/runner/work/_actions/actions/checkout/b4ffde65f46336ab88eb53be808477a3936bae11'.

Download action repository 'kachick/wait-other-jobs@fe30bb3fc06912519e744b0eaa638f17a9953685' (SHA:fe30bb3fc06912519e744b0eaa638f17a9953685)

[debug]Download 'https://api.github.com/repos/kachick/wait-other-jobs/tarball/fe30bb3fc06912519e744b0eaa638f17a9953685' to '/home/runner/work/_actions/_temp_a1ab34e8-22bc-472f-984f-02493c025e68/e63fdce9-1626-4fc2-9ab8-201fa9aa3057.tar.gz'

[debug]Unwrap 'kachick-wait-other-jobs-fe30bb3' to '/home/runner/work/_actions/kachick/wait-other-jobs/fe30bb3fc06912519e744b0eaa638f17a9953685'

[debug]Archive '/home/runner/work/_actions/_temp_a1ab34e8-22bc-472f-984f-02493c025e68/e63fdce9-1626-4fc2-9ab8-201fa9aa3057.tar.gz' has been unzipped into '/home/runner/work/_actions/kachick/wait-other-jobs/fe30bb3fc06912519e744b0eaa638f17a9953685'.

Download action repository 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' (SHA:60a0d83039c74a4aee543508d2ffcb1c3799cdea)

[debug]Download 'https://api.github.com/repos/actions/github-script/tarball/60a0d83039c74a4aee543508d2ffcb1c3799cdea' to '/home/runner/work/_actions/_temp_83a9f031-46ec-4312-afca-5851787ff636/b001bdcd-d4bf-4ee5-89f7-da9e79c0b9c3.tar.gz'

[debug]Unwrap 'actions-github-script-60a0d83' to '/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea'

[debug]Archive '/home/runner/work/_actions/_temp_83a9f031-46ec-4312-afca-5851787ff636/b001bdcd-d4bf-4ee5-89f7-da9e79c0b9c3.tar.gz' has been unzipped into '/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea'.

[debug]action.yml for action: '/home/runner/work/_actions/actions/checkout/b4ffde65f46336ab88eb53be808477a3936bae11/action.yml'.

[debug]action.yml for action: '/home/runner/work/_actions/kachick/wait-other-jobs/fe30bb3fc06912519e744b0eaa638f17a9953685/action.yml'.

[debug]action.yml for action: '/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/action.yml'.

[debug]Set step '__actions_checkout' display name to: 'Checkout'

[debug]Set step '__run' display name to: 'Run sleep 15s'

[debug]Set step '__kachick_wait-other-jobs' display name to: 'Run kachick/wait-other-jobs@fe30bb3fc06912519e744b0eaa638f17a9953685'

[debug]Set step '__actions_github-script' display name to: 'Comment the PR after waiting'

Complete job name: Report CI results

[debug]Collect running processes for tracking orphan processes.

[debug]Finishing: Set up job

Parameters

{ "triggeredCommitSha": "06f80545ba03c327d445f14edbd26999c40a7113", "runId": 8693758715, "repositoryInfo": { "owner": "neondatabase", "repo": "cloud" }, "waitSecondsBeforeFirstPolling": 0, "minIntervalSeconds": 15, "retryMethod": "equal_intervals", "attemptLimits": 1000, "isEarlyExit": false, "isDryRun": false, "waitList": [ { "workflowFile": "forecasting.yml" }, { "workflowFile": "testing.yml" }, { "workflowFile": "toolsapi.yml" }, { "workflowFile": "console.yml" }, { "workflowFile": "controlplane.yml" }, { "workflowFile": "githubworkflows.yml" } ], "skipList": [] }

Relevant log output

console.yml(deploy / Test regression suite in staging after deploy): [suiteStatus: COMPLETED][suiteConclusion: FAILURE][runStatus: COMPLETED][runConclusion: FAILURE][runURL: https://github.com/neondatabase/cloud/actions/runs/8693296944/job/23846035052]
kachick commented 6 months ago

Thanks for raising this issue! As I understand it, you want the following features, correct?

name: This workflow should be triggered last
on:
  pull_request:
jobs:
  at_last:
    runs-on: ubuntu-latest
    steps:
      - uses: kachick/wait-other-jobs@v2.0.2
        with:
          wait-list: |
            [
              {
                "workflowFile": "ci.yml"
              }
            ]
# ci.yml
name: Important jobs
on:
  push: # You want to skip this event in at_last job
  pull_request: # You want to wait this event in at_last job
jobs:
  ci:
    runs-on: ubuntu-latest

Both v2.0.2 and the latest v3.1.0 do not have these options. But in the GitHub GraphQL schema, workflowRun can return the event column. It may be suitable for this use case.

chaporgin commented 6 months ago

Exactly! Any ideas of what interface to extend and how to not break other users? Having it like another field along with workflow file name?

              {
                "workflowFile": "ci.yml"
                "on": "${{${{ github.event_name }}"
              }

?

kachick commented 6 months ago

Well, I think adding it only to the wait-list field is a good first step. Filling the field with template syntax looks smart to me.👍

A concern: if users want to specify multiple event names for a workflow, they now need many definitions for each event/workflow/job. The list will be longer.

kachick commented 6 months ago

I have added the option in #772 and released in v3.2.0 🙏

Tested the behavior as follows

Before

https://github.com/kachick/wait-other-jobs/pull/772/commits/f96e4834588287a5340bf051b23603adcc373d47 https://github.com/kachick/wait-other-jobs/actions/runs/8727607038/job/23945482510#step:3:77

lint.yml(dprint): [suiteStatus: COMPLETED][suiteConclusion: SUCCESS][runStatus: COMPLETED][runConclusion: SUCCESS][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/8727607025/job/23945481089]
  lint.yml(typos): [suiteStatus: COMPLETED][suiteConclusion: SUCCESS][runStatus: COMPLETED][runConclusion: SUCCESS][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/8727607025/job/23945480479]
  merge-bot-pr.yml(dependabot): [suiteStatus: COMPLETED][suiteConclusion: SKIPPED][runStatus: COMPLETED][runConclusion: NEUTRAL][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/8727607051/job/23945482122]
  multiple-event-triggers.yml(should_be_wait_this_only_in_pull_request): [suiteStatus: COMPLETED][suiteConclusion: SUCCESS][runStatus: COMPLETED][runConclusion: SUCCESS][eventName: push][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/8727606819/job/23945479652]
  multiple-event-triggers.yml(should_be_wait_this_only_in_pull_request): [suiteStatus: COMPLETED][suiteConclusion: SUCCESS][runStatus: COMPLETED][runConclusion: SUCCESS][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/872[76](https://github.com/kachick/wait-other-jobs/actions/runs/8727607038/job/23945482510#step:3:78)07031/job/23945480449]

After

https://github.com/kachick/wait-other-jobs/pull/772/commits/b0fdc48d49a649474231297d3d08650d55a26a6d https://github.com/kachick/wait-other-jobs/actions/runs/8727618623/job/23945520913

lint.yml(dprint): [suiteStatus: COMPLETED][suiteConclusion: SUCCESS][runStatus: COMPLETED][runConclusion: SUCCESS][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/8727618613/job/23945519439]
  lint.yml(typos): [suiteStatus: COMPLETED][suiteConclusion: SUCCESS][runStatus: COMPLETED][runConclusion: SUCCESS][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/8727618613/job/23945519809]
  merge-bot-pr.yml(dependabot): [suiteStatus: COMPLETED][suiteConclusion: SKIPPED][runStatus: COMPLETED][runConclusion: NEUTRAL][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/872[76](https://github.com/kachick/wait-other-jobs/actions/runs/8727618623/job/23945520913?pr=772#step:3:78)18615/job/23945520299]
  multiple-event-triggers.yml(should_be_wait_this_only_in_pull_request): [suiteStatus: COMPLETED][suiteConclusion: SUCCESS][runStatus: COMPLETED][runConclusion: SUCCESS][eventName: pull_request][runURL: https://github.com/kachick/wait-other-jobs/actions/runs/8727618616/job/23945519244]
chaporgin commented 6 months ago

Oh, that's speed! Thank you, will try it out!