Skip to content

Commit

Permalink
adding python env to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
BenJourdan committed Oct 11, 2024
1 parent b7f67fd commit eca21b7
Showing 1 changed file with 18 additions and 292 deletions.
310 changes: 18 additions & 292 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,306 +43,46 @@ jobs:
with:
python-version: 3.x

# Create a virtual environment
# Create and activate virtual environment
- name: Create and activate virtual environment
run: |
python -m venv venv
if [ ${{ runner.os }} == 'Windows' ]; then
.\venv\Scripts\activate
else
source venv/bin/activate
fi
# Install Maturin and build in same session
- name: Install Maturin and build Rust library
run: |
source venv/bin/activate
# Install Maturin to build Rust/Python library
- name: Install Maturin
run: pip install maturin

# Build and install the Rust library using Maturin
- name: Build and install Rust library
run: maturin develop --release

pip install maturin
maturin develop --release
# Install dependencies
- name: Install linters, formatters, test tools, and docs tools
run: |
source venv/bin/activate
pip install ruff black pytest sphinx sphinx-rtd-theme
# Run Ruff for linting and import sorting
- name: Run Ruff (Python linter)
run: ruff check . --fix

# Run Black to ensure code formatting (non-fix mode)
- name: Run Black (Python formatter check)
run: black --check .

# Run Pytest to ensure Python tests pass
- name: Run Python tests with pytest
run: pytest

# Set up Rust toolchain
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

# Run Rust tests
- name: Run Rust tests
run: cargo test

# Build wheels using Maturin
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto

# Upload wheels as artifacts
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

# Build Sphinx Documentation
- name: Build Sphinx Documentation
run: |
cd docs
make html
# Upload Documentation as an Artifact
- name: Upload Documentation
uses: actions/upload-artifact@v4
with:
name: sphinx-docs
path: docs/_build/html/

musllinux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
steps:
- uses: actions/checkout@v4

# Set up Python
- uses: actions/setup-python@v5
with:
python-version: 3.x

# Create a virtual environment
- name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate
# Install Maturin to build Rust/Python library
- name: Install Maturin
run: pip install maturin

# Build and install the Rust library using Maturin
- name: Build and install Rust library
run: maturin develop --release

# Install dependencies
- name: Install linters, formatters, test tools, and docs tools
run: |
pip install ruff black pytest sphinx sphinx-rtd-theme
# Run Ruff for linting and import sorting
- name: Run Ruff (Python linter)
run: ruff check . --fix
ruff check . --fix
# Run Black to ensure code formatting (non-fix mode)
- name: Run Black (Python formatter check)
run: black --check .

# Run Pytest to ensure Python tests pass
- name: Run Python tests with pytest
run: pytest

# Set up Rust toolchain
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

# Run Rust tests
- name: Run Rust tests
run: cargo test

# Build wheels using Maturin
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: musllinux_1_2

# Upload wheels as artifacts
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: dist

# Build Sphinx Documentation
- name: Build Sphinx Documentation
run: |
cd docs
make html
# Upload Documentation as an Artifact
- name: Upload Documentation
uses: actions/upload-artifact@v4
with:
name: sphinx-docs
path: docs/_build/html/

windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4

# Set up Python
- uses: actions/setup-python@v5
with:
python-version: 3.x
architecture: ${{ matrix.platform.target }}

# Create a virtual environment
- name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate
# Install Maturin to build Rust/Python library
- name: Install Maturin
run: pip install maturin

# Build and install the Rust library using Maturin
- name: Build and install Rust library
run: maturin develop --release

# Install dependencies
- name: Install linters, formatters, test tools, and docs tools
run: |
pip install ruff black pytest sphinx sphinx-rtd-theme
# Run Ruff for linting and import sorting
- name: Run Ruff (Python linter)
run: ruff check . --fix

# Run Black to ensure code formatting (non-fix mode)
- name: Run Black (Python formatter check)
run: black --check .
black --check .
# Run Pytest to ensure Python tests pass
- name: Run Python tests with pytest
run: pytest

# Set up Rust toolchain
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

# Run Rust tests
- name: Run Rust tests
run: cargo test

# Build wheels using Maturin
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'

# Upload wheels as artifacts
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

# Build Sphinx Documentation
- name: Build Sphinx Documentation
run: |
cd docs
make html
# Upload Documentation as an Artifact
- name: Upload Documentation
uses: actions/upload-artifact@v4
with:
name: sphinx-docs
path: docs/_build/html/

macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-12
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4

# Set up Python
- uses: actions/setup-python@v5
with:
python-version: 3.x

# Create a virtual environment
- name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate
# Install Maturin to build Rust/Python library
- name: Install Maturin
run: pip install maturin

# Build and install the Rust library using Maturin
- name: Build and install Rust library
run: maturin develop --release

# Install dependencies
- name: Install linters, formatters, test tools, and docs tools
run: |
pip install ruff black pytest sphinx sphinx-rtd-theme
# Run Ruff for linting and import sorting
- name: Run Ruff (Python linter)
run: ruff check . --fix

# Run Black to ensure code formatting (non-fix mode)
- name: Run Black (Python formatter check)
run: black --check .

# Run Pytest to ensure Python tests pass
- name: Run Python tests with pytest
run: pytest
pytest
# Set up Rust toolchain
- name: Set up Rust
Expand All @@ -362,12 +102,13 @@ jobs:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto

# Upload wheels as artifacts
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
name: wheels-linux-${{ matrix.platform.target }}
path: dist

# Build Sphinx Documentation
Expand All @@ -382,18 +123,3 @@ jobs:
with:
name: sphinx-docs
path: docs/_build/html/

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

0 comments on commit eca21b7

Please sign in to comment.