medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
440 stars 211 forks source link

Changelog-generator script fails when there are too many org open projects #7012

Open dianabarsan opened 3 years ago

dianabarsan commented 3 years ago

Describe the bug Our changelog-generator script fails with an error when there are too many open organization projects.

To Reproduce

  1. Checkout latest master. Go to script and npm ci
  2. Go to changelog-generator. Open the file and check the usage comment (and create your token.json file that contains a valid token).
  3. Run the script as noted, and set 3.10.3 as the project.
  4. The script fails with:
    HttpError: {"message":"Projects are disabled for this repository","documentation_url":"https://docs.github.com/v3/projects"}
    at /home/diana/projects/medic/scripts/node_modules/@octokit/rest/lib/request/request.js:56:19
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
    code: 410,
    status: undefined,
    ...<TRUNCATED>

Expected behavior The script should run successfully regardless of the number of open projects.

Additional context The script fails because, apparently, the default page size of the projects API is 30, while the project in question is 31st - bad luck - and we don't implement paginated project navigation - which the GitHub API provides.

The error is caused by the fallback to check repository projects, which is checking medic - an archived repo - instead of cht-core. The script wouldn't work even if the repo was correct, though.

dianabarsan commented 3 years ago

According to the GitHub API docs, the projects endpoint max page size is 100. The shortest fix (which is also what I used locally to generate 3.10.3 release notes) was to add a param per_page: 100 here: https://github.com/medic/cht-core/blob/master/scripts/changelog-generator/index.js#L41

garethbowen commented 3 years ago

Let's do the cheap and nasty fix for now. I hope we never go over 100 open projects...