Skip to content

Commit

Permalink
Merge pull request #1846 from ndunnett/master
Browse files Browse the repository at this point in the history
Fix external link parsing and implement request retrying
  • Loading branch information
Bogdanp committed May 23, 2024
2 parents dd850da + 8934fd0 commit d89abc7
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 87 deletions.
10 changes: 2 additions & 8 deletions .github/actions/update-badge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,8 @@ function parseGithubRepos (lines) {
}

function otherDomain (line) {
return (
!(
line.indexOf('[') < line.indexOf('/') &&
line.indexOf(']') > line.indexOf('/')
) ||
line.indexOf('gitlab.com') !== -1 ||
line.indexOf('gist.github.com') !== -1
)
const match = line.match(/\[[^\[\]\s]+\]\((?<link>[^\(\)\s]+)\)/)
return match !== null && !match.groups.link.startsWith('https://github.com/')
}

function generateLine (repo) {
Expand Down
39 changes: 27 additions & 12 deletions .github/actions/update-badge/updateRepos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ const core = require('@actions/core')
const { setTimeout: sleep } = require('timers/promises')

// limit size of each request to avoid getting timed out
const chunkSize = 250
const chunkSize = 200

// limit request rate to one chunk per requestWaitTime (seconds) to avoid exceeding secondary rate limits
// https://docs.github.com/en/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api#secondary-rate-limits
const requestWaitTime = 20
let lastRequestTime = 0

// retry the request if it fails, throw if request fails requestRetries times
// wait requestRetryTime (seconds) before retrying the first time, doubling time with each retry
const requestRetries = 5
const requestRetryTime = 30

module.exports = async function updateRepos (octokit, repos) {
let responses = []

Expand Down Expand Up @@ -45,22 +50,32 @@ async function queryRepos (octokit, repos) {
}

lastRequestTime = Date.now()
let nextRetryTime = requestRetryTime

for (let i = 1; ; i++) {
try {
return await octokit.graphql(query)
} catch (error) {
if (error.errors !== undefined) {
const softFail = error.errors.every(
e => e.message.indexOf('Could not resolve to a Repository') !== -1
)

try {
return await octokit.graphql(query)
} catch (error) {
if (error.errors !== undefined) {
const softFail = error.errors.every(
e => e.message.indexOf('Could not resolve to a Repository') !== -1
)
if (softFail) {
core.info(error)
return error.data
}
}

if (softFail) {
if (i < requestRetries) {
core.info(error)
return error.data
core.info(`retrying in ${nextRetryTime} seconds...`)
await sleep(nextRetryTime * 1000)
nextRetryTime *= 2
} else {
throw error
}
}

throw error
}
}

Expand Down
18 changes: 9 additions & 9 deletions 2018.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ of Code] event.
* [stephenfeagin/Go-AdventOfCode](https://github.com/stephenfeagin/Go-AdventOfCode) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2020--07--06-brightgreen)
* [GreenLightning/aoc18](https://github.com/GreenLightning/aoc18) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--12--02-brightgreen)
* [mnml/aoc](https://github.com/mnml/aoc) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2023--12--25-brightgreen)
* [sivertjoe/Advent-of-Code](https://github.com/sivertjoe/Advent-of-Code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2023--12--23-brightgreen)
* [sivertjoe/Advent-of-Code](https://github.com/sivertjoe/Advent-of-Code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--06-brightgreen)
* [nlowe/aoc2018](https://github.com/nlowe/aoc2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--19-brightgreen)

#### Groovy
Expand Down Expand Up @@ -291,7 +291,7 @@ of Code] event.
* [branislavjenco/advent2018](https://github.com/branislavjenco/advent2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--09-brightgreen)
* [mariotacke/advent-of-code-2018](https://github.com/mariotacke/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2022--12--04-brightgreen)
* [KonradLinkowski/AdventOfCode](https://github.com/KonradLinkowski/AdventOfCode) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2023--12--08-brightgreen)
* [shahata/adventofcode-solver](https://github.com/shahata/adventofcode-solver) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--05-brightgreen)
* [shahata/adventofcode-solver](https://github.com/shahata/adventofcode-solver) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--06-brightgreen)

#### Kotlin

Expand Down Expand Up @@ -332,7 +332,7 @@ of Code] event.
* [deanhouseholder/advent-of-code-2018](https://github.com/deanhouseholder/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--26-brightgreen)
* [spytheman/aoc2018](https://github.com/spytheman/aoc2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--01--15-brightgreen)
* [vuryss/aoc-2018-php](https://github.com/vuryss/aoc-2018-php) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--25-brightgreen)
* [tbali0524/advent-of-code-solutions](https://github.com/tbali0524/advent-of-code-solutions) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--02--10-brightgreen)
* [tbali0524/advent-of-code-solutions](https://github.com/tbali0524/advent-of-code-solutions) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--13-brightgreen)

#### Perl

Expand Down Expand Up @@ -376,7 +376,7 @@ of Code] event.
* [fsschmitt/advent-of-code-2018](https://github.com/fsschmitt/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--06-brightgreen)
* [iBelieve/adventofcode](https://github.com/iBelieve/adventofcode) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2022--12--10-brightgreen)
* [IanFindlay/advent-of-code](https://github.com/IanFindlay/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2022--12--10-brightgreen)
* [IsaacG/Advent-of-Code](https://github.com/IsaacG/Advent-of-Code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--06-brightgreen)
* [IsaacG/Advent-of-Code](https://github.com/IsaacG/Advent-of-Code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--11-brightgreen)
* [j0057/aoc2018](https://github.com/j0057/aoc2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-not%20available-red)
* [katzuv/advent-of-code](https://github.com/katzuv/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2023--11--25-brightgreen)
* [Kurocon/AdventOfCode2018](https://github.com/Kurocon/AdventOfCode2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--12--05-brightgreen)
Expand All @@ -403,7 +403,7 @@ of Code] event.
* [williamfhe/advent-of-code-2018](https://github.com/williamfhe/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--03--25-brightgreen)
* [yspreen/adventofcode](https://github.com/yspreen/adventofcode) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--01--19-brightgreen)
* [danielrossyamitrano/AdventOfCode](https://github.com/danielrossyamitrano/AdventOfCode) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2022--05--27-brightgreen)
* [MeanderingProgrammer/advent-of-code](https://github.com/MeanderingProgrammer/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--04--30-brightgreen)
* [MeanderingProgrammer/advent-of-code](https://github.com/MeanderingProgrammer/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--15-brightgreen)

#### Racket

Expand Down Expand Up @@ -449,14 +449,14 @@ of Code] event.

*Solutions to AoC in Rust.*

* [(GitLab) BafDyce/adventofcode](https://gitlab.com/BafDyce/adventofcode) (`2018` branch; will be merged into `master` after the event)
* [BafDyce/adventofcode](https://gitlab.com/BafDyce/adventofcode)
* [BurntSushi/advent-of-code](https://github.com/BurntSushi/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2021--06--16-brightgreen)
* [FichteFoll/advent-of-code](https://github.com/FichteFoll/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2023--12--22-brightgreen)
* [Poooel/advent-of-code-2018](https://github.com/Poooel/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--06--02-brightgreen)
* [StreakyCobra/advent-of-code-2018](https://github.com/StreakyCobra/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--14-brightgreen)
* [arosspope/advent-of-code](https://github.com/arosspope/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2022--01--15-brightgreen)
* [callum-oakley/advent-of-code-2018](https://github.com/callum-oakley/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--29-brightgreen)
* [dashed/advent-of-code](https://github.com/dashed/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--04--15-brightgreen)
* [dashed/advent-of-code](https://github.com/dashed/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--20-brightgreen)
* [foo-jin/advent-of-code](https://github.com/foo-jin/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--12--18-brightgreen)
* [iicurtis/Rust-Advent-of-Code-2018](https://github.com/iicurtis/Rust-Advent-of-Code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--19-brightgreen)
* [illbexyz/advent-of-code-2018](https://github.com/illbexyz/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--09-brightgreen)
Expand All @@ -469,7 +469,7 @@ of Code] event.
* [sebnow/adventofcode](https://github.com/sebnow/adventofcode) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2023--12--11-brightgreen)
* [svisser/advent-of-code-2018](https://github.com/svisser/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2018--12--28-brightgreen)
* [w4tson/advent-of-code-2018](https://github.com/w4tson/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--02--11-brightgreen)
* [AlexAegis/advent-of-code](https://github.com/AlexAegis/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--03--23-brightgreen)
* [AlexAegis/advent-of-code](https://github.com/AlexAegis/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--21-brightgreen)

#### Scala

Expand Down Expand Up @@ -499,7 +499,7 @@ of Code] event.
*Solutions to AoC in TypeScript.*

* [MattiasBuelens/advent-of-code-2018](https://github.com/MattiasBuelens/advent-of-code-2018) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2019--05--30-brightgreen)
* [AlexAegis/advent-of-code](https://github.com/AlexAegis/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--03--23-brightgreen)
* [AlexAegis/advent-of-code](https://github.com/AlexAegis/advent-of-code) ![Last Commit on GitHub](https://img.shields.io/badge/last%20commit-2024--05--21-brightgreen)

#### Zig

Expand Down
Loading

0 comments on commit d89abc7

Please sign in to comment.