Skip to content

Commit

Permalink
adding CI testing for multiple python version and caching pip depende…
Browse files Browse the repository at this point in the history
…ncies
  • Loading branch information
BenJourdan committed Oct 12, 2024
1 parent e4d6639 commit 8662cf1
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,65 +12,78 @@ permissions:
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 (this step pulls your repository code)
# Step 1: Checkout the code
- name: Checkout the code
uses: actions/checkout@v4

# Step 2: Set up Python
# Step 2: Set up Python versions
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: ${{ matrix.python-version }}

# Step 3: Create a virtual environment and install dependencies (including black, ruff, etc.)
- name: Install dependencies
# 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 # Linux/Windows compatible
python -m pip install --upgrade pip
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 4: Run Ruff for linting and import sorting
- name: Run Ruff (Python linter)
# Step 6: Run Ruff linter and fix issues
- name: Run Ruff (Python linter and fix)
run: |
source venv/bin/activate || .\venv\Scripts\activate
ruff check . --fix
shell: bash

# Step 5: Run Black to ensure code formatting (non-fix mode)
- name: Run Black (Python formatter check)
# Step 7: Run Black formatter
- name: Run Black (Python formatter)
run: |
source venv/bin/activate || .\venv\Scripts\activate
black --check .
black .
shell: bash

# Step 6: Build and install the Rust library using Maturin (in release mode)
# Step 8: Build and install the Rust library using Maturin (in release mode)
- name: Build and install Rust library (release mode)
run: |
source venv/bin/activate || .\venv\Scripts\activate
maturin develop --release # Build the Rust library and install it
shell: bash

# Step 7: Run Python tests with pytest
# Step 9: Run Python tests with pytest
- name: Run Python tests with pytest
run: |
source venv/bin/activate || .\venv\Scripts\activate
pytest tests/ # Run tests
pytest tests/
shell: bash

# Step 8: Build Sphinx Documentation
- name: Build Sphinx Documentation
# Step 10: Build Sphinx documentation
- name: Build Sphinx documentation
run: |
source venv/bin/activate || .\venv\Scripts\activate
cd docs
make html
shell: bash

# Step 9: Deploy Documentation to GitHub Pages. set read permissions to contents
# Step 11: Deploy documentation to GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down

0 comments on commit 8662cf1

Please sign in to comment.