Skip to content

Commit 2899f46

Browse files
CI/WEB: Adding cache for maintainers' github info (#50485)
1 parent 797f23e commit 2899f46

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
@@ -46,6 +46,12 @@ jobs:
4646
- name: Build Pandas
4747
uses: ./.github/actions/build_pandas
4848

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

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
@@ -163,6 +164,18 @@ def maintainers_add_info(context):
163164
Given the active maintainers defined in the yaml file, it fetches
164165
the GitHub user information for them.
165166
"""
167+
timestamp = time.time()
168+
169+
cache_file = pathlib.Path("maintainers.json")
170+
if cache_file.is_file():
171+
with open(cache_file) as f:
172+
context["maintainers"] = json.load(f)
173+
# refresh cache after 1 hour
174+
if (timestamp - context["maintainers"]["timestamp"]) < 3_600:
175+
return context
176+
177+
context["maintainers"]["timestamp"] = timestamp
178+
166179
repeated = set(context["maintainers"]["active"]) & set(
167180
context["maintainers"]["inactive"]
168181
)
@@ -179,6 +192,10 @@ def maintainers_add_info(context):
179192
return context
180193
resp.raise_for_status()
181194
context["maintainers"][f"{kind}_with_github_info"].append(resp.json())
195+
196+
with open(cache_file, "w") as f:
197+
json.dump(context["maintainers"], f)
198+
182199
return context
183200

184201
@staticmethod

0 commit comments

Comments
 (0)