diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f44dba..2a852b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 diff --git a/README.md b/README.md index 6516e1b..c661402 100644 --- a/README.md +++ b/README.md @@ -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 test # Build the function's runtime image - see Dockerfile $ docker build . --tag=runtime diff --git a/pyproject.toml b/pyproject.toml index 2064987..596ac5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"