Use latest hatch, with `hatch fmt` and `hatch test`
Also, just use Python 3.11.x - not a specific version - in CI. Signed-off-by: Nic Cope <nicc@rk0n.org>
This commit is contained in:
parent
34ed177048
commit
3268b9c0dc
|
@ -14,7 +14,8 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Common versions
|
# Common versions
|
||||||
PYTHON_VERSION: '3.11.5'
|
PYTHON_VERSION: '3.11'
|
||||||
|
HATCH_VERSION: '1.12.0'
|
||||||
DOCKER_BUILDX_VERSION: 'v0.11.2'
|
DOCKER_BUILDX_VERSION: 'v0.11.2'
|
||||||
|
|
||||||
# These environment variables are important to the Crossplane CLI install.sh
|
# These environment variables are important to the Crossplane CLI install.sh
|
||||||
|
@ -47,10 +48,10 @@ jobs:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
- name: Setup Hatch
|
- name: Setup Hatch
|
||||||
run: pipx install hatch==1.7.0
|
run: pipx install hatch==${{ env.HATCH_VERSION }}
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: hatch run lint:check
|
run: hatch fmt
|
||||||
|
|
||||||
unit-test:
|
unit-test:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
@ -64,10 +65,10 @@ jobs:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
- name: Setup Hatch
|
- name: Setup Hatch
|
||||||
run: pipx install hatch==1.7.0
|
run: pipx install hatch==${{ env.HATCH_VERSION }}
|
||||||
|
|
||||||
- name: Run Unit Tests
|
- 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
|
# 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
|
# speed this up we build single-platform packages in parallel. We then upload
|
||||||
|
|
|
@ -25,11 +25,11 @@ CLI][cli] to build functions.
|
||||||
# Run the code in development mode, for crossplane beta render
|
# Run the code in development mode, for crossplane beta render
|
||||||
hatch run development
|
hatch run development
|
||||||
|
|
||||||
# Lint the code - see pyproject.toml
|
# Lint and format the code - see pyproject.toml
|
||||||
hatch run lint:check
|
hatch fmt
|
||||||
|
|
||||||
# Run unit tests - see tests/test_fn.py
|
# Run unit tests - see tests/test_fn.py
|
||||||
hatch run test:unit
|
hatch test
|
||||||
|
|
||||||
# Build the function's runtime image - see Dockerfile
|
# Build the function's runtime image - see Dockerfile
|
||||||
$ docker build . --tag=runtime
|
$ docker build . --tag=runtime
|
||||||
|
|
|
@ -48,21 +48,10 @@ dependencies = ["ipython==8.28.0"]
|
||||||
[tool.hatch.envs.default.scripts]
|
[tool.hatch.envs.default.scripts]
|
||||||
development = "python function/main.py --insecure --debug"
|
development = "python function/main.py --insecure --debug"
|
||||||
|
|
||||||
[tool.hatch.envs.lint]
|
# This special environment is used by hatch fmt.
|
||||||
type = "virtual"
|
[tool.hatch.envs.hatch-static-analysis]
|
||||||
detached = true
|
|
||||||
path = ".venv-lint"
|
|
||||||
dependencies = ["ruff==0.6.9"]
|
dependencies = ["ruff==0.6.9"]
|
||||||
|
config-path = "none" # Disable Hatch's default Ruff config.
|
||||||
[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"
|
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
target-version = "py311"
|
target-version = "py311"
|
||||||
|
|
Loading…
Reference in New Issue