-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (109 loc) · 3.76 KB
/
Copy pathci.yml
File metadata and controls
115 lines (109 loc) · 3.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
# Least privilege by default; no job needs write access.
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-type-test:
name: lint + type + test (no GPU)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0 # hatch-vcs needs git history
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ matrix.python }}
cache: pip
- name: Install
run: |
python -m pip install --upgrade pip
pip install -e ".[cli,dev]"
- name: Lint
run: ruff check src tests
- name: Format check
run: ruff format --check src tests
- name: Type check
run: mypy src
- name: Unit + integration tests (skip slow/gpu)
run: pytest -m "not slow and not gpu" --cov=cortex_score --cov-report=xml
- name: Upload coverage
if: matrix.python == '3.11'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-xml
path: coverage.xml
packaging:
name: build + twine check + wheel smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.11"
- name: Build + metadata check
run: |
python -m pip install --upgrade pip build twine
python -m build
python -m twine check dist/*
- name: Install built wheel and smoke-test (no torch)
run: |
python -m pip install dist/*.whl
cd "$RUNNER_TEMP" # import the installed wheel, not the source tree
python -c "
import sys
import numpy as np
import cortex_score
assert 'torch' not in sys.modules
from cortex_score import score_from_predictions
r = score_from_predictions(np.random.randn(4, 20484).astype('float32'), model_revision='ci-wheel')
assert len(r.networks) == 5
print('wheel smoke OK', cortex_score.__version__)
"
- name: Wheel-content packaging tests
run: |
pip install -e ".[dev]"
pytest tests/integration/test_packaging.py -m slow
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: dist
path: dist/
import-without-gpu:
name: importable with no torch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.11"
- name: Install base only (no [gpu-deps])
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Confirm torch absent
run: python -c "import sys; assert 'torch' not in sys.modules; import cortex_score; print(cortex_score.__version__)"
- name: CPU-only smoke
run: |
python -c "
import numpy as np
from cortex_score import score_from_predictions
preds = np.random.randn(4, 20484).astype('float32')
r = score_from_predictions(preds, model_revision='ci')
assert len(r.networks) == 5
print('cpu smoke OK', r.result_id[:12])
"