Skip to content

Commit 3700f52

Browse files
Update dev workflow to use Pixi (#282)
* Add pixi.toml configuration for environment management - Define workspace with VirtualShip name and pixi-build preview - Configure multiple test environments (py310, py311, py312) - Set up feature environments for docs, typing, and pre-commit - Define pixi tasks for tests, docs, linting, and type checking - Align dependencies with existing pyproject.toml * Update CI workflows to use Pixi - Replace mamba-org/setup-micromamba with prefix-dev/setup-pixi - Update test job to use pixi environments (test-py310, test-py312) - Update typechecking job to use pixi run typing - Enable pixi caching for faster CI runs - Simplify workflow by removing manual dependency installation * Update contributing guidelines for Pixi - Replace Conda-based development setup with Pixi - Add comprehensive Pixi workflows section with examples - Document testing, docs, and code quality commands - Include tips for environment management and CI reproduction - Update dependency management instructions to reference pixi.toml * Add Pixi badge to README Add Pixi badge to indicate project uses Pixi for environment management * Remove environment.yml Environment management is now handled by pixi.toml. The environment.yml file is no longer needed as all dependencies are defined in pixi.toml. * Add virtualship source dependency * Move pytest args to CI call * Update RTD config * Add caching of Pixi lock * Pixi git files * Remove license = key in pixi.toml no longer needed since issue is resolved * Update pixi-build-python backend version * Update workflow to external pixi lock action * Update default environment for Pixi * Refactor pixi manifest to use run-dependencies * Move environment definitions to the end of the file
1 parent e689559 commit 3700f52

File tree

8 files changed

+223
-112
lines changed

8 files changed

+223
-112
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SCM syntax highlighting & preventing 3-way merges
2+
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff

.github/workflows/ci.yml

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,78 @@ env:
1919
# Many color libraries just need this to be set to any value, but at least
2020
# one distinguishes color depth, where "3" -> "256-bit color".
2121
FORCE_COLOR: 3
22+
PIXI_VERSION: "v0.63.2"
2223

2324
jobs:
25+
cache-pixi-lock:
26+
runs-on: ubuntu-slim
27+
outputs:
28+
cache-key: ${{ steps.pixi-lock.outputs.cache-key }}
29+
pixi-version: ${{ steps.pixi-lock.outputs.pixi-version }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: Parcels-code/pixi-lock/create-and-cache@9a2866f8258b87a3c616d5ad7d51c6cd853df78b
33+
id: pixi-lock
34+
with:
35+
pixi-version: ${{env.PIXI_VERSION}}
36+
- uses: actions/upload-artifact@v6 # make available as an artifact for local testing
37+
with:
38+
name: pixi-lock
39+
path: pixi.lock
40+
2441
tests:
25-
name: tests (${{ matrix.runs-on }} | Python ${{ matrix.python-version }})
42+
name: "Unit tests: ${{ matrix.runs-on }} | pixi run -e ${{ matrix.pixi-environment }} tests"
2643
runs-on: ${{ matrix.runs-on }}
44+
needs: cache-pixi-lock
2745
strategy:
2846
fail-fast: false
2947
matrix:
30-
python-version: ["3.10", "3.12"]
48+
pixi-environment: ["test-py310", "test-py312"]
3149
runs-on: [ubuntu-latest, windows-latest, macos-14]
32-
3350
steps:
3451
- uses: actions/checkout@v6
3552
with:
3653
fetch-depth: 0
37-
- uses: mamba-org/setup-micromamba@v2
54+
- uses: Parcels-code/pixi-lock/restore@9a2866f8258b87a3c616d5ad7d51c6cd853df78b
3855
with:
39-
environment-name: ship
40-
environment-file: environment.yml
41-
create-args: >-
42-
python=${{matrix.python-version}}
43-
44-
- run: pip install . --no-deps
56+
cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
57+
- uses: prefix-dev/setup-pixi@v0.9.4
58+
with:
59+
cache: true
60+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
61+
pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
4562

4663
- name: Test package
47-
run: >-
48-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
64+
run:
65+
pixi run -e ${{ matrix.pixi-environment }} tests -ra --cov --cov-report=xml --cov-report=term
4966
--durations=20
5067

5168
- name: Upload coverage report
5269
uses: codecov/codecov-action@v5.5.2
5370
with:
5471
token: ${{ secrets.CODECOV_TOKEN }}
55-
# typechecking:
56-
# name: mypy
57-
# runs-on: ubuntu-latest
58-
# steps:
59-
# - uses: actions/checkout@v6
60-
# with:
61-
# fetch-depth: 0
62-
# - uses: mamba-org/setup-micromamba@v2
63-
# with:
64-
# environment-name: ship
65-
# environment-file: environment.yml
66-
# create-args: >-
67-
# python=3.12
68-
69-
# - run: pip install . --no-deps
70-
# - run: conda install lxml # dep for report generation
71-
# - name: Typechecking
72-
# run: |
73-
# mypy --install-types --non-interactive src/virtualship --html-report mypy-report
74-
# - name: Upload test results
75-
# if: ${{ always() }} # Upload even on mypy error
76-
# uses: actions/upload-artifact@v4
77-
# with:
78-
# name: Mypy report
79-
# path: mypy-report
72+
# typechecking:
73+
# name: "TypeChecking: pixi run typing"
74+
# runs-on: ubuntu-latest
75+
# if: false
76+
# needs: cache-pixi-lock
77+
# steps:
78+
# - uses: actions/checkout@v4
79+
# with:
80+
# fetch-depth: 0
81+
# - uses: Parcels-code/pixi-lock/restore@9a2866f8258b87a3c616d5ad7d51c6cd853df78b
82+
# with:
83+
# cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
84+
# - uses: prefix-dev/setup-pixi@v0.9.4
85+
# with:
86+
# cache: true
87+
# pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
88+
# cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
89+
# - name: Typechecking
90+
# run: pixi run typing --non-interactive --html-report mypy-report
91+
# - name: Upload test results
92+
# if: ${{ always() }} # Upload even on mypy error
93+
# uses: actions/upload-artifact@v4
94+
# with:
95+
# name: Mypy report
96+
# path: mypy-report

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# pixi environments
2+
.pixi/*
3+
!.pixi/config.toml
4+
5+
16
# Byte-compiled / optimized / DLL files
27
__pycache__/
38
*.py[cod]

.readthedocs.yaml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
# Read the Docs configuration file
2-
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3-
41
version: 2
5-
sphinx:
6-
configuration: docs/conf.py
72
build:
8-
os: ubuntu-22.04
3+
os: ubuntu-lts-latest
94
tools:
10-
python: mambaforge-22.9
5+
python: "latest" # just so RTD stops complaining
116
jobs:
12-
pre_build:
13-
- pip install .
14-
- sphinx-build -b linkcheck docs/ _build/linkcheck
15-
- sphinx-apidoc -o docs/api/ --module-first --no-toc --force src/virtualship
16-
17-
conda:
18-
environment: environment.yml
7+
create_environment:
8+
- asdf plugin add pixi
9+
- asdf install pixi latest
10+
- asdf global pixi latest
11+
install:
12+
- pixi install -e docs
13+
build:
14+
html:
15+
- pixi run -e docs sphinx-build -T -b html docs $READTHEDOCS_OUTPUT/html
16+
sphinx:
17+
configuration: docs/conf.py

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<!-- Badges -->
99

10+
[![Pixi Badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json)](https://pixi.sh)
1011
[![Anaconda-release](https://anaconda.org/conda-forge/virtualship/badges/version.svg)](https://anaconda.org/conda-forge/virtualship/)
1112
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/virtualship)
1213
[![DOI](https://zenodo.org/badge/682478059.svg)](https://doi.org/10.5281/zenodo.14013931)

docs/contributing/index.md

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,66 @@ We have a design document providing a conceptual overview of VirtualShip. This d
88

99
### Development installation
1010

11-
We use `conda` to manage our development installation. Make sure you have `conda` installed by following [the instructions here](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) and then run the following commands:
11+
```{note}
12+
VirtualShip uses [Pixi](https://pixi.sh) to manage environments and run developer tooling. Pixi is a modern alternative to Conda and also includes other powerful tooling useful for a project like VirtualShip. It is our sole development workflow - we do not offer a Conda development workflow. Give Pixi a try, you won't regret it!
13+
```
14+
15+
To get started contributing to VirtualShip:
16+
17+
**Step 1:** [Install Pixi](https://pixi.sh/latest/).
18+
19+
**Step 2:** [Fork the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository)
20+
21+
**Step 3:** Clone your fork and `cd` into the repository.
22+
23+
**Step 4:** Install the Pixi environment
1224

1325
```bash
14-
conda create -n ship python=3.10
15-
conda activate ship
16-
conda env update --file environment.yml
17-
pip install -e . --no-deps --no-build-isolation
26+
pixi install
1827
```
1928

20-
This creates an environment, and installs all the dependencies that you need for development, including:
29+
Now you have a development installation of VirtualShip, as well as a bunch of developer tooling to run tests, check code quality, and build the documentation! Simple as that.
30+
31+
### Pixi workflows
32+
33+
You can use the following Pixi commands to run common development tasks.
2134

22-
- core dependencies
23-
- development dependencies (e.g., for testing)
24-
- documentation dependencies
35+
**Testing**
2536

26-
then installs the package in editable mode.
37+
- `pixi run tests` - Run the full test suite using pytest with coverage reporting
38+
- `pixi run tests-notebooks` - Run notebook tests
2739

28-
### Useful commands
40+
**Documentation**
2941

30-
The following commands are useful for local development:
42+
- `pixi run docs` - Build the documentation using Sphinx
43+
- `pixi run docs-watch` - Build and auto-rebuild documentation when files change (useful for live editing)
3144

32-
- `pytest` to run tests
33-
- `pre-commit run --all-files` to run pre-commit checks
34-
- `pre-commit install` (optional) to install pre-commit hooks
35-
- this means that every time you commit, pre-commit checks will run on the files you changed
36-
- `sphinx-autobuild docs docs/_build` to build and serve the documentation
37-
- `sphinx-apidoc -o docs/api/ --module-first --no-toc --force src/virtualship` (optional) to generate the API documentation
38-
- `sphinx-build -b linkcheck docs/ _build/linkcheck` to check for broken links in the documentation
45+
**Code quality**
3946

40-
The running of these commands is useful for local development and quick iteration, but not _vital_ as they will be run automatically in the CI pipeline (`pre-commit` by pre-commit.ci, `pytest` by GitHub Actions, and `sphinx` by ReadTheDocs).
47+
- `pixi run lint` - Run pre-commit hooks on all files (includes formatting, linting, and other code quality checks)
48+
- `pixi run typing` - Run mypy type checking on the codebase
49+
50+
**Different environments**
51+
52+
VirtualShip supports testing against different environments (e.g., different Python versions) with different feature sets. In CI we test against these environments, and you can too locally. For example:
53+
54+
- `pixi run -e test-py310 tests` - Run tests using Python 3.10
55+
- `pixi run -e test-py311 tests` - Run tests using Python 3.11
56+
- `pixi run -e test-py312 tests` - Run tests using Python 3.12
57+
58+
The name of the workflow on GitHub contains the command you have to run locally to recreate the workflow - making it super easy to reproduce CI failures locally.
59+
60+
**Typical development workflow**
61+
62+
1. Make your code changes
63+
2. Run `pixi run lint` to ensure code formatting and style compliance
64+
3. Run `pixi run tests` to verify your changes don't break existing functionality
65+
4. If you've added new features, run `pixi run typing` to check type annotations
66+
5. If you've modified documentation, run `pixi run docs` to build and verify the docs
67+
68+
```{tip}
69+
You can run `pixi info` to see all available environments and `pixi task list` to see all available tasks across environments.
70+
```
4171

4272
## For maintainers
4373

@@ -52,5 +82,5 @@ The running of these commands is useful for local development and quick iteratio
5282

5383
When adding a dependency, make sure to modify the following files where relevant:
5484

55-
- `environment.yml` for core and development dependencies (important for the development environment, and CI)
85+
- `pixi.toml` for core and development dependencies (important for the development environment, and CI)
5686
- `pyproject.toml` for core dependencies (important for the pypi package, this should propagate through automatically to `recipe/meta.yml` in the conda-forge feedstock)

environment.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)