Skip to content

Commit

Permalink
DX: modernize dev environment with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Oct 18, 2024
1 parent 5b1c0cd commit 2cf2782
Show file tree
Hide file tree
Showing 23 changed files with 184 additions and 273 deletions.
1 change: 1 addition & 0 deletions .binder/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graphviz
8 changes: 8 additions & 0 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
uv pip install \
--editable '.[jupyter]' \
--no-cache \
--system
1 change: 1 addition & 0 deletions .binder/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.12
4 changes: 1 addition & 3 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"*.svg",
".editorconfig",
".envrc",
".gitattributes",
".gitignore",
".pre-commit-config.yaml",
".prettierignore",
Expand All @@ -36,8 +35,7 @@
"CITATION.cff",
"docs/adr/*/*",
"docs/conf.py",
"pyproject.toml",
"tox.ini"
"pyproject.toml"
],
"language": "en-US",
"words": [
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ indent_size = 4

[LICENSE]
indent_size = unset

[uv.lock]
indent_size = 4
12 changes: 2 additions & 10 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
if [ -e .venv ]; then
source .venv/bin/activate
elif [ -e venv ]; then
source venv/bin/activate
elif [ -e .pixi ]; then
watch_file pixi.lock
eval "$(pixi shell-hook)"
else
layout anaconda
fi
uv sync --all-extras --quiet
source .venv/bin/activate
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
jobs:
milestone:
if: startsWith(github.ref, 'refs/tags')
uses: ComPWA/actions/.github/workflows/close-milestone.yml@v1
uses: ComPWA/actions/.github/workflows/close-milestone.yml@v2
push:
if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease
secrets: inherit
uses: ComPWA/actions/.github/workflows/push-to-version-branches.yml@v1
uses: ComPWA/actions/.github/workflows/push-to-version-branches.yml@v2
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ on:

jobs:
doc:
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v1
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2
permissions:
pages: write
id-token: write
with:
apt-packages: graphviz
gh-pages: true
python-version: "3.12"
specific-pip-packages: ${{ inputs.specific-pip-packages }}
style:
if: inputs.specific-pip-packages == ''
secrets:
token: ${{ secrets.PAT }}
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v1
with:
python-version: "3.12"
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2
4 changes: 2 additions & 2 deletions .github/workflows/clean-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ on:
jobs:
cleanup:
name: Remove caches
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: ComPWA/actions/clean-caches@v1
- uses: ComPWA/actions/clean-caches@v2
with:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ inputs.ref }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Requirements
name: Update

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -12,12 +12,10 @@ on:
- epic/*
paths:
- .pre-commit-config.yaml
schedule:
- cron: "0 3 7 */2 *"
workflow_dispatch:

jobs:
requirements:
uses: ComPWA/actions/.github/workflows/requirements.yml@v1
lock:
uses: ComPWA/actions/.github/workflows/lock.yml@v2
secrets:
token: ${{ secrets.PAT }}
2 changes: 1 addition & 1 deletion .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ on:

jobs:
lint-pr:
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v1
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v2
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
update_release_draft:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: release-drafter/release-drafter@v6
env:
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ version.py

# Temporary files
*.pyc
*condaenv.*
.coverage
.coverage.*
.ipynb_checkpoints/
Expand All @@ -36,9 +35,9 @@ prof/

# Virtual environments
*venv/
.pixi/
.tox/
pyvenv*/
uv.lock

