-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (134 loc) · 4.77 KB
/
Copy pathtest-python.yml
File metadata and controls
140 lines (134 loc) · 4.77 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
129
130
131
132
133
134
135
136
137
138
139
140
name: Test Python
on:
push:
paths:
- 'app.py'
- 'backend/**'
- 'lib/**'
- 'tools/**'
- 'tests/**'
- 'web/**'
- 'Pipfile'
- 'Pipfile.lock'
- '.github/workflows/test-python.yml'
pull_request:
paths:
- 'app.py'
- 'backend/**'
- 'lib/**'
- 'tools/**'
- 'tests/**'
- 'web/**'
- 'Pipfile'
- 'Pipfile.lock'
- '.github/workflows/test-python.yml'
# The macOS job below is intentionally not part of the per-PR path filters.
schedule:
- cron: '17 4 * * 1'
workflow_dispatch:
env:
PIPENV_VENV_IN_PROJECT: '1'
PIPENV_IGNORE_VIRTUALENVS: '1'
jobs:
# Syntax-only checks. No project dependencies are installed.
syntax:
name: Syntax check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Compile Python sources
run: python -m compileall -q app.py backend/app.py lib tools tests
# Globbed rather than listing files: web/*.js changes over time and a
# hardcoded name silently stops checking a renamed file (or hard-fails on
# a deleted one).
- name: Check browser JavaScript
run: |
set -e
for f in web/*.js; do
echo "node --check $f"
node --check "$f"
done
# `pipenv verify` only compares the Pipfile hash against Pipfile.lock, so it
# needs no dependency install and is safe on Linux.
lockfile:
name: Lockfile in sync
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pipenv
run: pip install pipenv
- name: Verify Pipfile.lock matches Pipfile
run: pipenv verify
# Linux is the primary test platform. The old macOS pin existed only because
# `openhaybike/locations.py` did `import objc`; openhaybike is gone, no Python
# file in the repo imports objc, and the pyobjc-* entries left in
# Pipfile.lock (transitive via bleak <- FindMy) carry
# `sys_platform == 'darwin'` markers, so they are simply skipped here.
#
# `pipenv sync` (not `pipenv install`) is deliberate: it installs exactly what
# Pipfile.lock pins, with hash verification and no re-resolution. Those
# platform markers were hand-restored after pipenv resolved the lock on a Mac
# and stripped them; a future `pipenv lock` run on macOS will strip them
# again. When that happens `pipenv sync` on this runner fails loudly trying to
# build pyobjc-core on Linux, instead of the breakage reaching users.
# Lock-vs-Pipfile freshness is covered separately by the `lockfile` job.
test:
name: Unit tests (Linux)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pipenv
run: pip install pipenv
- name: Locate pip cache
id: pip-cache
run: echo "dir=$(pip cache dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-py3.12-pipenv-${{ hashFiles('Pipfile.lock') }}
restore-keys: ${{ runner.os }}-py3.12-pipenv-
- name: Install dependencies from the lock file
run: pipenv sync --dev
- name: Assert no macOS-only package was installed
run: |
if pipenv run python -c "import objc" 2>/dev/null; then
echo "pyobjc was installed on Linux - Pipfile.lock lost its" \
"sys_platform == 'darwin' markers. Re-patch the lock." >&2
exit 1
fi
echo "No pyobjc on Linux, as expected."
- name: Run tests
run: pipenv run python -m unittest discover -s tests -v
# macOS is where the app actually runs (eel desktop UI), and it is the only
# platform that exercises the pyobjc-* / macholib branch of Pipfile.lock.
# Kept off the per-PR path triggers because macOS runners bill at ~10x Linux;
# it runs weekly and on demand, which is enough to catch a darwin-side lock
# regression without taxing every pull request.
test-macos:
name: Unit tests (macOS)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pipenv
run: pip install pipenv
- name: Install dependencies from the lock file
run: pipenv sync --dev
- name: Run tests
run: pipenv run python -m unittest discover -s tests -v