Skip to content

Commit 113ca72

Browse files
Backport PR #50485 on branch 1.5.x (CI/WEB: Adding cache for maintainers' github info) (#50551)
Backport PR #50485: CI/WEB: Adding cache for maintainers' github info Co-authored-by: Marc Garcia <[email protected]>
1 parent 033c259 commit 113ca72

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.github/workflows/docbuild-and-upload.yml

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ jobs:
4545
- name: Build Pandas
4646
uses: ./.github/actions/build_pandas
4747

48+
- name: Set up maintainers cache
49+
uses: actions/cache@v3
50+
with:
51+
path: maintainers.json
52+
key: maintainers
53+
4854
- name: Build website
4955
run: python web/pandas_web.py web/pandas --target-path=web/build
5056

web/pandas_web.py

+17
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import collections
2828
import datetime
2929
import importlib
30+
import json
3031
import operator
3132
import os
3233
import pathlib
@@ -157,6 +158,18 @@ def maintainers_add_info(context):
157158
Given the active maintainers defined in the yaml file, it fetches
158159
the GitHub user information for them.
159160
"""
161+
timestamp = time.time()
162+
163+
cache_file = pathlib.Path("maintainers.json")
164+
if cache_file.is_file():
165+
with open(cache_file) as f:
166+
context["maintainers"] = json.load(f)
167+
# refresh cache after 1 hour
168+
if (timestamp - context["maintainers"]["timestamp"]) < 3_600:
169+
return context
170+
171+
context["maintainers"]["timestamp"] = timestamp
172+
160173
repeated = set(context["maintainers"]["active"]) & set(
161174
context["maintainers"]["inactive"]
162175
)
@@ -171,6 +184,10 @@ def maintainers_add_info(context):
171184
return context
172185
resp.raise_for_status()
173186
context["maintainers"][f"{kind}_with_github_info"].append(resp.json())
187+
188+
with open(cache_file, "w") as f:
189+
json.dump(context["maintainers"], f)
190+
174191
return context
175192

176193
@staticmethod

0 commit comments

Comments
 (0)