Skip to content

Commit 6b26407

Browse files
committed
chore: update CI workflows and testing configurations
- Modified the GitHub Actions workflows to specify the correct branch for documentation deployment. - Enhanced the documentation build step by installing additional dependencies for documentation generation. - Introduced a new workflow for running tests across multiple operating systems and Python versions, including GPU tests. - Updated the test workflow to include caching for pip dependencies and improved coverage reporting. - Added integration tests to ensure comprehensive testing of the codebase, enhancing overall test coverage and reliability. - Adjusted the coverage report generation to include XML output for better integration with CI tools.
1 parent a261d0d commit 6b26407

File tree

3 files changed

+181
-9
lines changed

3 files changed

+181
-9
lines changed

.github/workflows/docs.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,33 @@ name: Build and Deploy Docs
22

33
on:
44
push:
5-
branches: [main, dev_org]
5+
branches: [main, dev/jmlr]
66

77
jobs:
88
build-and-deploy:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3
12-
12+
1313
- name: Set up Python
1414
uses: actions/setup-python@v4
1515
with:
1616
python-version: '3.9'
17-
17+
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
21-
pip install -e '.[dev]'
22-
pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints
23-
21+
pip install -e '.[dev, docs]'
22+
# pip install -e '.[dev]'
23+
# pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints
24+
2425
- name: Build docs
2526
run: |
2627
cd docs
2728
make html
28-
29+
2930
- name: Deploy to GitHub Pages
3031
uses: peaceiris/actions-gh-pages@v3
3132
with:
3233
github_token: ${{ secrets.GITHUB_TOKEN }}
33-
publish_dir: ./docs/build/html
34+
publish_dir: ./docs/build/html_temp

.github/workflows/test.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, dev/jmlr ]
6+
pull_request:
7+
branches: [ main, dev/jmlr ]
8+
workflow_call:
9+
10+
jobs:
11+
test:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
python-version: ["3.9", "3.10", "3.11"]
18+
pytorch-version: ["2.0.0", "2.1.0", "2.2.0"]
19+
exclude:
20+
# Exclude some combinations to reduce CI load
21+
- os: windows-latest
22+
python-version: "3.9"
23+
- os: macos-latest
24+
python-version: "3.9"
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
# with:
29+
# fetch-depth: 0
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Cache pip dependencies
37+
uses: actions/cache@v3
38+
with:
39+
path: ~/.cache/pip
40+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pip-${{ matrix.python-version }}-
43+
${{ runner.os }}-pip-
44+
45+
- name: Install PyTorch ${{ matrix.pytorch-version }}
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install torch==${{ matrix.pytorch-version }} --index-url https://download.pytorch.org/whl/cpu
49+
50+
- name: Install package, dev, and test dependencies
51+
run: pip install -e ".[dev, tests]"
52+
53+
# - name: Install additional test dependencies
54+
# run: pip install pytest-xdist pytest-timeout
55+
56+
- name: Run unit and gpu tests with coverage
57+
# Automatically uses pytest configuration from pyproject.toml
58+
run: pytest
59+
env:
60+
PYTORCH_VERSION: ${{ matrix.pytorch-version }}
61+
# run: |
62+
# pytest tests/unit/ -v \
63+
# --cov=torchsom \
64+
# --cov-report=xml \
65+
# --cov-report=html \
66+
# --cov-report=term-missing \
67+
# --cov-config=pyproject.toml \
68+
# --junit-xml=junit.xml \
69+
# --timeout=300 \
70+
# -n auto \
71+
# -m "unit or gpu"
72+
73+
- name: Upload coverage to Codecov
74+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && matrix.pytorch-version == '2.1.0'
75+
uses: codecov/codecov-action@v5
76+
with:
77+
files: coverage.xml
78+
flags: unittests
79+
name: codecov-umbrella
80+
fail_ci_if_error: false
81+
82+
- name: Upload test results
83+
uses: actions/upload-artifact@v3
84+
if: always()
85+
with:
86+
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }}-torch${{ matrix.pytorch-version }}
87+
path: |
88+
coverage.xml
89+
htmlcov/
90+
junit.xml
91+
92+
test-gpu:
93+
runs-on: self-hosted
94+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
95+
strategy:
96+
fail-fast: false
97+
matrix:
98+
python-version: ["3.10"]
99+
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- name: Set up Python ${{ matrix.python-version }}
104+
uses: actions/setup-python@v4
105+
with:
106+
python-version: ${{ matrix.python-version }}
107+
108+
- name: Install CUDA PyTorch
109+
run: |
110+
python -m pip install --upgrade pip
111+
pip install torch --index-url https://download.pytorch.org/whl/cu118
112+
113+
- name: Install package, dev, and test dependencies
114+
run: pip install -e ".[dev, tests]"
115+
116+
- name: Run GPU tests
117+
run: |
118+
pytest tests/unit/ -v \
119+
--cov=torchsom \
120+
--cov-report=xml \
121+
--cov-report=term-missing \
122+
--junit-xml=junit-gpu.xml \
123+
--timeout=600 \
124+
-m "gpu"
125+
env:
126+
CUDA_VISIBLE_DEVICES: 0
127+
128+
- name: Upload GPU test results
129+
uses: actions/upload-artifact@v3
130+
if: always()
131+
with:
132+
name: gpu-test-results
133+
path: |
134+
coverage.xml
135+
junit-gpu.xml
136+
137+
integration-tests:
138+
runs-on: ubuntu-latest
139+
needs: test
140+
if: github.event_name == 'push'
141+
steps:
142+
- uses: actions/checkout@v4
143+
144+
- name: Set up Python 3.10
145+
uses: actions/setup-python@v4
146+
with:
147+
python-version: "3.10"
148+
149+
- name: Install package, dev, and test dependencies
150+
run: pip install -e ".[dev, tests]"
151+
152+
- name: Run integration tests
153+
run: |
154+
pytest tests/ -v \
155+
--cov=torchsom \
156+
--cov-report=xml \
157+
--cov-report=term-missing \
158+
--junit-xml=junit-integration.xml \
159+
--timeout=600 \
160+
-m "integration"
161+
continue-on-error: true
162+
163+
- name: Upload integration test results
164+
uses: actions/upload-artifact@v3
165+
if: always()
166+
with:
167+
name: integration-test-results
168+
path: |
169+
coverage.xml
170+
junit-integration.xml

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ addopts = [
114114
"--durations=10", # Report 10 slowest tests
115115
"--cov=torchsom", # Coverage of torchsom
116116
"--cov-report=term-missing", # Show missing lines in the report
117+
"--cov-report=xml", # Generate XML coverage report
117118
"--cov-report=html", # Generate HTML coverage report
118119
"--cov-config=pyproject.toml", # Use configuration from pyproject.toml
119-
"-m unit or gpu", # default marker selection
120120
"--junit-xml=junit.xml", # Create JUnit XML file for CI compatibility
121+
"-m unit or gpu", # default marker selection
121122
]
122123
# Custom pytest markers with descriptions
123124
markers = [

0 commit comments

Comments
 (0)