-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (113 loc) · 4 KB
/
CI.yml
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: CI
on:
push:
branches:
- main
pull_request:
permissions:
contents: write
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
# Checkout the code
- name: Checkout the code
uses: actions/checkout@v4
# Set up Python versions
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Cache pip dependencies
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Run Clippy
- name: Run Clippy (Rust Linter)
run: cargo clippy -- -D warnings
# Set up and activate virtual environment (store activation command as output)
- name: Set up and activate virtual environment
id: activate-venv
run: |
python -m venv venv
echo "activate_venv=source venv/bin/activate" >> $GITHUB_ENV # Store the activation command as output for later reuse
shell: bash
# Install dependencies (including maturin and project dependencies)
- name: Install dependencies
run: |
${{ env.activate_venv }} # Use stored activation command
pip install --upgrade pip
pip install maturin
pip install -r requirements.txt
shell: bash
# Run Ruff linter and fail on any issues
- name: Run Ruff (Python linter)
run: |
${{ env.activate_venv }} # Use stored activation command
ruff check .
shell: bash
# Run Black formatter
- name: Run Black (Python formatter)
run: |
${{ env.activate_venv }} # Use stored activation command
black --check .
shell: bash
# Build and install the Rust library using Maturin (in release mode)
- name: Build and install Rust library (release mode)
run: |
${{ env.activate_venv }} # Use stored activation command
maturin develop --release # Build the Rust library and install it
shell: bash
# Run Python tests with pytest
- name: Run Python tests with pytest
run: |
${{ env.activate_venv }} # Use stored activation command
pytest tests/ # Run tests
shell: bash
# Separate job for deploying the documentation
deploy:
runs-on: ubuntu-latest
needs: linux # Ensure this job only runs after the matrix job completes
steps:
# Step 1: Checkout the code
- name: Checkout the code
uses: actions/checkout@v4
# Step 2: Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10' # Just need a single Python version to build docs
# Step 3: Set up and activate virtual environment for Sphinx (store activation command as output)
- name: Set up and activate virtual environment
id: activate-venv
run: |
python -m venv venv
echo "activate_venv=source venv/bin/activate" >> $GITHUB_ENV # Store the activation command as output for later reuse
shell: bash
# Step 4: Install dependencies for docs
- name: Install dependencies for docs
run: |
${{ env.activate_venv }} # Use stored activation command
pip install --upgrade pip
pip install -r requirements.txt
shell: bash
# Step 5: Build Sphinx documentation
- name: Build Sphinx documentation
run: |
${{ env.activate_venv }} # Use stored activation command
cd docs
make html
shell: bash
# Step 6: Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_build/html