Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: |
pip install --group dev --group docs
pip install .
invoke build-docs
make build-docs

- name: upload docs
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ python -m venv ${DESTENV}
source ${DESTENV}/bin/activate
pip install --upgrade --quiet pip
pip install --quiet --group dev
invoke devenv
invoke package
make devenv
make package

# find packages
PKG=`ls ${ROOT}/dist/*.${SUFFIX}`
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: run code linters
run: |
pip install --group dev
invoke linters
make linters

get-date:
name: Get current date for cache
Expand Down Expand Up @@ -120,17 +120,17 @@ jobs:
if [ "${{matrix.connection-type}}" == "libvalkey" ]; then
pip install "libvalkey>=4.0.1"
fi
invoke devenv
make devenv
if [[ "${{matrix.test-type}}" == "standalone" ]]; then
./util/wait-for-it.sh localhost:6379
else
./util/wait-for-it.sh localhost:16379
fi
invoke ${{matrix.test-type}}-tests --protocol=${{ matrix.protocol-version }}
make ${{matrix.test-type}}-tests PROTOCOL=${{ matrix.protocol-version }}
# TODO: remove check for 3.14 once it's fixed
# https://github.com/MagicStack/uvloop/issues/637
if [[ "${{matrix.python-version}}" != pypy-* && "${{matrix.python-version}}" != "3.14-dev" ]]; then
invoke ${{matrix.test-type}}-tests --uvloop --protocol=${{ matrix.protocol-version }}
make ${{matrix.test-type}}-tests USE_UVLOOP=1 PROTOCOL=${{ matrix.protocol-version }}
fi

- uses: actions/upload-artifact@v4
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ Here's how to get started with your code contribution:
b. source .venv/bin/activate
c. pip install --group dev

4. If you need a development environment, run `invoke devenv`. Note: this relies on docker compose to build environments, and assumes that you have a version supporting [docker profiles](https://docs.docker.com/compose/profiles/).
5. While developing, make sure the tests pass by running `invoke tests`
4. If you need a development environment, run `make devenv`. Note: this relies on docker compose to build environments, and assumes that you have a version supporting [docker profiles](https://docs.docker.com/compose/profiles/).
5. While developing, make sure the tests pass by running `make tests`
6. If you like the change and think the project could use it, send a
pull request

To see what else is part of the automation, run `invoke -l`
To see what else is part of the automation, run `make help`

## The Development Environment

Running `invoke devenv` starts all of the dockers used by this
Running `make devenv` starts all of the dockers used by this
project, and leaves them running. These can be easily cleaned up with
`invoke clean`. NOTE: it is assumed that the user running these tests,
`make clean`. NOTE: it is assumed that the user running these tests,
can execute docker and its various commands.

- A master Valkey node
Expand All @@ -124,22 +124,22 @@ configuration](https://redis.io/topics/sentinel).

## Testing

Call `invoke tests` to run all tests, or `invoke all-tests` to run linters
Call `make tests` to run all tests, or `make all-tests` to run linters
tests as well. With the 'tests' and 'all-tests' targets, all Valkey and
ValkeyCluster tests will be run.

It is possible to run only Valkey client tests (with cluster mode disabled) by
using `invoke standalone-tests`; similarly, ValkeyCluster tests can be run by using
`invoke cluster-tests`.
using `make standalone-tests`; similarly, ValkeyCluster tests can be run by using
`make cluster-tests`.

Each run of tests starts and stops the various dockers required. Sometimes
things get stuck, an `invoke clean` can help.
things get stuck, an `make clean` can help.

## Documentation

If relevant, update the code documentation, via docstrings, or in `/docs`.

You can check how the documentation looks locally by running `invoke build-docs`
You can check how the documentation looks locally by running `make build-docs`
and loading the generated HTML files in a browser.

Historically there is a mix of styles in the docstrings, but the preferred way
Expand Down
86 changes: 86 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
USE_UVLOOP ?= 0
PROTOCOL ?= 2
CLUSTER_URL ?= valkey://localhost:16379/0
ADDITIONAL_PYTEST_ARGS ?=

ifeq ($(USE_UVLOOP), 1)
UVLOOP_ARG := --uvloop
UVLOOP_REPORT_INFIX := -uvloop
else
UVLOOP_ARG := --no-uvloop
endif

.PHONY: devenv stop-devenv build-docs linters standalone-tests cluster-tests all-tests clean package

all: help

help:
@echo "Please use \"make <target>\" where <target> is one of"
@echo " clean to clean the project and stop development environment"
@echo " devenv to start development environment (requires docker-compose)"
@echo " stop-devenv to stop development environment"
@echo " build-docs to build the sphinx documentation"
@echo " docs is an alias for build-docs"
@echo " linters to run code linters"
@echo " standalone-tests to run standalone tests"
@echo " cluster-tests to run cluster tests"
@echo " tests to run standalone and cluster tests"
@echo " all-tests to run all linters and tests"
@echo " package to build the package"

.check-virtualenv:
ifndef VIRTUAL_ENV
@echo "**************************************************************"
@echo "*** WARNING: it is highliy recommended to use a virtualenv ***"
@echo "**************************************************************"
endif

clean: stop-devenv
rm -rf build
rm -rf dist
docker compose --profile all rm -s -f

devenv: clean
docker compose --profile all up -d

stop-devenv:
docker compose --profile all down

build-docs docs: .check-virtualenv
pip install --group docs
make -C docs html

linters: .check-virtualenv
flake8 tests valkey
black --target-version py37 --check --diff tests valkey
isort --check-only --diff tests valkey
vulture valkey whitelist.py --min-confidence 80
flynt --fail-on-change --dry-run tests valkey

standalone-tests: .check-virtualenv
pytest \
--protocol=$(PROTOCOL) \
--cov=./ \
--cov-report=xml:coverage_valkey.xml \
-W always \
-m 'not onlycluster' \
--junit-xml=standalone$(UVLOOP_REPORT_INFIX)-results.xml \
$(UVLOOP_ARG) $(ADDITIONAL_PYTEST_ARGS)

cluster-tests: .check-virtualenv
pytest \
--protocol=$(PROTOCOL) \
--cov=./ \
--cov-report=xml:coverage_cluster.xml \
-W always \
-m 'not onlynoncluster and not valkeymod' \
--valkey-url=$(CLUSTER_URL) \
--junit-xml=cluster$(UVLOOP_REPORT_INFIX)-results.xml \
$(UVLOOP_ARG) $(ADDITIONAL_PYTEST_ARGS)

package: .check-virtualenv
hatchling build

tests: standalone-tests cluster-tests

all-tests: linters tests
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ dependencies = [
dev = [
'black',
'cachetools',
'click',
'flake8-isort',
'flake8',
'flynt',
'hatchling',
'invoke',
'mock',
'packaging>=20.4',
'pytest',
Expand Down
94 changes: 0 additions & 94 deletions tasks.py

This file was deleted.