-
Notifications
You must be signed in to change notification settings - Fork 19
128 lines (123 loc) · 5.07 KB
/
Copy pathpythonpackage.yml
File metadata and controls
128 lines (123 loc) · 5.07 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Python package
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '31 13 * * 2'
jobs:
# ── Offline unit tests ────────────────────────────────────────────────────
# Run on every supported Python version. No secrets required.
# Skips tests marked `live` or `integration` (see pytest.ini addopts).
test-offline:
name: "Unit tests – Python ${{ matrix.python-version }}"
runs-on: ubuntu-22.04
environment: test
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade setuptools pip pipenv
pipenv install --skip-lock --dev -e .
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
pipenv run ruff check . --select=E9,F63,F7,F82 --output-format=full
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
pipenv run ruff check . --exit-zero
- name: Test with pytest (offline only)
run: |
pipenv run py.test \
--cov-config .coveragerc \
--cov-report xml:output/coverage.xml \
--cov mygeotab \
--junitxml output/python${{ matrix.python-version }}-test-results.xml \
tests/
- name: Upload coverage to Codecov
if: matrix.python-version == '3.14'
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./output/coverage.xml
flags: "py${{ matrix.python-version }}"
- name: Archive test results
uses: actions/upload-artifact@v7
with:
name: "test-results-py${{ matrix.python-version }}"
path: output
# ── Live network tests ─────────────────────────────────────────────────────
# Unauthenticated calls to public Geotab servers (GetVersion).
# Runs on a single Python version; does not need DB credentials.
test-live:
name: "Live network tests – Python 3.12"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- name: Set up Python 3.12
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade setuptools pip pipenv
pipenv install --skip-lock --dev -e .
- name: Run live server-call tests
run: |
pipenv run py.test -m live tests/
# ── Credentialed integration tests ────────────────────────────────────────
# Requires GitHub environment "test" with DB secrets. Runs sequentially
# (max-parallel: 1) to avoid hammering the shared test account.
test-integration:
name: "Integration tests – Python 3.12"
runs-on: ubuntu-22.04
environment: test
strategy:
max-parallel: 1
env:
MYGEOTAB_DATABASE: ${{ secrets.MYGEOTAB_DATABASE }}
MYGEOTAB_USERNAME: ${{ secrets.MYGEOTAB_USERNAME }}
MYGEOTAB_PASSWORD: ${{ secrets.MYGEOTAB_PASSWORD }}
MYGEOTAB_SERVER: ${{ secrets.MYGEOTAB_SERVER }}
MYGEOTAB_USERNAME_ASYNC: ${{ secrets.MYGEOTAB_USERNAME_ASYNC }}
MYGEOTAB_PASSWORD_ASYNC: ${{ secrets.MYGEOTAB_PASSWORD_ASYNC }}
steps:
- uses: actions/checkout@v7
- name: Set up Python 3.12
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade setuptools pip pipenv
pipenv install --skip-lock --dev -e .
- name: Run credentialed integration tests
# Skip if secrets are not available (e.g. PRs from forks).
# Exit code 5 means pytest collected 0 tests (no integration tests
# marked yet); treat that as success so the job doesn't block the PR.
run: |
if [ -z "$MYGEOTAB_DATABASE" ]; then
echo "No credentials available – skipping integration tests."
exit 0
fi
pipenv run py.test \
-m integration \
--benchmark-min-rounds=3 \
--benchmark-storage=file://output/ \
--benchmark-autosave \
--junitxml output/integration-test-results.xml \
tests/ || { code=$?; [ $code -eq 5 ] && echo "No integration tests collected – OK." || exit $code; }
- name: Archive integration results
uses: actions/upload-artifact@v7
with:
name: integration-results
path: output