Skip to content

Commit

Permalink
Merge pull request #99 from negz/hatchery
Browse files Browse the repository at this point in the history
Update to hatch v0.12, which includes new `hatch test` and `hatch fmt` commands
  • Loading branch information
negz authored Oct 10, 2024
2 parents 33ee9e1 + 59f8ccc commit 5ceb763
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ concurrency:

env:
# Common versions
PYTHON_VERSION: '3.11.5'
PYTHON_VERSION: '3.11'
HATCH_VERSION: '1.12.0'

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

- name: Setup Hatch
run: pipx install hatch==1.7.0
run: pipx install hatch==${{ env.HATCH_VERSION }}

- name: Lint
run: hatch run lint:check
run: hatch fmt

unit-test:
runs-on: ubuntu-22.04
Expand All @@ -62,10 +63,10 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup Hatch
run: pipx install hatch==1.7.0
run: pipx install hatch==${{ env.HATCH_VERSION }}

- name: Run Unit Tests
run: hatch run test:unit
run: hatch test --all --randomize


build:
Expand All @@ -80,7 +81,7 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup Hatch
run: pipx install hatch==1.7.0
run: pipx install hatch==${{ env.HATCH_VERSION }}

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

- name: Setup Hatch
run: pipx install hatch==1.7.0
run: pipx install hatch==${{ env.HATCH_VERSION }}

- name: Build Documentation
run: hatch run docs:pdoc -d google crossplane/function -o docs
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Some useful commands:
# Generate gRPC stubs.
hatch run generate:protoc

# Lint the code.
hatch run lint:check
# Format and lint the code.
hatch fmt

# Run unit tests.
hatch run test:unit
hatch test

# Build an sdist and wheel.
hatch build
Expand Down
22 changes: 5 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ dependencies = ["grpcio-tools==1.66.2"]
[tool.hatch.envs.generate.scripts]
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"

[tool.hatch.envs.lint]
type = "virtual"
detached = true
path = ".venv-lint"
dependencies = ["ruff==0.6.9"]

[tool.hatch.envs.lint.scripts]
check = "ruff format crossplane tests && ruff check --fix crossplane tests"


[tool.hatch.envs.test]
type = "virtual"
path = ".venv-test"

[tool.hatch.envs.test.scripts]
unit = "python -m unittest tests/*.py"

[tool.hatch.envs.docs]
type = "virtual"
path = ".venv-docs"
Expand All @@ -77,6 +60,11 @@ generate = "pdoc -m google crossplane/function -o docs"
[tool.hatch.build.targets.wheel]
packages = ["crossplane"]

# This special environment is used by hatch fmt.
[tool.hatch.envs.hatch-static-analysis]
dependencies = ["ruff==0.6.9"]
config-path = "none" # Disable Hatch's default Ruff config.

[tool.ruff]
target-version = "py311"
exclude = ["crossplane/function/proto/*", "tests/testdata/*"]
Expand Down
3 changes: 1 addition & 2 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

import crossplane.function.proto.v1.run_function_pb2 as fnv1
from crossplane.function import logging, resource

from .testdata.models.io.upbound.aws.s3 import v1beta2
from tests.testdata.models.io.upbound.aws.s3 import v1beta2


class TestResource(unittest.TestCase):
Expand Down

0 comments on commit 5ceb763

Please sign in to comment.