Skip to content

adding CI testing for multiple python version and caching pip depende… #19

adding CI testing for multiple python version and caching pip depende…

adding CI testing for multiple python version and caching pip depende… #19

Workflow file for this run

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] # Test on multiple Python versions
steps:
# Step 1: Checkout the code
- name: Checkout the code
uses: actions/checkout@v4
# Step 2: Set up Python versions
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Step 3: Cache pip dependencies
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Step 4: Set up and activate virtual environment
- name: Set up and activate virtual environment
id: activate-venv
run: |
python -m venv venv
source venv/bin/activate || .\venv\Scripts\activate
shell: bash
# Step 5: Install dependencies (including maturin and project dependencies)
- name: Install dependencies
run: |
pip install --upgrade pip
pip install maturin
pip install -r requirements.txt
shell: bash
# Step 6: Run Ruff linter and fix issues
- name: Run Ruff (Python linter and fix)
run: |
ruff check . --fix
shell: bash
# Step 7: Run Black formatter
- name: Run Black (Python formatter)
run: |
black .
shell: bash
# Step 8: Build and install the Rust library using Maturin (in release mode)
- name: Build and install Rust library (release mode)
run: |
maturin develop --release # Build the Rust library and install it
shell: bash
# Step 9: Run Python tests with pytest
- name: Run Python tests with pytest
run: |
pytest tests/
shell: bash
# Step 10: Build Sphinx documentation
- name: Build Sphinx documentation
run: |
cd docs
make html
shell: bash
# Step 11: Deploy documentation 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