Skip to content

Commit 879d7f3

Browse files
authored
Merge pull request #36 from EO-DataHub/migrate-to-uv
Migrate to uv with modern QA tooling
2 parents 8148c5a + 784af77 commit 879d7f3

File tree

12 files changed

+511
-757
lines changed

12 files changed

+511
-757
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ htmlcov
2727
Makefile
2828
.pre-commit-config.yaml
2929
CHANGELOG.md
30-
README.md
3130

3231
# IDE and editor files
3332
.vscode

.github/workflows/actions.yaml

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: All checks
22
on:
3-
workflow_call:
43
push:
54
tags:
65
- 'v[0-9]+'
@@ -11,22 +10,11 @@ on:
1110
- 'v[0-9]+.[0-9]+.[0-9]+-*'
1211
branches:
1312
- '**'
13+
pull_request: ~
1414

1515
jobs:
16-
pre-commit-preparation:
17-
name: Pre-commit
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: actions/checkout@v3
21-
- uses: actions/setup-python@v3
22-
23-
- name: Copy config
24-
run: |
25-
if [ ! -f .pre-commit-config.yaml ]; then
26-
curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/EO-DataHub/github-actions/main/.pre-commit-config-python.yaml
27-
fi
28-
29-
- uses: pre-commit/action@v3.0.1
16+
qa:
17+
uses: EO-DataHub/github-actions/.github/workflows/qa-python.yaml@main
3018

3119
security-scan:
3220
name: Call Security Scan
@@ -36,25 +24,11 @@ jobs:
3624
name: Run unit tests
3725
uses: EO-DataHub/github-actions/.github/workflows/unit-tests-python-uv.yaml@main
3826

