Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: switch to dependency groups #261

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit
# renovate: datasource=pypi;depName=ruff
rev: "v0.9.1"
rev: "v0.9.2"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
38 changes: 17 additions & 21 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,25 @@
# Required
version: 2

submodules:
include:
- docs/sphinx-docs-starter-pack

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: dirhtml
configuration: docs/conf.py
fail_on_warning: true

# If using Sphinx, optionally build your docs in additional formats such as PDF
formats:
- pdf
# Optionally build your docs in additional formats such as PDF
# formats:
# - pdf
# - epub

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/.sphinx/requirements.txt
- method: pip
path: .
build:
os: ubuntu-24.04
tools:
python: "3.12"
jobs:
post_system_dependencies:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --extra docs
50 changes: 34 additions & 16 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ ifneq ($(OS),Windows_NT)
OS := $(shell uname)
endif
ifdef CI
APT := apt-get --yes
APT := apt-get --yes
else
APT := apt-get
endif

PRETTIER=npm exec --package=prettier -- prettier
PRETTIER_FILES=**.yaml **.yml **.json **.json5 **.css **.md

# By default we should not update the uv lock file here.
export UV_FROZEN := true

.DEFAULT_GOAL := help

.ONESHELL:
Expand Down Expand Up @@ -42,25 +48,22 @@ help: ## Show this help.

.PHONY: setup
setup: install-uv setup-precommit ## Set up a development environment
uv sync --frozen --all-extras
uv sync --all-extras

.PHONY: setup-tests
setup-tests: install-uv install-build-deps ##- Set up a testing environment without linters
uv sync --frozen
uv sync

.PHONY: setup-lint
setup-lint: install-uv install-shellcheck install-pyright install-lint-build-deps ##- Set up a linting-only environment
uv sync --frozen --no-install-workspace --extra lint --extra types
uv sync --no-install-workspace --group lint --group types

.PHONY: setup-docs
setup-docs: install-uv ##- Set up a documentation-only environment
uv sync --frozen --no-dev --no-install-workspace --extra docs
uv sync --no-dev --group docs

.PHONY: setup-precommit
setup-precommit: install-uv ##- Set up pre-commit hooks in this repository.
ifeq ($(shell which pre-commit),)
uv tool install pre-commit
endif
ifeq ($(shell which pre-commit),)
uv tool run pre-commit install
else
Expand All @@ -86,6 +89,10 @@ format-ruff: install-ruff ##- Automatically format with ruff
format-codespell: ##- Fix spelling issues with codespell
uv run codespell --toml pyproject.toml --write-changes $(SOURCES)

.PHONY: format-prettier
format-prettier: install-npm ##- Format files with prettier
$(PRETTIER) --write $(PRETTIER_FILES)

.PHONY: lint-ruff
lint-ruff: install-ruff ##- Lint with ruff
ifneq ($(CI),)
Expand All @@ -98,7 +105,7 @@ ifneq ($(CI),)
endif

.PHONY: lint-codespell
lint-codespell: ##- Check spelling with codespell
lint-codespell: install-codespell ##- Check spelling with codespell
ifneq ($(CI),)
@echo ::group::$@
endif
Expand Down Expand Up @@ -141,12 +148,12 @@ ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-yaml
lint-yaml: ##- Lint YAML files with yamllint
.PHONY: lint-prettier
lint-prettier: install-npm ##- Lint files with prettier
ifneq ($(CI),)
@echo ::group::$@
endif
uv run --extra lint yamllint .
$(PRETTIER) --check $(PRETTIER_FILES)
ifneq ($(CI),)
@echo ::endgroup::
endif
Expand All @@ -156,7 +163,7 @@ lint-docs: ##- Lint the documentation
ifneq ($(CI),)
@echo ::group::$@
endif
uv run --extra docs sphinx-lint --max-line-length 88 --enable all $(DOCS)
uv run --group docs sphinx-lint --max-line-length 88 --ignore docs/reference/commands --ignore docs/_build --enable all $(DOCS)
ifneq ($(CI),)
@echo ::endgroup::
endif
Expand Down Expand Up @@ -192,11 +199,11 @@ test-coverage: ## Generate coverage report

