-
Notifications
You must be signed in to change notification settings - Fork 35
139 lines (117 loc) · 4.39 KB
/
ci.yaml
File metadata and controls
139 lines (117 loc) · 4.39 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
name: ci
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
if: github.event.pull_request.draft == false || github.event_name == 'push'
name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
# only run for MSV Python 3.10 on PRs, but all versions on pushes to main
python-version: ${{ github.event_name == 'push' && fromJSON('["3.10", "3.11", "3.12"]') || fromJSON('["3.10"]') }}
env:
TURN_OFF_MPS_IF_RUNNING_CI: 1
MPLBACKEND: Agg
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
activate-environment: true
- name: Install dependencies
run: |
uv sync --extra dev --extra spatiotemporal
- name: Test with pytest
run: |
# stop pytest after 3 failures to save CI time
pytest --maxfail=3 --cov=autoemulate --cov-report=xml --cov-report=html
- name: Upload Coverage
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
fail_ci_if_error: false
# # Clean python cache files
# - name: Clean cache files
# run: |
# find . -type f -name "*.pyc" -delete
# find . -type d -name "__pycache__" -delete
# rm -f .coverage* coverage.xml
# - name: Switch to CPU version of PyTorch
# run: |
# pip uninstall torch -y
# pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cpu
# - name: Verify PyTorch installation
# run: |
# python -c "import torch; print(torch.__version__); print('CUDA available:', torch.cuda.is_available())"
# - name: Debug Coverage Config
# run: |
# cat pyproject.toml
# coverage debug config
# - name: Run Tests with Coverage
# run: |
# coverage run --source=. --omit="v0/*" -m pytest
# coverage xml -i -o coverage.xml
# env:
# COVERAGE_FILE: ".coverage.${{ matrix.python-version }}"
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }} # Required for private repos
# file: ./coverage.xml # Specify the coverage report file
# fail_ci_if_error: true
# verbose: true
# - name: Store coverage file
# uses: actions/upload-artifact@v4
# with:
# name: coverage
# path: .coverage.${{ matrix.python-version }}
# include-hidden-files: true
# # Coverage job to comment on PRs and update README badge
# coverage:
# runs-on: ubuntu-latest
# needs: tests
# permissions:
# pull-requests: write
# contents: write
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Download coverage artifact
# uses: actions/download-artifact@v4
# with:
# name: coverage
# # Comment coverage details on PR
# - name: Coverage comment
# id: coverage_comment
# uses: py-cov-action/python-coverage-comment-action@v3
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# MERGE_COVERAGE_FILES: true
# # Store comment to be posted if written
# - name: Store Pull Request comment to be posted
# uses: actions/upload-artifact@v4
# if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
# with:
# name: python-coverage-comment-action
# path: python-coverage-comment-action.txt