Skip to content

Commit

Permalink
Implement startupGracePeriod in wait-list (#821)
Browse files Browse the repository at this point in the history
Resolves #820

There are many changes to apply new option and the semantics in wait-list

Notable changes are listed as follows

* Use TC39 `Temporal` for duration unit, but keep current settings `wait-seconds-before-first-polling` and `min-interval-seconds` for compatibility
* Started to adding reporting unit tests without snapshots, using snapshots is hard to be updated
* Mark the new option `startupGracePeriod` as required and apply for all items in wait-list with small seconds
* Refine complex loggers by adding severity and structured
  • Loading branch information
kachick authored Jun 2, 2024
1 parent b259df7 commit 7941eac
Show file tree
Hide file tree
Showing 25 changed files with 38,742 additions and 1,612 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GH-771 - Wait
name: GH-771 - Event Name
on:
push:
paths:
Expand All @@ -16,6 +16,15 @@ on:
permissions: {}

jobs:
echo:
runs-on: ubuntu-24.04
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
timeout-minutes: 5
steps:
- name: Print note
run: |
echo 'Triggered by ${{ github.event_name }} event'
echo 'See https://github.com/kachick/wait-other-jobs/issues/771 for the detail'
wait:
runs-on: ubuntu-24.04
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
Expand All @@ -30,10 +39,12 @@ jobs:
retry-method: 'equal_intervals'
min-interval-seconds: 5
attempt-limits: 30
skip-same-workflow: 'false'
wait-list: |
[
{
"workflowFile": "GH-771-targets.yml",
"workflowFile": "GH-771-eventname.yml",
"jobName": "echo",
"eventName": "${{ github.event_name }}"
}
]
27 changes: 0 additions & 27 deletions .github/workflows/GH-771-targets.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/GH-820-graceperiod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: GH-820 - Grace Period
on:
push:
branches: [main]
paths:
- '**GH-820**'
- 'action.yml'
- 'dist/**'
pull_request:
paths:
- '**GH-820**'
- 'action.yml'
- 'dist/**'
workflow_dispatch:

# Disable all permissions in workflow global as to setup clean room
# However PRs will have read permissions because this project is on a public repository
permissions: {}

jobs:
quickstarter-success:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- run: echo ':)'
intermediate:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- run: sleep 15
slowstarter-success:
runs-on: ubuntu-24.04
timeout-minutes: 5
needs: [intermediate]
steps:
- run: echo ':)'
slowstarter-fail:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
timeout-minutes: 5
needs: [intermediate]
steps:
- run: |
echo ':<'
false
wait-success:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: ./
with:
retry-method: 'equal_intervals'
wait-seconds-before-first-polling: '0'
min-interval-seconds: '5'
attempt-limits: '100'
wait-list: |
[
{
"workflowFile": "GH-820-graceperiod.yml",
"optional": false,
"jobName": "quickstarter-success"
},
{
"workflowFile": "GH-820-graceperiod.yml",
"optional": false,
"jobName": "slowstarter-success",
"startupGracePeriod": { "seconds": 60 }
}
]
wait-fail:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: ./
with:
retry-method: 'equal_intervals'
wait-seconds-before-first-polling: '0'
min-interval-seconds: '5'
attempt-limits: '100'
wait-list: |
[
{
"workflowFile": "GH-820-graceperiod.yml",
"optional": false,
"jobName": "quickstarter-success"
},
{
"workflowFile": "GH-820-graceperiod.yml",
"optional": false,
"jobName": "slowstarter-fail",
"startupGracePeriod": { "seconds": 60 }
}
]
26 changes: 23 additions & 3 deletions .github/workflows/itself.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ on:
branches: [main]
paths:
- '.github/workflows/itself.yml'
- '.github/workflows/GH-771-echo.yml'
- 'action.yml'
- 'dist/**'
pull_request:
paths:
- '.github/workflows/itself.yml'
- '.github/workflows/GH-771-echo.yml'
- 'action.yml'
- 'dist/**'
schedule:
Expand All @@ -32,8 +30,15 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
# Do NOT specify any options here to make sure zero config may work
# Do NOT specify options except non omittable skip-list to make sure zero config may work
- uses: ./
with:
skip-list: |
[
{
"workflowFile": "GH-820-graceperiod.yml"
}
]
validation_example_basic_errors_allow_failure:
runs-on: ubuntu-24.04
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
Expand Down Expand Up @@ -91,6 +96,12 @@ jobs:
min-interval-seconds: 2
attempt-limits: 2
skip-same-workflow: 'true'
skip-list: |
[
{
"workflowFile": "GH-820-graceperiod.yml"
}
]
equal_intervals:
runs-on: ubuntu-24.04
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
Expand All @@ -105,6 +116,12 @@ jobs:
min-interval-seconds: 10
attempt-limits: 60
skip-same-workflow: 'true'
skip-list: |
[
{
"workflowFile": "GH-820-graceperiod.yml"
}
]
wait-list:
runs-on: ubuntu-24.04
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
Expand Down Expand Up @@ -158,5 +175,8 @@ jobs:
{
"workflowFile": "merge-bot-pr.yml",
"jobName": "dependabot"
},
{
"workflowFile": "GH-820-graceperiod.yml"
}
]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