# Settings
.idea/
Expand All @@ -53,6 +52,5 @@ pyvenv*/
!.vscode/*.json
!.zenodo.json
!codecov.yml
!environment.yml
!pyrightconfig.json
.jupyter_ystore.db
17 changes: 8 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ci:
autoupdate_commit_msg: "MAINT: autoupdate pre-commit hooks"
autoupdate_commit_msg: "MAINT: update lock files"
autoupdate_schedule: quarterly
skip:
- check-jsonschema
Expand All @@ -12,14 +12,13 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.4.1
rev: 0.5.0rc10
hooks:
- id: check-dev-files
args:
- --doc-apt-packages=graphviz
- --dev-python-version=3.12
- --github-pages
- --no-prettierrc
- --no-pypi
- --repo-name=compwa.github.io
- --repo-title=ComPWA Organization
Expand Down Expand Up @@ -56,7 +55,7 @@ repos:
metadata.vscode
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.7.0
hooks:
- id: ruff
args: [--fix]
Expand All @@ -65,7 +64,7 @@ repos:
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand Down Expand Up @@ -106,7 +105,7 @@ repos:
args: [--in-place]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.2
rev: 0.29.4
hooks:
- id: check-jsonschema
name: Check CITATION.cff
Expand All @@ -119,7 +118,7 @@ repos:
pass_filenames: false

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.13.3
rev: v8.15.1
hooks:
- id: cspell

Expand All @@ -144,7 +143,7 @@ repos:
docs/_static/favicon.ico
)$
- repo: https://github.com/ComPWA/mirrors-pyright
rev: v1.1.379
- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.385
hooks:
- id: pyright
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
30 changes: 15 additions & 15 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
version: 2

sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: true

formats:
- htmlzip

build:
os: ubuntu-22.04
apt_packages:
- graphviz
os: ubuntu-24.04
tools:
python: "3.12"
jobs:
post_install:
- python -m pip install 'uv>=0.2.0'
- python -m uv pip install -e .[doc]
commands:
- |-
export PIXI_HOME=$READTHEDOCS_VIRTUALENV_PATH
curl -fsSL https://pixi.sh/install.sh | bash
pixi global install graphviz uv
- |-
export UV_LINK_MODE=copy
uv run \
--extra doc \
--locked \
--with tox \
tox -e doc
mkdir -p $READTHEDOCS_OUTPUT
mv docs/_build/html $READTHEDOCS_OUTPUT
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
"\u03bd": true,
"\u03c3": true
},
"files.associations": {
"**/pixi.lock": "yaml"
},
"files.watcherExclude": {
"**/*_cache/**": true,
"**/.eggs/**": true,
Expand Down Expand Up @@ -63,6 +60,9 @@
"ruff.enable": true,
"ruff.importStrategy": "fromEnvironment",
"ruff.organizeImports": true,
"search.exclude": {
"**/uv.lock": true
},
"telemetry.telemetryLevel": "off",
"yaml.schemas": {
"https://citation-file-format.github.io/1.2.0/schema.json": "CITATION.cff",
Expand Down
25 changes: 23 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# How to contribute?

[![Open in Visual Studio Code](https://img.shields.io/badge/vscode-open-blue?logo=visualstudiocode)](https://open.vscode.dev/ComPWA/compwa.github.io)
[![Open in Visual Studio Code](https://img.shields.io/badge/vscode-open-blue?logo=visualstudiocode)](https://github.dev/ComPWA/compwa.github.io)

This repository is part of the [ComPWA Organization](https://github.com/ComPWA). For more information about how to contribute to the packages, go to **[compwa.github.io/develop](https://compwa.github.io/develop)**!
> [!TIP]
> This package is part of the [ComPWA Organization](https://github.com/ComPWA). For more information about how to contribute to the packages, go to **[compwa.github.io/develop](https://compwa.github.io/develop)**!
To contribute to the project, you need to install the package in a virtual environment. This can be done best with [`uv`](https://docs.astral.sh/uv) (see installation instructions [here](https://docs.astral.sh/uv/getting-started/installation)). For this, you first need to get the source code with [Git](https://git-scm.com):

```shell
git clone https://github.com/ComPWA/compwa.github.io
cd compwa.github.io
```

Now it's simply a matter of creating and activating the [virtual environment](https://docs.astral.sh/uv/pip/environments) with [`uv sync`](https://docs.astral.sh/uv/reference/cli/#uv-sync). The dependencies for the project are 'pinned' in each commit through the [`uv.lock` file](https://docs.astral.sh/uv/concepts/projects/#project-lockfile).

```shell
uv sync
source .venv/bin/activate
```

Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:

```shell
pre-commit install --install-hooks
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
[![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)

This repository contains the source code for the [compwa.github.io](https://compwa.github.io) pages.
11 changes: 0 additions & 11 deletions environment.yml

This file was deleted.

Loading

0 comments on commit 2cf2782

Please sign in to comment.