-
Notifications
You must be signed in to change notification settings - Fork 7
132 lines (115 loc) · 3.59 KB
/
Copy pathpytest.yml
File metadata and controls
132 lines (115 loc) · 3.59 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
name: Tests
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch: # Manually trigger the workflow
# Triggers with push to main
push:
branches:
- main
- development
# Triggers with push to a PR aimed at main
pull_request:
branches:
- main
- development
env:
package-name: "hypersweeper"
test-dir: tests
UV_SYSTEM_PYTHON: 1
CI: false
jobs:
# General unit tests
source-test:
name: test
runs-on: "ubuntu-latest"
defaults:
run:
shell: bash # Default to using bash on all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.6.14"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install ${{ env.package-name }}
run: make install-dev
- name: Store git status
id: status-before
shell: bash
run: |
BEFORE="$(git status --porcelain -b)"
# save multi-line output correctly to GITHUB_OUTPUT
echo "BEFORE<<EOF" >> $GITHUB_OUTPUT
echo "$BEFORE" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Tests (with crash diagnostics)
shell: bash
env:
PYTHONFAULTHANDLER: "1"
run: |
set -o pipefail
echo "Running pytest with faulthandler; output saved to pytest.log"
python -X faulthandler -m pytest -vv -s --disable-pytest-warnings tests --durations=20 2>&1 | tee pytest.log
rc=${PIPESTATUS[0]}
echo "pytest exit code: $rc"
if [ "$rc" -ne 0 ]; then
echo "===== Last 500 lines of pytest.log ====="
tail -n 500 pytest.log || true
echo "===== Python faulthandler / thread info ====="
python - <<'PY'
import faulthandler, threading
print('faulthandler enabled:', faulthandler.is_enabled())
print('thread count:', len(threading.enumerate()))
PY
if command -v dmesg >/dev/null 2>&1; then
echo "===== dmesg tail (possible OOM/kernel kills) ====="
sudo dmesg | tail -n 200 || true
fi
mkdir -p artifacts
cp pytest.log artifacts/
exit $rc
fi
- name: Upload pytest log
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest-log
path: artifacts/pytest.log
- name: Diagnostics and cleanup check
if: always()
shell: bash
run: |
echo "=== GIT status before tests ==="
echo "${{ steps.status-before.outputs.BEFORE }}"
echo "=== GIT status after tests ==="
git status --porcelain -b
echo "=== Running processes (ps) ==="
ps auxf || true
echo "=== Open files in repo (lsof) ==="
lsof +D . || true
echo "=== disk usage (du) at repo root ==="
du -sh . || true
before="${{ steps.status-before.outputs.BEFORE }}"
after="$(git status --porcelain -b)"
if [[ "$before" != "$after" ]]; then
echo "git status from before: $before"
echo "git status from after: $after"
echo "Not all generated files have been deleted!"
exit 1
fi
- name: Kill leftover test processes (best-effort)
if: always()
shell: bash
run: |
pkill -f uv || true
pkill -f pytest || true
sleep 1
ps auxf || true