From 99804736932d01c95917757aef7d1384a8c9ede7 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Tue, 18 Jun 2024 11:52:23 +0200 Subject: [PATCH 1/3] docs: add more documentation for local development, testing, linting and formatting --- README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c3ade1f72..f3e0117cc 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Installation The easiest way to install conda-smithy is to use conda and conda-forge: -``` +```sh conda install -n root -c conda-forge conda-smithy ``` @@ -108,15 +108,78 @@ Running a build When everything is configured you can trigger a build with a push to the feedstock repo on github. -Developing conda-smithy +Developing `conda-smithy` ----------------------- -To develop conda smithy, use your favortite conda-based environment manager and create an environment based on the `environment.yml`. +If you don’t already have a conda-based environment manager, install one. For example [Miniconda]((https://docs.anaconda.com/free/miniconda/miniconda-install/)). -``` +To develop `conda-smithy`, use said environment manager and create an environment based on the `environment.yml`. + +```sh $ conda env create ``` +Then activate the environment, check that it works and install the dependencies: + +```sh +$ conda activate conda-smithy +$ which python +# ☝️ should now point to an environment-specific python +$ python -m pip install . +``` + +You might want to switch Python versions, for example if you wish to exactly replicate a CI issue locally. To do that: + +- Change the Python version in the `environment.yml` +- Deactivate and delete old environment, if you have it: `conda deactivate && conda env delete -n conda-smithy` +- (re-)run `conda env create` and activate the new environment with `conda activate conda-smithy` + +### Testing + +Run all tests with `pytest`. + +Run specific test file: +```sh +pytest tests/test_configure_feedstock.py +``` + +Run specific test within a file: +```sh +pytest tests/test_configure_feedstock.py -k test_cuda_enabled_render +``` + +Run with coverage (this is how the tests are run in CI): + +```sh +pytest tests --cov conda_smithy --cov-report lcov --cov-report term-missing +``` + +#### Troubleshooting Tests + +If test coverage is reported as 0%, your `pytest` and `pytest-cov` plugin might be from different environments/Python instances. You can force the use the of the environment versions by prefixing the commands with `python -m`, so to run the tests with coverage: + +```sh +python -m pytest tests --cov conda_smithy --cov-report lcov --cov-report term-missing +``` + +You may find that your latest changes aren’t reflected in a test run, in such cases, you can try rebuilding the project: + +```sh +python -m pip install -v --no-build-isolation -e . && pytest tests +``` + +### Linting and Formatting + +This repo currently uses `flake8` for linting (but doesn’t enforce it) and `black` for auto-formatting. `black` is already configured in the pre-commit hook, but you can run it manually whenever you like with: + +```sh +pre-commit run --all-files +``` + +To run flake, just type `flake8`. Note that `black` doesn’t auto-fix all errors found by `flake8`. + +**Note:** There is [an ongoing effort](https://github.com/conda-forge/conda-smithy/pull/1919) to replace `flake8` with `ruff`, which will then also be able to format away many of the issues it finds. + Releasing conda-smithy ---------------------- From cb947e39a8459cae80f306b313b2eb6a1284b026 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Wed, 26 Jun 2024 10:18:25 +0200 Subject: [PATCH 2/3] docs: suggested changes from review notes Co-authored-by: jaimergp --- README.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f3e0117cc..1786c7db9 100644 --- a/README.md +++ b/README.md @@ -111,12 +111,12 @@ When everything is configured you can trigger a build with a push to the feedsto Developing `conda-smithy` ----------------------- -If you don’t already have a conda-based environment manager, install one. For example [Miniconda]((https://docs.anaconda.com/free/miniconda/miniconda-install/)). +If you don’t already have a conda-based environment manager, install one. For example [Miniconda](https://docs.anaconda.com/free/miniconda/miniconda-install/). -To develop `conda-smithy`, use said environment manager and create an environment based on the `environment.yml`. +To develop `conda-smithy`, use said environment manager and create an environment based on the included `environment.yml` file. ```sh -$ conda env create +$ conda env create -f environment.yml ``` Then activate the environment, check that it works and install the dependencies: @@ -125,14 +125,14 @@ Then activate the environment, check that it works and install the dependencies: $ conda activate conda-smithy $ which python # ☝️ should now point to an environment-specific python -$ python -m pip install . +$ python -m pip install -e . --no-deps ``` You might want to switch Python versions, for example if you wish to exactly replicate a CI issue locally. To do that: -- Change the Python version in the `environment.yml` -- Deactivate and delete old environment, if you have it: `conda deactivate && conda env delete -n conda-smithy` -- (re-)run `conda env create` and activate the new environment with `conda activate conda-smithy` +```sh +conda install -n conda-smithy python=x.y +``` ### Testing @@ -145,7 +145,7 @@ pytest tests/test_configure_feedstock.py Run specific test within a file: ```sh -pytest tests/test_configure_feedstock.py -k test_cuda_enabled_render +pytest tests/test_configure_feedstock.py::test_cuda_enabled_render ``` Run with coverage (this is how the tests are run in CI): @@ -162,12 +162,6 @@ If test coverage is reported as 0%, your `pytest` and `pytest-cov` plugin might python -m pytest tests --cov conda_smithy --cov-report lcov --cov-report term-missing ``` -You may find that your latest changes aren’t reflected in a test run, in such cases, you can try rebuilding the project: - -```sh -python -m pip install -v --no-build-isolation -e . && pytest tests -``` - ### Linting and Formatting This repo currently uses `flake8` for linting (but doesn’t enforce it) and `black` for auto-formatting. `black` is already configured in the pre-commit hook, but you can run it manually whenever you like with: @@ -178,8 +172,6 @@ pre-commit run --all-files To run flake, just type `flake8`. Note that `black` doesn’t auto-fix all errors found by `flake8`. -**Note:** There is [an ongoing effort](https://github.com/conda-forge/conda-smithy/pull/1919) to replace `flake8` with `ruff`, which will then also be able to format away many of the issues it finds. - Releasing conda-smithy ---------------------- From 82d958423452dd15f8bcf5dbea858ea2da7e0f33 Mon Sep 17 00:00:00 2001 From: hulkoba Date: Mon, 29 Jul 2024 10:41:46 +0200 Subject: [PATCH 3/3] docs: refer miniforge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1786c7db9..3f1d2a292 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ When everything is configured you can trigger a build with a push to the feedsto Developing `conda-smithy` ----------------------- -If you don’t already have a conda-based environment manager, install one. For example [Miniconda](https://docs.anaconda.com/free/miniconda/miniconda-install/). +If you don’t already have a conda-based environment manager, install one. For example [Miniforge](https://github.com/conda-forge/miniforge). To develop `conda-smithy`, use said environment manager and create an environment based on the included `environment.yml` file.