feat: support pagination in build bot PR commit reading

Todo: cherry-pick this to master
Build-bot: skip build:developer
This commit is contained in:
Marc Durdin 2025-08-28 15:18:16 +02:00
parent a194e02bfd
commit b2e731e2b5
4 changed files with 491 additions and 1 deletions

View file

@ -0,0 +1,32 @@
/*
* Keyman is copyright (C) SIL Global. MIT License.
*
* Created by mcdurdin on 2025-08-28
*
* Paginate large commit lists for PRs so we get all build commands
*/
import { Octokit } from "octokit";
if(process.argv.length < 4) {
console.log(`Usage: node ${process.argv[1]} <GITHUB_TOKEN> <PULL_NUMBER>`);
process.exit(1);
}
const GITHUB_TOKEN = process.argv[2];
const pull_number = process.argv[3];
const octokit = new Octokit({
auth: GITHUB_TOKEN
});
const data = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", {
owner: "keymanapp",
repo: "keyman",
pull_number,
per_page: 100,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
});
process.stdout.write(JSON.stringify(data));

View file

@ -0,0 +1,434 @@
{
"name": "github-integration",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "github-integration",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"octokit": "^5.0.3"
}
},
"node_modules/@octokit/app": {
"version": "16.1.0",
"resolved": "https://registry.npmjs.org/@octokit/app/-/app-16.1.0.tgz",
"integrity": "sha512-OdKHnm0CYLk8Setr47CATT4YnRTvWkpTYvE+B/l2B0mjszlfOIit3wqPHVslD2jfc1bD4UbO7Mzh6gjCuMZKsA==",
"license": "MIT",
"dependencies": {
"@octokit/auth-app": "^8.1.0",
"@octokit/auth-unauthenticated": "^7.0.1",
"@octokit/core": "^7.0.2",
"@octokit/oauth-app": "^8.0.1",
"@octokit/plugin-paginate-rest": "^13.0.0",
"@octokit/types": "^14.0.0",
"@octokit/webhooks": "^14.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/auth-app": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-8.1.0.tgz",
"integrity": "sha512-6bWhyvLXqCSfHiqlwzn9pScLZ+Qnvh/681GR/UEEPCMIVwfpRDBw0cCzy3/t2Dq8B7W2X/8pBgmw6MOiyE0DXQ==",
"license": "MIT",
"dependencies": {
"@octokit/auth-oauth-app": "^9.0.1",
"@octokit/auth-oauth-user": "^6.0.0",
"@octokit/request": "^10.0.2",
"@octokit/request-error": "^7.0.0",
"@octokit/types": "^14.0.0",
"toad-cache": "^3.7.0",
"universal-github-app-jwt": "^2.2.0",
"universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/auth-oauth-app": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-9.0.1.tgz",
"integrity": "sha512-TthWzYxuHKLAbmxdFZwFlmwVyvynpyPmjwc+2/cI3cvbT7mHtsAW9b1LvQaNnAuWL+pFnqtxdmrU8QpF633i1g==",
"license": "MIT",
"dependencies": {
"@octokit/auth-oauth-device": "^8.0.1",
"@octokit/auth-oauth-user": "^6.0.0",
"@octokit/request": "^10.0.2",
"@octokit/types": "^14.0.0",
"universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/auth-oauth-device": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-8.0.1.tgz",
"integrity": "sha512-TOqId/+am5yk9zor0RGibmlqn4V0h8vzjxlw/wYr3qzkQxl8aBPur384D1EyHtqvfz0syeXji4OUvKkHvxk/Gw==",
"license": "MIT",
"dependencies": {
"@octokit/oauth-methods": "^6.0.0",
"@octokit/request": "^10.0.2",
"@octokit/types": "^14.0.0",
"universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/auth-oauth-user": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-6.0.0.tgz",
"integrity": "sha512-GV9IW134PHsLhtUad21WIeP9mlJ+QNpFd6V9vuPWmaiN25HEJeEQUcS4y5oRuqCm9iWDLtfIs+9K8uczBXKr6A==",
"license": "MIT",
"dependencies": {
"@octokit/auth-oauth-device": "^8.0.1",
"@octokit/oauth-methods": "^6.0.0",
"@octokit/request": "^10.0.2",
"@octokit/types": "^14.0.0",
"universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/auth-token": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz",
"integrity": "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==",
"license": "MIT",
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/auth-unauthenticated": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/@octokit/auth-unauthenticated/-/auth-unauthenticated-7.0.1.tgz",
"integrity": "sha512-qVq1vdjLLZdE8kH2vDycNNjuJRCD1q2oet1nA/GXWaYlpDxlR7rdVhX/K/oszXslXiQIiqrQf+rdhDlA99JdTQ==",
"license": "MIT",
"dependencies": {
"@octokit/request-error": "^7.0.0",
"@octokit/types": "^14.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/core": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.3.tgz",
"integrity": "sha512-oNXsh2ywth5aowwIa7RKtawnkdH6LgU1ztfP9AIUCQCvzysB+WeU8o2kyyosDPwBZutPpjZDKPQGIzzrfTWweQ==",
"license": "MIT",
"dependencies": {
"@octokit/auth-token": "^6.0.0",
"@octokit/graphql": "^9.0.1",
"@octokit/request": "^10.0.2",
"@octokit/request-error": "^7.0.0",
"@octokit/types": "^14.0.0",
"before-after-hook": "^4.0.0",
"universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/endpoint": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-11.0.0.tgz",
"integrity": "sha512-hoYicJZaqISMAI3JfaDr1qMNi48OctWuOih1m80bkYow/ayPw6Jj52tqWJ6GEoFTk1gBqfanSoI1iY99Z5+ekQ==",
"license": "MIT",
"dependencies": {
"@octokit/types": "^14.0.0",
"universal-user-agent": "^7.0.2"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/graphql": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-9.0.1.tgz",
"integrity": "sha512-j1nQNU1ZxNFx2ZtKmL4sMrs4egy5h65OMDmSbVyuCzjOcwsHq6EaYjOTGXPQxgfiN8dJ4CriYHk6zF050WEULg==",
"license": "MIT",
"dependencies": {
"@octokit/request": "^10.0.2",
"@octokit/types": "^14.0.0",
"universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/oauth-app": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/@octokit/oauth-app/-/oauth-app-8.0.1.tgz",
"integrity": "sha512-QnhMYEQpnYbEPn9cae+wXL2LuPMFglmfeuDJXXsyxIXdoORwkLK8y0cHhd/5du9MbO/zdG/BXixzB7EEwU63eQ==",
"license": "MIT",
"dependencies": {
"@octokit/auth-oauth-app": "^9.0.1",
"@octokit/auth-oauth-user": "^6.0.0",
"@octokit/auth-unauthenticated": "^7.0.1",
"@octokit/core": "^7.0.2",
"@octokit/oauth-authorization-url": "^8.0.0",
"@octokit/oauth-methods": "^6.0.0",
"@types/aws-lambda": "^8.10.83",
"universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/oauth-authorization-url": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-8.0.0.tgz",
"integrity": "sha512-7QoLPRh/ssEA/HuHBHdVdSgF8xNLz/Bc5m9fZkArJE5bb6NmVkDm3anKxXPmN1zh6b5WKZPRr3697xKT/yM3qQ==",
"license": "MIT",
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/oauth-methods": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-6.0.0.tgz",
"integrity": "sha512-Q8nFIagNLIZgM2odAraelMcDssapc+lF+y3OlcIPxyAU+knefO8KmozGqfnma1xegRDP4z5M73ABsamn72bOcA==",
"license": "MIT",
"dependencies": {
"@octokit/oauth-authorization-url": "^8.0.0",
"@octokit/request": "^10.0.2",
"@octokit/request-error": "^7.0.0",
"@octokit/types": "^14.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/openapi-types": {
"version": "25.1.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-25.1.0.tgz",
"integrity": "sha512-idsIggNXUKkk0+BExUn1dQ92sfysJrje03Q0bv0e+KPLrvyqZF8MnBpFz8UNfYDwB3Ie7Z0TByjWfzxt7vseaA==",
"license": "MIT"
},
"node_modules/@octokit/openapi-webhooks-types": {
"version": "12.0.3",
"resolved": "https://registry.npmjs.org/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-12.0.3.tgz",
"integrity": "sha512-90MF5LVHjBedwoHyJsgmaFhEN1uzXyBDRLEBe7jlTYx/fEhPAk3P3DAJsfZwC54m8hAIryosJOL+UuZHB3K3yA==",
"license": "MIT"
},
"node_modules/@octokit/plugin-paginate-graphql": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-6.0.0.tgz",
"integrity": "sha512-crfpnIoFiBtRkvPqOyLOsw12XsveYuY2ieP6uYDosoUegBJpSVxGwut9sxUgFFcll3VTOTqpUf8yGd8x1OmAkQ==",
"license": "MIT",
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"@octokit/core": ">=6"
}
},
"node_modules/@octokit/plugin-paginate-rest": {
"version": "13.1.1",
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-13.1.1.tgz",
"integrity": "sha512-q9iQGlZlxAVNRN2jDNskJW/Cafy7/XE52wjZ5TTvyhyOD904Cvx//DNyoO3J/MXJ0ve3rPoNWKEg5iZrisQSuw==",
"license": "MIT",
"dependencies": {
"@octokit/types": "^14.1.0"
},
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"@octokit/core": ">=6"
}
},
"node_modules/@octokit/plugin-rest-endpoint-methods": {
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-16.0.0.tgz",
"integrity": "sha512-kJVUQk6/dx/gRNLWUnAWKFs1kVPn5O5CYZyssyEoNYaFedqZxsfYs7DwI3d67hGz4qOwaJ1dpm07hOAD1BXx6g==",
"license": "MIT",
"dependencies": {
"@octokit/types": "^14.1.0"
},
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"@octokit/core": ">=6"
}
},
"node_modules/@octokit/plugin-retry": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-8.0.1.tgz",
"integrity": "sha512-KUoYR77BjF5O3zcwDQHRRZsUvJwepobeqiSSdCJ8lWt27FZExzb0GgVxrhhfuyF6z2B2zpO0hN5pteni1sqWiw==",
"license": "MIT",
"dependencies": {
"@octokit/request-error": "^7.0.0",
"@octokit/types": "^14.0.0",
"bottleneck": "^2.15.3"
},
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"@octokit/core": ">=7"
}
},
"node_modules/@octokit/plugin-throttling": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-11.0.1.tgz",
"integrity": "sha512-S+EVhy52D/272L7up58dr3FNSMXWuNZolkL4zMJBNIfIxyZuUcczsQAU4b5w6dewJXnKYVgSHSV5wxitMSW1kw==",
"license": "MIT",
"dependencies": {
"@octokit/types": "^14.0.0",
"bottleneck": "^2.15.3"
},
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"@octokit/core": "^7.0.0"
}
},
"node_modules/@octokit/request": {
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.3.tgz",
"integrity": "sha512-V6jhKokg35vk098iBqp2FBKunk3kMTXlmq+PtbV9Gl3TfskWlebSofU9uunVKhUN7xl+0+i5vt0TGTG8/p/7HA==",
"license": "MIT",
"dependencies": {
"@octokit/endpoint": "^11.0.0",
"@octokit/request-error": "^7.0.0",
"@octokit/types": "^14.0.0",
"fast-content-type-parse": "^3.0.0",
"universal-user-agent": "^7.0.2"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/request-error": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-7.0.0.tgz",
"integrity": "sha512-KRA7VTGdVyJlh0cP5Tf94hTiYVVqmt2f3I6mnimmaVz4UG3gQV/k4mDJlJv3X67iX6rmN7gSHCF8ssqeMnmhZg==",
"license": "MIT",
"dependencies": {
"@octokit/types": "^14.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/types": {
"version": "14.1.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-14.1.0.tgz",
"integrity": "sha512-1y6DgTy8Jomcpu33N+p5w58l6xyt55Ar2I91RPiIA0xCJBXyUAhXCcmZaDWSANiha7R9a6qJJ2CRomGPZ6f46g==",
"license": "MIT",
"dependencies": {
"@octokit/openapi-types": "^25.1.0"
}
},
"node_modules/@octokit/webhooks": {
"version": "14.1.3",
"resolved": "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-14.1.3.tgz",
"integrity": "sha512-gcK4FNaROM9NjA0mvyfXl0KPusk7a1BeA8ITlYEZVQCXF5gcETTd4yhAU0Kjzd8mXwYHppzJBWgdBVpIR9wUcQ==",
"license": "MIT",
"dependencies": {
"@octokit/openapi-webhooks-types": "12.0.3",
"@octokit/request-error": "^7.0.0",
"@octokit/webhooks-methods": "^6.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/@octokit/webhooks-methods": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-6.0.0.tgz",
"integrity": "sha512-MFlzzoDJVw/GcbfzVC1RLR36QqkTLUf79vLVO3D+xn7r0QgxnFoLZgtrzxiQErAjFUOdH6fas2KeQJ1yr/qaXQ==",
"license": "MIT",
"engines": {
"node": ">= 20"
}
},
"node_modules/@types/aws-lambda": {
"version": "8.10.152",
"resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.152.tgz",
"integrity": "sha512-soT/c2gYBnT5ygwiHPmd9a1bftj462NWVk2tKCc1PYHSIacB2UwbTS2zYG4jzag1mRDuzg/OjtxQjQ2NKRB6Rw==",
"license": "MIT"
},
"node_modules/before-after-hook": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz",
"integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==",
"license": "Apache-2.0"
},
"node_modules/bottleneck": {
"version": "2.19.5",
"resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz",
"integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==",
"license": "MIT"
},
"node_modules/fast-content-type-parse": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-3.0.0.tgz",
"integrity": "sha512-ZvLdcY8P+N8mGQJahJV5G4U88CSvT1rP8ApL6uETe88MBXrBHAkZlSEySdUlyztF7ccb+Znos3TFqaepHxdhBg==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "MIT"
},
"node_modules/octokit": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/octokit/-/octokit-5.0.3.tgz",
"integrity": "sha512-+bwYsAIRmYv30NTmBysPIlgH23ekVDriB07oRxlPIAH5PI0yTMSxg5i5Xy0OetcnZw+nk/caD4szD7a9YZ3QyQ==",
"license": "MIT",
"dependencies": {
"@octokit/app": "^16.0.1",
"@octokit/core": "^7.0.2",
"@octokit/oauth-app": "^8.0.1",
"@octokit/plugin-paginate-graphql": "^6.0.0",
"@octokit/plugin-paginate-rest": "^13.0.0",
"@octokit/plugin-rest-endpoint-methods": "^16.0.0",
"@octokit/plugin-retry": "^8.0.1",
"@octokit/plugin-throttling": "^11.0.1",
"@octokit/request-error": "^7.0.0",
"@octokit/types": "^14.0.0",
"@octokit/webhooks": "^14.0.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/toad-cache": {
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.7.0.tgz",
"integrity": "sha512-/m8M+2BJUpoJdgAHoG+baCwBT+tf2VraSfkBgl0Y00qIWt41DJ8R5B8nsEw0I58YwF5IZH6z24/2TobDKnqSWw==",
"license": "MIT",
"engines": {
"node": ">=12"
}
},
"node_modules/universal-github-app-jwt": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-2.2.2.tgz",
"integrity": "sha512-dcmbeSrOdTnsjGjUfAlqNDJrhxXizjAz94ija9Qw8YkZ1uu0d+GoZzyH+Jb9tIIqvGsadUfwg+22k5aDqqwzbw==",
"license": "MIT"
},
"node_modules/universal-user-agent": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz",
"integrity": "sha512-TmnEAEAsBJVZM/AADELsK76llnwcf9vMKuPz8JflO1frO8Lchitr0fNaN9d+Ap0BjKtqWqd/J17qeDnXh8CL2A==",
"license": "ISC"
}
}
}

View file

@ -0,0 +1,15 @@
{
"name": "github-integration",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"description": "",
"private": true,
"dependencies": {
"octokit": "^5.0.3"
}
}

View file

@ -240,7 +240,16 @@ find_platform_changes
if [ "$prremote" == "origin" ]; then
# We only accept Build-bot commands on trusted local origin PRs
prcommits=`curl -s -H "User-Agent: @keymanapp" -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/keymanapp/keyman/pulls/$PRNUM/commits`
cd "${KEYMAN_ROOT}/resources/build/ci/github"
npm ci
if builder_is_windows; then
# See https://stackoverflow.com/questions/45890339/stdout-is-not-a-tty-using-bash-for-node-tape-tap-spec
NODE_WRAPPER=node.exe
else
NODE_WRAPPER=node
fi
# Note: we may move all of this into javascript at some point!
prcommits=$(${NODE_WRAPPER} api-pull-commits.mjs $GITHUB_TOKEN $PRNUM)
test_bot_check_pr_body "$PRNUM" "$prinfo"
build_bot_check_messages $PRNUM "$prinfo" "$prcommits"
fi