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

Implement list-based waiting using GraphQL APIs #574

Merged
merged 41 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ed4bd08
`npm install @octokit/graphql @octokit/graphql-schema`
kachick Aug 29, 2023
45fec25
Attempt to get GraphQL result with octokit
kachick Aug 30, 2023
848b215
Maybe this;
kachick Aug 30, 2023
8d1ba3e
Merge branch 'main' into specify-targets-with-octokit-graphql-schema
kachick Oct 2, 2023
b1010f6
`npm upgrade @octokit/graphql @octokit/graphql-schema`
kachick Oct 2, 2023
0b668ac
`npm uninstall @octokit/graphql @octokit/graphql-schema && npm instal…
kachick Oct 2, 2023
bf1792b
WIP
kachick Oct 2, 2023
5f4b10f
WIP - Custom response
kachick Oct 2, 2023
7f3f343
WIP - Fix conflict path
kachick Oct 2, 2023
fa60e99
WIP - Set different error mesasges
kachick Oct 2, 2023
8fc4cb8
Just skip empty results
kachick Oct 2, 2023
ddfe9d3
WIP - Fix to access nodes
kachick Oct 2, 2023
6969876
WIP - debugger
kachick Oct 2, 2023
cb9178f
WIP - map doesnot stringify
kachick Oct 2, 2023
6bbfe15
WIP - Replace logics with GraphQL
kachick Oct 2, 2023
03244fe
WIP - Add checkSuite layer logging for debug
kachick Oct 2, 2023
8d22e2e
WIP - Log detail
kachick Oct 2, 2023
43c4506
Simple colorize
kachick Oct 2, 2023
9f8a286
Reduce characters for logger
kachick Oct 2, 2023
391a2a7
Remove temporal code
kachick Oct 2, 2023
252ec56
Simplify with skipping edge layer
kachick Oct 2, 2023
ab91f1a
Experimental - Directly filter run id since GraphQL
kachick Oct 2, 2023
c724dd7
Flatten import
kachick Oct 2, 2023
4919cb3
`npm uninstall @octokit/graphql @octokit/types && makers setup && mak…
kachick Oct 2, 2023
9e0a8fb
Add note
kachick Oct 2, 2023
c8c79cb
WIP - Add description about new options
kachick Oct 2, 2023
14c918d
Clarify current limitation
kachick Oct 2, 2023
6c33b99
Update related actions in example
kachick Oct 2, 2023
bdb4b75
Implement wait-list and skip-list
kachick Oct 2, 2023
89eaeb3
Add E2E tests for new options
kachick Oct 2, 2023
d248fc0
Fix a typo
kachick Oct 2, 2023
f8a5212
Accept a e-mail related security problem from zod
kachick Oct 2, 2023
6a91581
Fix list filter
kachick Oct 2, 2023
b07237c
Hard for human
kachick Oct 2, 2023
f3e75e3
:<
kachick Oct 2, 2023
70aa3a7
Implement all jobName in workflow pattern
kachick Oct 2, 2023
1c5ad11
Refine E2E test
kachick Oct 2, 2023
7799731
JSON is strict
kachick Oct 2, 2023
9ecb78d
Adjust for actual behaviors
kachick Oct 2, 2023
69122fe
Implement paging for toplevel suites layer
kachick Oct 2, 2023
1270a2f
Clarify actual dependency `@octokit/core` as official doc
kachick Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ jobs:
# https://spdx.org/licenses/
allow-licenses: MIT, BSD-3-Clause, BSD-2-Clause, 0BSD, Unlicense, ISC, Apache-2.0, CC-BY-4.0
allow-dependencies-licenses: pkg:githubactions/DeterminateSystems/nix-installer-action@4
# https://github.com/colinhacks/zod/pull/2824 - Email regex is not related to this repo
allow-ghsas: GHSA-m95q-7qp3-xv42
42 changes: 42 additions & 0 deletions .github/workflows/itself.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,45 @@ jobs:
retry-method: 'equal_intervals'
min-interval-seconds: 10
attempt-limits: 60
wait-list:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: ./
with:
retry-method: 'equal_intervals'
min-interval-seconds: 5
attempt-limits: 30
wait-list: |
[
{
"workflowFile": "lint.yml"
},
{
"workflowFile": "merge-bot-pr.yml",
"jobName": "dependabot"
}
]
skip-list:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: ./
with:
retry-method: 'equal_intervals'
min-interval-seconds: 5
attempt-limits: 30
skip-list: |
[
{
"workflowFile": "ci.yml"
},
{
"workflowFile": "merge-bot-pr.yml",
"jobName": "dependabot"
}
]
43 changes: 34 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![CI](https://github.com/kachick/wait-other-jobs/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/kachick/wait-other-jobs/actions/workflows/ci.yml?query=event%3Apush++)
[![Itself](https://github.com/kachick/wait-other-jobs/actions/workflows/itself.yml/badge.svg?branch=main)](https://github.com/kachick/wait-other-jobs/actions/workflows/itself.yml?query=event%3Apush++)

This README describes development version as main branch, refer [v1 README](https://github.com/kachick/wait-other-jobs/blob/v1/README.md) for released versions.

## Overview

This action waits all GitHub Action jobs even if they are running in other workflows.\
Expand Down Expand Up @@ -33,19 +35,37 @@ jobs:
with-waiting:
runs-on: ubuntu-latest
steps:
- name: Wait for other jobs to pass or fail
uses: kachick/wait-other-jobs@v1.3.0
- uses: kachick/wait-other-jobs@v2.0.0
timeout-minutes: 15
```

You can change the token, status polling interval and turns early-exit as below.
You can change the token, polling interval, allow/deny list and turns early-exit as below.

```yaml
with:
github-token: "${{ secrets.YOUR_PAT }}"
min-interval-seconds: '300' # default '30'
retry-method: 'equal_intervals' # default 'exponential_backoff'
early-exit: 'false' # default 'true'
# lists should be given with JSON formatted array, do not specify both wait-list and skip-list
# Each items should have "workflowFile" field and they can optinaly have "jobName" field
# If no jobName is specified, all of jobs in the workflow will be targeted
wait-list: |
[
{
"workflowFile": "ci.yml",
"jobName": "test"
},
{
"workflowFile": "release.yml"
}
]
skip-list: |
[
{
"workflowFile": "pages.yml",
}
]
```

Full list of the changeable parameters
Expand All @@ -57,7 +77,9 @@ Full list of the changeable parameters
| `retry-method` | How to wait for next polling | `string` | `false` | `exponential_backoff` | `exponential_backoff`, `equal_intervals` |
| `early-exit` | Stop rest pollings if faced at least 1 bad condition | `bool` | `false` | `true` | |
| `attempt-limits` | Stop rest pollings after this attempts even if other jobs are not yet completed | `number` | `false` | `1000` | |
| `dry-run` | Avoid http requests for tests | `bool` | `false` | `false` | |
| `wait-list` | This action will not wait for items other than this list | `string` | `false` | `[]` | |
| `skip-list` | This action will not wait for items on this list | `string` | `false` | `[]` | |
| `dry-run` | Avoid requests for tests | `bool` | `false` | `false` | |

Below is a typical usecase. Assume test jobs defined in another workflow.

Expand All @@ -78,11 +100,11 @@ jobs:
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.5.1
- uses: actions/checkout@v3
uses: dependabot/fetch-metadata@v1.6.0
- uses: actions/checkout@v4
- name: Wait for other jobs to pass or fail
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
uses: kachick/wait-other-jobs@v1.3.0
uses: kachick/wait-other-jobs@v2.0.0
timeout-minutes: 10
- name: Approve and merge
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
Expand All @@ -95,9 +117,9 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.actor == 'renovate[bot]' }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Wait for other jobs to pass or fail
uses: kachick/wait-other-jobs@v1.3.0
uses: kachick/wait-other-jobs@v2.0.0
timeout-minutes: 10
- name: Approve and merge
run: gh pr review --approve "$PR_URL" && gh pr merge --auto --squash "$PR_URL"
Expand All @@ -111,6 +133,9 @@ jobs:
Judge OK or Bad with the checkRun state at the moment.\
When some jobs will be triggered after this action with `needs: [distant-first]`, it might be unaccurate. (I didn't faced yet)

If any workflow starts many jobs as 100+, this action does not support it.\
Because of nested paging in GraphQL makes complex. See [related docs](https://github.com/octokit/plugin-paginate-graphql.js/blob/a6b12e867466b0c583b002acd1cb1ed90b11841f/README.md#L184-L218) for further detail.

## GITHUB_TOKEN vs PAT

This action just requires following GITHUB_TOKEN permissions. Needless annoying setup and needless unsecure around PAT.
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ inputs:
description: 'Stop rest pollings after this limits even if other jobs are not yet completed'
required: false
default: '1000' # Enough large
wait-list:
description: 'This action will not wait for items other than this list'
required: false
default: '[]'
skip-list:
description: 'This action will not wait for items on this list'
required: false
default: '[]'
dry-run:
description: 'Avoid http requests for tests'
required: false
Expand Down