Skip to content

Commit

Permalink
Fetch up to 100 check runs in a single poll request
Browse files Browse the repository at this point in the history
* Fetching >100 check runs would require pagination and burn more
rate limit on every poll
  • Loading branch information
dghubble committed Jul 27, 2023
1 parent 58a394e commit f46e880
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { wait } from '../src/wait'
import { expect, test } from '@jest/globals'
import {wait} from '../src/wait'
import {expect, test} from '@jest/globals'

test('throws invalid number', async () => {
const input = parseInt('foo', 10)
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import { Context } from '@actions/github/lib/context'
import { poll } from './poll'
import {Context} from '@actions/github/lib/context'
import {poll} from './poll'

async function run(): Promise<void> {
try {
// read inputs
const token = core.getInput('token', { required: true })
const token = core.getInput('token', {required: true})

// github context
const context = github.context
Expand Down
27 changes: 14 additions & 13 deletions src/poll.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GitHub } from '@actions/github/lib/utils'
import {GitHub} from '@actions/github/lib/utils'
import * as core from '@actions/core'
import { wait } from './wait'
import {wait} from './wait'

export interface Config {
client: InstanceType<typeof GitHub>
Expand Down Expand Up @@ -41,7 +41,8 @@ export async function poll(config: Config): Promise<void> {
const response = await client.rest.checks.listForRef({
owner,
repo,
ref
ref,
per_page: 100
})

core.debug(`Received ${response.data.total_count} total check runs`)
Expand Down Expand Up @@ -117,14 +118,14 @@ interface CheckRun {
name: string
status: string
conclusion:
| (
| 'success'
| 'failure'
| 'neutral'
| 'cancelled'
| 'skipped'
| 'timed_out'
| 'action_required'
)
| null
| (
| 'success'
| 'failure'
| 'neutral'
| 'cancelled'
| 'skipped'
| 'timed_out'
| 'action_required'
)
| null
}

0 comments on commit f46e880

Please sign in to comment.