Skip to content

Commit 38ca36d

Browse files
committed
Set up uv for dependency management and add PR preview workflow
1 parent feeeb5b commit 38ca36d

File tree

4 files changed

+2461
-8
lines changed

4 files changed

+2461
-8
lines changed

.github/workflows/gh-pages.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v4
2525

26-
# Install dependencies
27-
- name: Set up Python 3.11
28-
uses: actions/setup-python@v5
26+
# Install uv for faster dependency management
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v4
2929
with:
30-
python-version: '3.11'
31-
cache: pip # Implicitly uses requirements.txt for cache key
30+
enable-cache: true
3231

32+
# Set up Python using uv
33+
- name: Set up Python
34+
run: uv python install 3.11
35+
36+
# Install dependencies using uv
3337
- name: Install dependencies
34-
run: pip install -r requirements.txt
38+
run: uv sync
3539

3640
# (optional) Cache your executed notebooks between runs
3741
# if you have config:
@@ -41,12 +45,12 @@ jobs:
4145
uses: actions/cache@v4
4246
with:
4347
path: _build/.jupyter_cache
44-
key: jupyter-book-cache-${{ hashFiles('requirements.txt') }}
48+
key: jupyter-book-cache-${{ hashFiles('uv.lock') }}
4549

4650
# Build the book
4751
- name: Build the book
4852
run: |
49-
jupyter-book build .
53+
uv run jupyter-book build .
5054
5155
# Upload the book's HTML as an artifact
5256
- name: Upload artifact

.github/workflows/pr-preview.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: PR Preview
2+
3+
# Build the book on pull requests for preview
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
- master
9+
10+
jobs:
11+
build-preview:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
# Install uv for faster dependency management
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v4
19+
with:
20+
enable-cache: true
21+
22+
# Set up Python using uv
23+
- name: Set up Python
24+
run: uv python install 3.11
25+
26+
# Install dependencies using uv
27+
- name: Install dependencies
28+
run: uv sync
29+
30+
# Cache executed notebooks between runs
31+
- name: Cache executed notebooks
32+
uses: actions/cache@v4
33+
with:
34+
path: _build/.jupyter_cache
35+
key: jupyter-book-cache-${{ hashFiles('uv.lock') }}
36+
37+
# Build the book
38+
- name: Build the book
39+
run: |
40+
uv run jupyter-book build .
41+
42+
# Upload the book's HTML as an artifact
43+
- name: Upload book artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: book-html-${{ github.event.pull_request.number }}
47+
path: "_build/html"
48+
retention-days: 7
49+
50+
# Post comment with artifact link
51+
- name: Comment PR
52+
uses: actions/github-script@v7
53+
if: github.event_name == 'pull_request'
54+
with:
55+
script: |
56+
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
57+
github.rest.issues.createComment({
58+
issue_number: context.issue.number,
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
body: `📚 Book preview build completed! [Download the artifact](${artifactUrl}) to view the HTML locally.`
62+
})

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[project]
2+
name = "xarray-for-biology"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = [
8+
"flox>=0.10.6",
9+
"jupyter-book>=1.0.4.post1",
10+
"jupyterlab>=4.4.7",
11+
"matplotlib>=3.10.6",
12+
"numpy>=2.3.2",
13+
"xarray>=2025.8.0",
14+
]

0 commit comments

Comments
 (0)