CI #374
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| # Run on all pull requests and on pushes to main. | |
| pull_request: | |
| paths: | |
| - .github/workflows/ci.yml | |
| - pyproject.toml | |
| - uv.lock | |
| - tap_github/** | |
| - tests/** | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - .github/workflows/ci.yml | |
| - pyproject.toml | |
| - uv.lock | |
| - tap_github/** | |
| - tests/** | |
| 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: | |
| name: CI | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| ORG_LEVEL_TOKEN: ${{secrets.ORG_LEVEL_TOKEN}} | |
| UV_PYTHON: ${{ matrix.python-version }} | |
| 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 | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - 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@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| 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 }} | |
| id: setup-python | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| allow-prereleases: true | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0 | |
| - name: Install Tox | |
| run: | | |
| uv tool install --with tox-gh tox | |
| - name: Run Tox | |
| id: test_pytest | |
| continue-on-error: true | |
| env: | |
| LOGLEVEL: WARNING | |
| run: | | |
| tox | |
| - name: Run Tox (run 2) | |
| id: retry_test_pytest | |
| if: steps.test_pytest.outcome=='failure' # check the step outcome, wait and retry | |
| env: | |
| LOGLEVEL: WARNING | |
| 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 | |
| tox |