Skip to content

refactor: Authenticator refactoring (preparation for app token refreshing) #878

refactor: Authenticator refactoring (preparation for app token refreshing)

refactor: Authenticator refactoring (preparation for app token refreshing) #878

Workflow file for this run

name: Test tap-github
on:
# Run on all pull requests and on pushes to main.
pull_request:
paths:
- .github/workflows/test_tap.yml
- poetry.lock
- pyproject.toml
- 'tap_github/**'
push:
branches:
- main
paths:
- .github/workflows/test_tap.yml
- poetry.lock
- pyproject.toml
- 'tap_github/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ORG_LEVEL_TOKEN: ${{secrets.ORG_LEVEL_TOKEN}}
strategy:
matrix:
python-version:
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
# run the matrix jobs one after the other so they can benefit from caching
max-parallel: 1
steps:
- uses: actions/checkout@v4
- 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@v4
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 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@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
# Version of Poetry to use
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-4-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
- name: Install dependencies
run: |
poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Test with pytest
id: test_pytest
continue-on-error: true
run: |
LOGLEVEL=WARNING poetry run pytest --capture=no
- name: Test with pytest (run 2)
id: retry_test_pytest
if: steps.test_pytest.outcome=='failure' # check the step outcome, wait and retry
run: |
# 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