From 7b477a7717567ec1c571f9532ba2c5d41dec596d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Sava=C3=ABte?= Date: Fri, 12 May 2023 15:40:21 +0200 Subject: [PATCH 1/2] Update ci caching logic --- .github/workflows/test_tap.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_tap.yml b/.github/workflows/test_tap.yml index 5125a505..adbced77 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: From ffd1ff52dc8ac7deb8deb0935d87277d67751a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Sava=C3=ABte?= Date: Fri, 12 May 2023 16:11:41 +0200 Subject: [PATCH 2/2] Minimise sleep time before retrying python tests --- .github/workflows/test_tap.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_tap.yml b/.github/workflows/test_tap.yml index adbced77..2c0d8f94 100644 --- a/.github/workflows/test_tap.yml +++ b/.github/workflows/test_tap.yml @@ -72,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