conda-forge / conda-smithy

The tool for managing conda-forge feedstocks.
https://conda-forge.org/
BSD 3-Clause "New" or "Revised" License
147 stars 177 forks source link

[Feature Request] Add devcontainer configuration to feedstocks #1790

Open kenibrewer opened 10 months ago

kenibrewer commented 10 months ago

I initially created a PR with a devcontainer configuration in a feedstock repo that I help maintain, but was advised by a reviewer that this style of customization isn't appropriate for the feedstock repos. So I figured I'd make my case here for the benefits of adding devcontainer configuration more broadly to the conda-smithy feedstock repos.

What is a devcontainer configuration

A devcontainer configuration is a set of files that define the development environment used to develop and perform local testing of the code in a repo. Devcontainer configuration that follow the devcontainer.json schema can be used in two ways:

Why use a devcontainer configuration

Devcontainer configurations lower the barrier to entry for new contributors by providing a consistent development environment that is easy to set up and use. Instead of spending time researching and installing dependencies, contributors can get started right away by simply cloning the repo and opening it in VSCode or GitHub Codespaces. More opinionated devcontainer configurations can also help enforce best practices and reduce the number of common mistakes that new contributors make. Finally, devcontainer configurations can ensure greater consistency between the development environment and the CI environment, which can help reduce the number of occasions where a recipe builds locally but fails on CI.

How would a devcontainer configuration interact with existing build/test workflows

A devcontainer configuration would not replace existing build/test workflows, but rather provide a more convenient way to run them. The existing scripts of:

conda debug -m .ci_support/linux.... recipe

and

python build-locally --debug

would still be primary ways to debug conda recipe builds in the feedstocks. However, developers would be able to run these commands without being concerned that they are using the wrong version of conda or python, that local environment variables are interfering with the build, or figuring out what specific dependencies they need to install.

Test it out

To aid in the discussion, I've left the branch from the closed PR above in place so folks can test out an example devcontainer configuration in a feedstock repo. This link should take you to a page where you can create a new codespace using the devcontainer configuration. Alternately, you can clone the branch locally and open it in VSCode with the Remote Containers extension installed. The recipe in this branch is failing to build due to some source codebase related issues I'm working on, but the devcontainer configuration works correctly out-of-the-box.

hmaarrfk commented 10 months ago

i must admit this is pretty cool.

it takes a while to setup, but havin a different computer, other than my own to try things would be pretty nice.

Does it work for windows ;)?