39-
get-tag-name:
40-
runs-on: ubuntu-latest
41-
outputs:
42-
image_tag: ${{ steps.get-image-tag.outputs.IMAGE_TAG }}
43-
steps:
44-
- name: Get image tag
45-
id: get-image-tag
46-
run: |
47-
IMAGE_TAG=$(if [[ "${GITHUB_REF##refs/tags/}" =~ ^v ]]; then echo ${GITHUB_REF##refs/tags/v}; elif [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then echo "latest"; else echo "${GITHUB_REF##refs/heads/}-latest" | sed "s/[^a-zA-Z0-9]/-/g" ; fi) >> "$GITHUB_ENV"
48-
echo $IMAGE_TAG
49-
echo "IMAGE_TAG=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
50-
5127
publish:
5228
name: Build and push Docker image
53-
needs: [get-tag-name]
5429
uses: EO-DataHub/github-actions/.github/workflows/ecr-publish.yaml@main
5530
with:
5631
image_name: ${{ vars.IMAGE_NAME }}
57-
image_tag: ${{ needs.get-tag-name.outputs.image_tag }}
5832
aws_role_arn: ${{ vars.AWS_ROLE_ARN }}
5933
aws_ecr_alias: ${{ vars.AWS_ECR_ALIAS }}
6034
permissions:

Makefile

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
1-
.PHONY: dockerbuild dockerpush test testonce ruff black lint isort pre-commit-check requirements-update requirements setup
21
VERSION ?= latest
32
IMAGENAME = resource-catalogue-fastapi
43
DOCKERREPO ?= public.ecr.aws/eodh
54
uv-run ?= uv run --no-sync
65

6+
.PHONY: dockerbuild
77
dockerbuild:
88
DOCKER_BUILDKIT=1 docker build -t ${IMAGENAME}:${VERSION} .
99

10+
.PHONY: dockerpush
1011
dockerpush: dockerbuild
1112
docker tag ${IMAGENAME}:${VERSION} ${DOCKERREPO}/${IMAGENAME}:${VERSION}
1213
docker push ${DOCKERREPO}/${IMAGENAME}:${VERSION}
1314

15+
.PHONY: test
1416
test:
15-
${uv-run} ptw resource_catalogue_fastapi
17+
${uv-run} ptw .
1618

19+
.PHONY: testonce
1720
testonce:
1821
${uv-run} pytest
1922

20-
ruff:
21-
${uv-run} ruff check .
23+
.git/hooks/pre-commit:
24+
${uv-run} pre-commit install
25+
curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/EO-DataHub/github-actions/main/.pre-commit-config-python.yaml
2226

23-
black:
24-
${uv-run} black .
27+
.PHONY: setup
28+
setup: update .git/hooks/pre-commit
2529

26-
isort:
27-
${uv-run} isort . --profile black
30+
.PHONY: pre-commit
31+
pre-commit:
32+
${uv-run} pre-commit
2833

29-
validate-pyproject:
30-
${uv-run} validate-pyproject pyproject.toml
34+
.PHONY: pre-commit-all
35+
pre-commit-all:
36+
${uv-run} pre-commit run --all-files
3137

32-
lint: ruff black isort validate-pyproject
38+
.PHONY: check
39+
check:
40+
${uv-run} ruff check
41+
${uv-run} ruff format --check --diff
42+
${uv-run} pyright
43+
${uv-run} validate-pyproject pyproject.toml
3344

34-
uv-sync:
35-
${uv-run} sync --frozen
45+
.PHONY: format
46+
format:
47+
${uv-run} ruff check --fix
48+
${uv-run} ruff format
3649

37-
.git/hooks/pre-commit:
38-
${uv-run} pre-commit install
39-
curl -o .pre-commit-config.yaml https://raw.githubusercontent.com/EO-DataHub/github-actions/main/.pre-commit-config-python.yaml
50+
.PHONY: install
51+
install:
52+
uv sync --frozen
4053

41-
setup: uv-sync .git/hooks/pre-commit
54+
.PHONY: update
55+
update:
56+
uv sync

pyproject.toml

Lines changed: 39 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -24,55 +24,26 @@
2424

2525
[project]
2626
name = "resource-catalogue-fastapi"
27-
dynamic = ["version"]
27+
version = "0.0.0"
2828
description = "A FastApi deployment to handle requests to update the resource catalogue"
2929
readme = "README.md"
30-
31-
# Our target version is Python 3.13.
3230
requires-python = ">=3.13,<3.14"
33-
3431
license = {file = "LICENSE"}
35-
36-
# This should be your name or the name of the organization who originally
37-
# authored the project, and a valid email address corresponding to the name
38-
# listed.
3932
authors = [
4033
{name = "Telespazio UK Ltd", email = "alex.palmer@telespazio.com" }
4134
]
42-
4335
maintainers = [
4436
{name = "Telespazio UK Ltd", email = "alex.palmer@telespazio.com" }
4537
]
46-
47-
# Classifiers help users find your project by categorizing it.
48-
#
49-
# For a list of valid classifiers, see https://pypi.org/classifiers/
5038
classifiers = [
51-
# How mature is this project? Common values are
52-
# 3 - Alpha
53-
# 4 - Beta
54-
# 5 - Production/Stable
5539
"Development Status :: 3 - Alpha",
56-
57-
# Indicate who your project is intended for
5840
"Intended Audience :: Science/Research",
5941
"Intended Audience :: Developers",
60-
61-
# CHANGEME Pick your license as you wish
6242
"License :: OSI Approved :: Apache Software License",
63-
# "License :: Other/Proprietary License",
64-
6543
"Programming Language :: Python :: 3",
66-
"Programming Language :: Python :: 3.11",
44+
"Programming Language :: Python :: 3.13",
6745
"Programming Language :: Python :: 3 :: Only",
6846
]
69-
70-
# This field lists other packages that your project depends on to run.
71-
# Any package you put here will be installed by pip when your project is
72-
# installed, so they must be valid existing projects.
73-
#
74-
# For an analysis of this field vs pip's requirements files see:
75-
# https://packaging.python.org/discussions/install-requires-vs-requirements/
7647
dependencies = [
7748
"fastapi",
7849
"uvicorn",
@@ -86,95 +57,61 @@ dependencies = [
8657
"kubernetes",
8758
]
8859

89-
[dependency-groups] # Optional
60+
[dependency-groups]
9061
dev = [
62+
"pre-commit",
63+
"pyright",
9164
"pytest",
92-
"pytest-xdist",
9365
"pytest-mock",
9466
"pytest-watcher",
95-
"black",
67+
"pytest-xdist",
9668
"ruff",
97-
"isort",
98-
"pre-commit",
69+
"validate-pyproject",
9970
"httpx",
10071
"requests-mock",
101-
"validate-pyproject>=0.24.1",
10272
]
10373

10474
[tool.uv]
105-
constraint-dependencies = ["urllib3>=2.6.0"]
75+
package = true
10676

107-
# List URLs that are relevant to your project
108-
#
109-
# This field corresponds to the "Project-URL" and "Home-Page" metadata fields:
110-
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
111-
# https://packaging.python.org/specifications/core-metadata/#home-page-optional
112-
#
113-
# Examples listed include a pattern for specifying where the package tracks
114-
# issues, where the source is hosted, where to say thanks to the package
115-
# maintainers, and where to support the project financially. The key is
116-
# what's used to render the link text on PyPI.
117-
[project.urls] # Optional
118-
homepage = "https://github.com/UKEODHP/"
119-
repository = "CHANGEME-https://github.com/UKEODHP/..."
120-
changelog = "CHANGEME-https://github.com/UKEODHP/.../master/CHANGELOG.md"
77+
[project.urls]
78+
homepage = "https://github.com/EO-DataHub/resource-catalogue-fastapi"
79+
repository = "https://github.com/EO-DataHub/resource-catalogue-fastapi"
12180

12281
[build-system]
123-
# These are the assumed default build requirements from pip:
124-
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
125-
requires = ["setuptools>=69.0.0", "wheel", "setuptools-git-versioning>=2.0,<3"]
126-
build-backend = "setuptools.build_meta"
82+
requires = ["hatchling"]
83+
build-backend = "hatchling.build"
12784

12885
[tool.pytest.ini_options]
129-
pythonpath = ["."]
86+
addopts = ["--import-mode=importlib"]
13087
markers = [
13188
"integrationtest: Integration test"
13289
]
13390

134-
[tool.setuptools]
135-
packages = []
136-
137-
[tool.setuptools-git-versioning]
138-
enabled = true
139-
140-
[tool.black]
141-
line-length = 100
142-
target-version = ['py311']
143-
14491
[tool.ruff]
145-
line-length = 110
146-
target-version = "py311"
147-
select = ["E", "F", "B", "W"]
148-
149-
exclude = [
150-
".bzr",
151-
".direnv",
152-
".eggs",
153-
".git",
154-
".git-rewrite",
155-
".hg",
156-
".mypy_cache",
157-
".nox",
158-
".pants.d",
159-
".pytype",
160-
".ruff_cache",
161-
".svn",
162-
".tox",
163-
".venv",
164-
"__pypackages__",
165-
"_build",
166-
"buck-out",
167-
"build",
168-
"dist",
169-
"node_modules",
170-
"venv",
92+
line-length = 119
93+
94+
[tool.ruff.lint]
95+
select = [
96+
"E", # Pycodestyle errors
97+
"W", # Pycodestyle warnings
98+
"F", # Pyflakes
99+
"I", # isort
100+
"FAST", # FastAPI
101+
"RUF", # RUF-specific rules
102+
"SIM", # Simplifications
103+
"B", # Bugbear
104+
"ANN", # Annotations
105+
"PLC", # Pylint convention
106+
"PLE", # Pylint errors
107+
"UP", # pyupgrade
108+
"FURB", # refurb
109+
"PT", # pytest
110+
]
111+
ignore = [
112+
"E501", # line too long
113+
"SIM108", # ternary operator
114+
"SIM103", # return bool directly
115+
"B008", # function call in default argument (incompatible with FastAPI)
116+
"ANN401", # dynamically typed Any (needed for FastAPI Depends)
171117
]
172-
173-
[tool.pylint.'MESSAGES CONTROL']
174-
disable = '''
175-
line-too-long,
176-
missing-class-docstring,
177-
too-many-locals,
178-
too-many-instance-attributes,
179-
logging-fstring-interpolation,
180-
'''

0 commit comments

Comments
 (0)