-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (90 loc) · 3.55 KB
/
Copy pathrun_test.yaml
File metadata and controls
103 lines (90 loc) · 3.55 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
name: Automated Tests
on:
push:
branches: [main]
pull_request:
branches: [main, fix/*, hotfix/*, release/*, develop]
# Security: Add minimal permissions
permissions:
contents: read
actions: write # required for actions/upload-artifact
env:
PYTORCH_VERSION: ">=2.0"
TORCHVISION_VERSION: ">=0.15"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Fail fast to save CI resources
fail-fast: true
matrix:
os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest", "windows-latest"]') }}
python-version: ${{ github.event_name == 'pull_request' && fromJSON('["3.10"]') || fromJSON('["3.10", "3.12"]') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Fetch more history for better caching
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
**/pyproject.toml
**/requirements*.txt
**/setup.py
# Improved caching strategy
- name: Cache dependencies and PyTorch
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.cache/torch
key: deps-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt', '**/setup.py') }}-pytorch-${{ env.PYTORCH_VERSION }}
restore-keys: |
deps-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt', '**/setup.py') }}-
deps-${{ runner.os }}-py${{ matrix.python-version }}-
- name: Install dependencies
# Install PyTorch CPU version for faster installation and testing
run: |
python -m pip install --upgrade pip wheel setuptools
pip install "torch${{ env.PYTORCH_VERSION }}" "torchvision${{ env.TORCHVISION_VERSION }}" --index-url https://download.pytorch.org/whl/cpu
pip install .[dev]
timeout-minutes: 10
env:
PYTHONIOENCODING: utf-8
- name: Run tests with pytest
run: |
pytest tests --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml --cov=datamint --cov-report=html --tb=short -v
timeout-minutes: 45
env:
PYTHONIOENCODING: utf-8
if: runner.os != 'Windows'
- name: Run import tests with pytest (Windows)
run: |
pytest tests/test_imports.py --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml --tb=short -v
timeout-minutes: 10
env:
PYTHONIOENCODING: utf-8
if: runner.os == 'Windows'
- name: Test datamint config CLI (unified)
run: datamint config --api-key testapikey
timeout-minutes: 1
env:
PYTHONIOENCODING: utf-8
- name: Upload pytest test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml
retention-days: 15
- name: Upload coverage report
if: always() && matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: htmlcov/
retention-days: 15