.PHONY: docs
docs: ## Build documentation
uv run --extra docs sphinx-build -b html -W $(DOCS) $(DOCS)/_build
uv run --group docs sphinx-build -b html -W $(DOCS) $(DOCS)/_build

.PHONY: docs-auto
docs-auto: ## Build and host docs with sphinx-autobuild
uv run --extra docs sphinx-autobuild -b html --open-browser --port=8080 --watch $(PROJECT) -W $(DOCS) $(DOCS)/_build
uv run --group docs sphinx-autobuild -b html --open-browser --port=8080 --watch $(PROJECT) -W $(DOCS) $(DOCS)/_build

.PHONY: pack-pip
pack-pip: ##- Build packages for pip (sdist, wheel)
Expand Down Expand Up @@ -242,7 +249,7 @@ ifneq ($(shell which pyright),)
else ifneq ($(shell which snap),)
sudo snap install --classic pyright
else
# Workaround for a bug in npm
# Workaround for a bug in npm
[ -d "$(HOME)/.npm/_cacache" ] && chown -R `id -u`:`id -g` "$(HOME)/.npm" || true
uv tool install pyright
endif
Expand All @@ -267,3 +274,14 @@ else ifneq ($(shell which brew),)
else
$(warning Shellcheck not installed. Please install it yourself.)
endif

.PHONY: install-npm
install-npm:
ifneq ($(shell which npm),)
else ifneq ($(shell which snap),)
sudo snap install --classic node
else ifneq ($(shell which brew),)
brew install node
else
$(error npm not installed. Please install it yourself.)
endif
15 changes: 0 additions & 15 deletions docs/.sphinx/requirements.txt

This file was deleted.

49 changes: 24 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ requires-python = ">=3.10"
"Source" = "https://github.com/canonical/craft-store"
"Issues" = "https://github.com/canonical/craft-store/issues"

[project.optional-dependencies]
[dependency-groups]
lint = [
"codespell[toml]~=2.3",
"yamllint~=1.35"
Expand All @@ -55,23 +55,34 @@ docs = [
"lxd-sphinx-extensions==0.0.16",
"myst-parser==4.0.0",
"pyspelling==2.10",
"sphinx==8.1.3",
"sphinx-autobuild==2024.10.3",
"sphinxcontrib-jquery==4.1",
"sphinx-copybutton==0.5.2",
"sphinx-design==0.6.1",
"sphinxext-opengraph==0.9.1",
"sphinx-lint==1.0.0",
"sphinx-notfound-page==1.0.4",
"sphinx-reredirects==0.1.5",
"sphinx-rtd-theme",
"sphinx-tabs==3.4.7",
"sphinx-toolbox>=2.5.0",
"sphinx~=8.1",
"sphinx-autobuild~=2024.10.3",
"sphinxcontrib-jquery~=4.1",
"sphinx-copybutton~=0.5.2",
"sphinx-design~=0.6.1",
"sphinxext-opengraph~=0.9.1",
"sphinx-lint~=1.0",
"sphinx-notfound-page~=1.0",
"sphinx-reredirects~=0.1.5",
"sphinx-tabs~=3.4.7",
"sphinx-toolbox~=3.8",
]
release = [
"twine",
"wheel",
]
dev-dependencies = [
"build",
"pyyaml~=6.0",
"coverage[toml]~=7.6",
"pytest~=8.3",
"pytest-cov~=5.0",
"pytest-mock~=3.14",
"pytest-check~=2.4",
"pytest-subprocess~=1.5",
"pytest-timeout~=2.0",
"pytest-httpx~=0.35",
]

[tool.uv]
constraint-dependencies = [
Expand All @@ -98,18 +109,6 @@ constraint-dependencies = [
"webencodings>=0.4.0",
"wheel>=0.38",
]
dev-dependencies = [
"build",
"pyyaml>=6.0.0",
"coverage[toml]==7.6.2",
"pytest==8.3.3",
"pytest-cov==5.0.0",
"pytest-mock==3.14.0",
"pytest-check>=2.4",
"pytest-subprocess>=1.5",
"pytest-timeout>=2.0",
"pytest-httpx>=0.35",
]

[build-system]
requires = [
Expand Down
Loading
Loading