Skip to content

Commit

Permalink
Assume ok when remaining rate limit is missing
Browse files Browse the repository at this point in the history
Otherwise, we try to pick out the time left until rate limit reset
and crash.
  • Loading branch information
tannewt committed Oct 1, 2024
1 parent c321d22 commit 03f581e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bundle_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name: Update Bundles
on:
schedule:
- cron: 0 5 * * *
workflow_dispatch:

jobs:
check-repo-owner:
Expand Down Expand Up @@ -50,7 +51,6 @@ jobs:
ADABOT_EMAIL: ${{ secrets.ADABOT_EMAIL }}
ADABOT_GITHUB_USER: ${{ secrets.ADABOT_GITHUB_USER }}
ADABOT_GITHUB_ACCESS_TOKEN: ${{ secrets.ADABOT_GITHUB_ACCESS_TOKEN }}
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
BIGQUERY_PRIVATE_KEY: ${{ secrets.BIGQUERY_PRIVATE_KEY }}
BIGQUERY_CLIENT_EMAIL: ${{ secrets.BIGQUERY_CLIENT_EMAIL }}
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.9
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3
- name: Versions
run: |
python3 --version
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ jobs:
# Its necessary to do this here, since 'schedule' events cannot (currently)
# be limited (they run on all forks' default branches).
if: startswith(github.repository, 'adafruit/')
services:
redis:
image: redis
ports:
- 6379/tcp
options: --entrypoint redis-server
steps:
- name: Set up Python 3.9
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3
- name: Versions
run: |
python3 --version
Expand All @@ -50,6 +44,5 @@ jobs:
ADABOT_GITHUB_USER: ${{ secrets.ADABOT_GITHUB_USER }}
ADABOT_GITHUB_ACCESS_TOKEN: ${{ secrets.ADABOT_GITHUB_ACCESS_TOKEN }}
RTD_TOKEN: ${{ secrets.RTD_TOKEN }}
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
python3 -u -m pytest
4 changes: 2 additions & 2 deletions adabot/arduino_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ def main(verbosity=1, output_file=None): # pylint: disable=missing-function-doc
run_arduino_lib_checks()
except:
_, exc_val, exc_tb = sys.exc_info()
logger.error("Exception Occurred!", quiet=True)
logger.error(("-" * 60), quiet=True)
logger.error("Exception Occurred!")
logger.error(("-" * 60))
logger.error("Traceback (most recent call last):")
trace = traceback.format_tb(exc_tb)
for line in trace:
Expand Down
4 changes: 2 additions & 2 deletions adabot/circuitpython_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

BUNDLES = ["Adafruit_CircuitPython_Bundle", "CircuitPython_Community_Bundle"]

CONTRIBUTOR_CACHE = {}


def fetch_bundle(bundle, bundle_path):
"""Clones `bundle` to `bundle_path`"""
Expand Down Expand Up @@ -549,8 +551,6 @@ def new_release(bundle, bundle_path):
contributor_cache_fn = pathlib.Path("contributors.json").resolve()
if contributor_cache_fn.exists():
CONTRIBUTOR_CACHE = json.loads(contributor_cache_fn.read_text())
else:
CONTRIBUTOR_CACHE = {}

bundles_dir = os.path.abspath(".bundles")
if "GITHUB_WORKSPACE" in os.environ:
Expand Down
4 changes: 3 additions & 1 deletion adabot/github_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def request(method, url, **kwargs):
_fix_url(url), timeout=TIMEOUT, **_fix_kwargs(kwargs)
)
from_cache = getattr(response, "from_cache", False)
remaining = int(response.headers.get("X-RateLimit-Remaining", 0))
# If rate limit remaining is missing, then assume we're fine. Use a million to signify this
# case. GitHub will be in the single thousands.
remaining = int(response.headers.get("X-RateLimit-Remaining", 1000000))
logging.debug(
"GET %s %s status=%s",
url,
Expand Down

0 comments on commit 03f581e

Please sign in to comment.