Skip to content

Commit

Permalink
fix pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen1 authored Oct 24, 2024
2 parents 1cc4802 + e3794d2 commit 0064fa7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set Node.js 16.x
uses: actions/setup-node@v3.2.0
- name: Set Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x

- name: Install dependencies
run: npm ci
Expand All @@ -46,7 +46,7 @@ jobs:
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
npm install
- run: |
npm run all
# - run: |
# if [ "$(( RANDOM % 2 ))" -ne 0 ]; then
# echo "uh oh!!!" && exit 1
# fi
# - run: |
# if [ "$(( RANDOM % 2 ))" -ne 0 ]; then
# echo "uh oh!!!" && exit 1
# fi
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./
id: wait-for-green
with:
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ GitHub Action that waits for commit statuses and checks to complete. This is use

```yaml
name: Merge Gate
on:
on:
pull_request: {}
jobs:
wait-for-green:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jchen1/wait-for-green@v1.0.7
- uses: actions/checkout@v4
- uses: jchen1/wait-for-green@v2
id: wait-for-green
with:
token: '${{ secrets.GITHUB_TOKEN }}'
Expand All @@ -22,7 +22,6 @@ jobs:
- name: Fail if checks have failed
if: steps.wait-for-green.outputs.success != 'true'
run: echo "Status checks failed with status ${{ steps.wait-for-green.outputs.success }}!" && exit 1

```
## Options
Expand Down
9 changes: 5 additions & 4 deletions 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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wait-for-green",
"version": "1.0.9",
"version": "2.0.0",
"private": true,
"description": "GitHub Action to wait for commit statuses and checks to become green",
"main": "lib/main.js",
Expand Down
18 changes: 7 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,10 @@ async function checkChecks(
ignored: string
): Promise<Status> {
const checks = await octokit.paginate(octokit.rest.checks.listForRef, config);
const statusByName: Record<
string,
[number, typeof checks.check_runs[number], Status]
> = {};
const statusByName: Record<string, [number, typeof checks[number], Status]> =
{};

checks.check_runs.forEach(checkStatus => {
checks.forEach(checkStatus => {
if (shouldIgnoreCheck(ignored, checkStatus.name)) {
return;
}
Expand Down Expand Up @@ -228,11 +226,8 @@ async function checkStatuses(
config: Config,
ignored: string
): Promise<Status> {
const statuses = await octokit.paginate(
octokit.rest.repos.getCombinedStatusForRef,
config
);
return combinedStatusToStatus(statuses, ignored);
const statuses = await octokit.rest.repos.getCombinedStatusForRef(config);
return combinedStatusToStatus(statuses.data, ignored);
}

async function run(): Promise<void> {
Expand Down Expand Up @@ -314,7 +309,8 @@ async function run(): Promise<void> {
core.setOutput('success', false);
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
core.setFailed(error);
core.error(error.stack || '');
}
}
}
Expand Down

0 comments on commit 0064fa7

Please sign in to comment.