Skip to content

Commit 5ceb763

Browse files
authored
Merge pull request #99 from negz/hatchery
Update to hatch v0.12, which includes new `hatch test` and `hatch fmt` commands
2 parents 33ee9e1 + 59f8ccc commit 5ceb763

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

.github/workflows/ci.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ concurrency:
2727

2828
env:
2929
# Common versions
30-
PYTHON_VERSION: '3.11.5'
30+
PYTHON_VERSION: '3.11'
31+
HATCH_VERSION: '1.12.0'
3132

3233
# The PyPi project version to push. The default is v0.0.0+gitdate-gitsha.
3334
PYPI_VERSION: ${{ inputs.version }}
@@ -45,10 +46,10 @@ jobs:
4546
python-version: ${{ env.PYTHON_VERSION }}
4647

4748
- name: Setup Hatch
48-
run: pipx install hatch==1.7.0
49+
run: pipx install hatch==${{ env.HATCH_VERSION }}
4950

5051
- name: Lint
51-
run: hatch run lint:check
52+
run: hatch fmt
5253

5354
unit-test:
5455
runs-on: ubuntu-22.04
@@ -62,10 +63,10 @@ jobs:
6263
python-version: ${{ env.PYTHON_VERSION }}
6364

6465
- name: Setup Hatch
65-
run: pipx install hatch==1.7.0
66+
run: pipx install hatch==${{ env.HATCH_VERSION }}
6667

6768
- name: Run Unit Tests
68-
run: hatch run test:unit
69+
run: hatch test --all --randomize
6970

7071

7172
build:
@@ -80,7 +81,7 @@ jobs:
8081
python-version: ${{ env.PYTHON_VERSION }}
8182

8283
- name: Setup Hatch
83-
run: pipx install hatch==1.7.0
84+
run: pipx install hatch==${{ env.HATCH_VERSION }}
8485

8586
# If a version wasn't explicitly passed as a workflow_dispatch input we
8687
# default to version v0.0.0+<git-commit-date>-<git-short-sha>, for example
@@ -143,7 +144,7 @@ jobs:
143144
python-version: ${{ env.PYTHON_VERSION }}
144145

145146
- name: Setup Hatch
146-
run: pipx install hatch==1.7.0
147+
run: pipx install hatch==${{ env.HATCH_VERSION }}
147148

148149
- name: Build Documentation
149150
run: hatch run docs:pdoc -d google crossplane/function -o docs

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ Some useful commands:
3434
# Generate gRPC stubs.
3535
hatch run generate:protoc
3636

37-
# Lint the code.
38-
hatch run lint:check
37+
# Format and lint the code.
38+
hatch fmt
3939

4040
# Run unit tests.
41-
hatch run test:unit
41+
hatch test
4242

4343
# Build an sdist and wheel.
4444
hatch build

pyproject.toml

+5-17
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,6 @@ dependencies = ["grpcio-tools==1.66.2"]
4949
[tool.hatch.envs.generate.scripts]
5050
protoc = "python -m grpc_tools.protoc --proto_path=. --python_out=. --pyi_out=. --grpc_python_out=. crossplane/function/proto/v1beta1/run_function.proto crossplane/function/proto/v1/run_function.proto"
5151

52-
[tool.hatch.envs.lint]
53-
type = "virtual"
54-
detached = true
55-
path = ".venv-lint"
56-
dependencies = ["ruff==0.6.9"]
57-
58-
[tool.hatch.envs.lint.scripts]
59-
check = "ruff format crossplane tests && ruff check --fix crossplane tests"
60-
61-
62-
[tool.hatch.envs.test]
63-
type = "virtual"
64-
path = ".venv-test"
65-
66-
[tool.hatch.envs.test.scripts]
67-
unit = "python -m unittest tests/*.py"
68-
6952
[tool.hatch.envs.docs]
7053
type = "virtual"
7154
path = ".venv-docs"
@@ -77,6 +60,11 @@ generate = "pdoc -m google crossplane/function -o docs"
7760
[tool.hatch.build.targets.wheel]
7861
packages = ["crossplane"]
7962

63+
# This special environment is used by hatch fmt.
64+
[tool.hatch.envs.hatch-static-analysis]
65+
dependencies = ["ruff==0.6.9"]
66+
config-path = "none" # Disable Hatch's default Ruff config.
67+
8068
[tool.ruff]
8169
target-version = "py311"
8270
exclude = ["crossplane/function/proto/*", "tests/testdata/*"]

tests/test_resource.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
import crossplane.function.proto.v1.run_function_pb2 as fnv1
2424
from crossplane.function import logging, resource
25-
26-
from .testdata.models.io.upbound.aws.s3 import v1beta2
25+
from tests.testdata.models.io.upbound.aws.s3 import v1beta2
2726

2827

2928
class TestResource(unittest.TestCase):

0 commit comments

Comments
 (0)