Skip to content

Test tap-github

Test tap-github #2615

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/**'
workflow_dispatch:
schedule:
# Every 6 hours
- cron: "0 */6 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 1
jobs:
tests:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ORG_LEVEL_TOKEN: ${{secrets.ORG_LEVEL_TOKEN}}
strategy:
matrix:
python-version:
- "3.14"
- "3.13"
- "3.12"
- "3.11"
- "3.10"
# run the matrix jobs one after the other so they can benefit from caching
max-parallel: 1
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- 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@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
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: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
# Version of Poetry to use
version: 2.2.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: poetry
- name: Install dependencies
run: |
poetry env use ${{ steps.setup-python.outputs.python-path }}
poetry install
- name: Type check with mypy
id: type_check
continue-on-error: true
run: |
poetry run mypy tap_github
- 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