Skip to content

Commit

Permalink
fix: update ci caching logic (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentS authored May 15, 2023
1 parent d8971d4 commit 203b05e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/test_tap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash

- name: Cache github API responses
uses: actions/cache@v3
with:
# must match the path in tests/__init__.py
path: '.cache/api_calls_tests_cache.sqlite'
# github cache expires after 1wk, and we expire the content after 24h
# this key should not need to change unless we need to clear the cache
key: api-cache-v4
# this key is rotated every 24h so that the code does not find a stale
# file in the cache. See issue #119
key: api-cache-v4-${{ steps.get-date.outputs.date }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -64,5 +72,11 @@ jobs:
id: retry_test_pytest
if: steps.test_pytest.outcome=='failure' # check the step outcome, wait and retry
run: |
sleep 60m
# sleep as little as possible to reduce CI run time
# This assumes that REST quota is the one that caused problem
# (which is most likely/often the case)
target_ts=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/rate_limit | grep reset | head -n 1 | awk -F: '{ print $2 }')
current_ts=$(date +%s)
seconds_to_sleep=$(echo "$target_ts - $current_ts" | bc)
sleep $seconds_to_sleep
LOGLEVEL=WARNING poetry run pytest --capture=no

0 comments on commit 203b05e

Please sign in to comment.