forked from MeltanoLabs/tap-github
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (89 loc) · 2.76 KB
/
ci.yml
File metadata and controls
100 lines (89 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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}}
TOX_GH_MAJOR_MINOR: ${{ 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@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
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 uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}
- 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