Skip to content

Commit

Permalink
Use latest hatch, with hatch fmt and hatch test
Browse files Browse the repository at this point in the history
Also, just use Python 3.11.x - not a specific version - in CI.

Signed-off-by: Nic Cope <[email protected]>
  • Loading branch information
negz committed Oct 10, 2024
1 parent 34ed177 commit 6a068dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ on:

env:
# Common versions
PYTHON_VERSION: '3.11.5'
PYTHON_VERSION: '3.11'
HATCH_VERSION: '1.12.0'
DOCKER_BUILDX_VERSION: 'v0.11.2'

# These environment variables are important to the Crossplane CLI install.sh
Expand Down Expand Up @@ -47,10 +48,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 @@ -64,10 +65,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

# We want to build most packages for the amd64 and arm64 architectures. To
# speed this up we build single-platform packages in parallel. We then upload
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ CLI][cli] to build functions.
# Run the code in development mode, for crossplane beta render
hatch run development

# Lint the code - see pyproject.toml
hatch run lint:check
# Lint and format the code - see pyproject.toml
hatch fmt

# Run unit tests - see tests/test_fn.py
hatch run test:unit
hatch run test

# Build the function's runtime image - see Dockerfile
$ docker build . --tag=runtime
Expand Down
17 changes: 3 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,10 @@ dependencies = ["ipython==8.28.0"]
[tool.hatch.envs.default.scripts]
development = "python function/main.py --insecure --debug"

[tool.hatch.envs.lint]
type = "virtual"
detached = true
path = ".venv-lint"
# This special environment is used by hatch fmt.
[tool.hatch.envs.hatch-static-analysis]
dependencies = ["ruff==0.6.9"]

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

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

[tool.hatch.envs.test.scripts]
unit = "python -m unittest tests/*.py"
config-path = "none" # Disable Hatch's default Ruff config.

[tool.ruff]
target-version = "py311"
Expand Down

0 comments on commit 6a068dd

Please sign in to comment.