tmp

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@
}
}
},
"search.exclude": {
"dist/**": true,
"node_modules/**": true,
".direnv/**": true
},
"deno.enable": false
}
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
This file only records notable changes. Not synchronized with all releases and tags.

- main - not yet released
- Nothing
- Add `startupGracePeriod` option in wait-list: [#820](https://github.com/kachick/wait-other-jobs/issues/820)
- v3.2.0
- Add option to specify the event in `wait-list`: [#771](https://github.com/kachick/wait-other-jobs/issues/771)
- Add `eventName` option in wait-list: [#771](https://github.com/kachick/wait-other-jobs/issues/771)
- v3.1.0
- Add option to disable validations for `wait-list` and missing checkRun: [#762](https://github.com/kachick/wait-other-jobs/pull/762)
- Add `optional` option in wait-list: [#762](https://github.com/kachick/wait-other-jobs/pull/762)
- Refine inputs validations and the messages: [#766](https://github.com/kachick/wait-other-jobs/pull/766)
- v3.0.0
- Wait other jobs which defined in same workflow by default: [#754](https://github.com/kachick/wait-other-jobs/issues/754)\
You can change this behavior with new option `skip-same-workflow: 'true'`
- Validate if the checkRun for the `wait-list` specified name is not found: [#760](https://github.com/kachick/wait-other-jobs/issues/760)
- Validate if the checkRun for the wait-list specified name is not found: [#760](https://github.com/kachick/wait-other-jobs/issues/760)
- v2.0.2
- Allow some neutral patterns: [93299c](https://github.com/kachick/wait-other-jobs/commit/93299c2fa22fd463db31668eba54b34b58270696)
- v2.0.0
Expand Down
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ with:
# - If no jobName is specified, all the jobs in the workflow will be targeted.
# - wait-list:
# - If the checkRun for the specified name is not found, this action raise errors by default.
# You can disable this validation with `"optional": true`.
# You can disable this validation with `"optional": true` or use the `startupGracePeriod` that described in following section
# - Wait for all event types by default, you can change with `"eventName": "EVENT_NAME_AS_push"`.
wait-list: |
[
Expand Down Expand Up @@ -117,11 +117,38 @@ See the [docs](docs/examples.md) for further detail.
```
Similar problems should be considered in matrix jobs. See [#761](https://github.com/kachick/wait-other-jobs/issues/761) for further detail

## Limitations
## Startup grace period - Since v3.3.0

Judge whether the checkRun state at the moment.\
When some jobs are triggered late after this action, we need to use the following configurations.

An example of using a `wait-list`.

```yaml
with:
wait-list: |
[
{
"workflowFile": "might_be_triggered_after_0-4_minutes.yml",
"optional": false,
"startupGracePeriod": { "minutes": 5 }
}
]
```

- 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 see actual example yet)
This action starts immediately but ignores the job missing in the first 5 minutes.

- No need to extend `wait-seconds-before-first-polling`
- Disable `optional`, because it is needed to check
- Set enough value for `startupGracePeriod` for this purpose.\
It should be parsible with [Temporal.Duration.from()](https://github.com/tc39/proposal-temporal)\
e.g
- `"PT1M"` # ISO8601 duration format
- `{ "minutes": 3, "seconds": 20 }` # key-value for each unit

If not using wait-list, this pattern should be considered in your `wait-seconds-before-first-polling`.

## Limitations

- 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.
Expand Down
Loading

0 comments on commit 7941eac

Please sign in to comment.