From 6148ea1292fafb411cbb2998addbfc8b9dc7ba21 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Fri, 12 Jul 2024 21:48:45 -0400 Subject: [PATCH] update the contributing guide with the new hatch setup --- CONTRIBUTING.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 427d2de5..deb93fc1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,21 +66,18 @@ Rather than forking `dbt-labs/dbt-postgres`, use `dbt-labs/dbt-postgres` directl ### Installation -1. Ensure the latest version of `pip` is installed: +1. Ensure the latest versions of `pip` and `hatch` are installed: ```shell - pip install --upgrade pip + pip install --upgrade pip hatch ``` -2. Configure and activate a virtual environment using `virtualenv` as described in -[Setting up an environment](https://github.com/dbt-labs/dbt-core/blob/HEAD/CONTRIBUTING.md#setting-up-an-environment) -3. Install `dbt-postgres` and development dependencies in the virtual environment +2. Create a `hatch` environment with all of the development dependencies and activate it: ```shell - pip install -e .[dev] + hatch shell ``` When `dbt-postgres` is installed this way, any changes made to the `dbt-postgres` source code will be reflected in the virtual environment immediately. - ## Testing `dbt-postgres` contains [unit](https://github.com/dbt-labs/dbt-postgres/tree/main/tests/unit) @@ -95,9 +92,9 @@ Unit tests can be run locally without setting up a database connection: # Note: replace $strings with valid names # run all unit tests in a module -python -m pytest tests/unit/$test_file_name.py +hatch run unit-tests tests/unit/$test_file_name.py # run a specific unit test -python -m pytest tests/unit/$test_file_name.py::$test_class_name::$test_method_name +hatch run unit-tests tests/unit/$test_file_name.py::$test_class_name::$test_method_name ``` ### Functional tests @@ -120,17 +117,22 @@ Functional tests can be run locally with a valid database connection configured ```shell # Note: replace $strings with valid names +# run all functional tests +hatch run integration-tests + # run all functional tests in a directory -python -m pytest tests/functional/$test_directory +hatch run integration-tests tests/functional/$test_directory + # run all functional tests in a module -python -m pytest tests/functional/$test_dir_and_filename.py +hatch run integration-tests tests/functional/$test_directory/$test_filename.py + # run all functional tests in a class -python -m pytest tests/functional/$test_dir_and_filename.py::$test_class_name +hatch run integration-tests tests/functional/$test_directory/$test_filename.py::$test_class_name + # run a specific functional test -python -m pytest tests/functional/$test_dir_and_filename.py::$test_class_name::$test__method_name +hatch run integration-tests tests/functional/$test_directory/$test_filename.py::$test_class_name::$test__method_name ``` - ## Documentation ### User documentation