diff --git a/.github/workflows/test_tap.yml b/.github/workflows/test_tap.yml index 5125a505..2c0d8f94 100644 --- a/.github/workflows/test_tap.yml +++ b/.github/workflows/test_tap.yml @@ -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: @@ -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