diff --git a/cookiecutter.json b/cookiecutter.json index 7a9fecd..ee7c3a7 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -16,6 +16,7 @@ "project_name_underscored": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}", "github_username": "elixir-cloud-aai", "python_version": "3.13.0", + "poetry_version": "1.8.5", "add_script": "y", "year": "{% now 'utc', '%Y' %}", "add_pypi_release_ci": "y", @@ -29,6 +30,7 @@ "project_name_dashed": "Distribution name (used on PyPI)", "github_username": "GitHub account name (used in repo URL and package metadata)", "python_version": "Minimum Python version (used in dependency specification)", + "poetry_version": "Poetry version ", "add_script": "CLI tool inclusion flag (used in build configuration)", "add_pypi_release_ci": "PyPI publishing automation flag " } diff --git a/{{ cookiecutter.project_name_dashed }}/.devcontainer/Dockerfile b/{{ cookiecutter.project_name_dashed }}/.devcontainer/Dockerfile index fc0c27c..3614bb1 100644 --- a/{{ cookiecutter.project_name_dashed }}/.devcontainer/Dockerfile +++ b/{{ cookiecutter.project_name_dashed }}/.devcontainer/Dockerfile @@ -42,6 +42,9 @@ RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master && git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM}/plugins/zsh-autosuggestions \ && git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM}/plugins/fast-syntax-highlighting +# Clone asdf scripts +RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf + # Install direnv RUN curl -sfL https://direnv.net/install.sh | bash diff --git a/{{ cookiecutter.project_name_dashed }}/.devcontainer/override.zshrc b/{{ cookiecutter.project_name_dashed }}/.devcontainer/override.zshrc index 632e04a..4d45299 100644 --- a/{{ cookiecutter.project_name_dashed }}/.devcontainer/override.zshrc +++ b/{{ cookiecutter.project_name_dashed }}/.devcontainer/override.zshrc @@ -3,6 +3,7 @@ export ZSH="/root/.oh-my-zsh" # Plugins plugins=( + asdf # Sets up asdf version manager direnv # Loads .envrc files git # Adds git command aliases and useful prompt info docker # Provides docker command completion and aliases diff --git a/{{ cookiecutter.project_name_dashed }}/.github/actions/setup/poetry/action.yaml b/{{ cookiecutter.project_name_dashed }}/.github/actions/setup/poetry/action.yaml index 6b7d3dc..8a552d2 100644 --- a/{{ cookiecutter.project_name_dashed }}/.github/actions/setup/poetry/action.yaml +++ b/{{ cookiecutter.project_name_dashed }}/.github/actions/setup/poetry/action.yaml @@ -10,7 +10,7 @@ inputs: default: '{{ cookiecutter.python_version }}' description: The version of Python to use poetry-version: - default: '1.8.2' + default: '{{ cookiecutter.poetry_version }}' description: The version of Poetry to install poetry-install-options: default: '' @@ -19,7 +19,7 @@ inputs: default: '' description: Options to pass to poetry export for hash generation for cache invalidation - +{% raw %} runs: using: composite steps: diff --git a/{{ cookiecutter.project_name_dashed }}/.tool-versions b/{{ cookiecutter.project_name_dashed }}/.tool-versions new file mode 100644 index 0000000..aaae9d1 --- /dev/null +++ b/{{ cookiecutter.project_name_dashed }}/.tool-versions @@ -0,0 +1,2 @@ +poetry {{ cookiecutter.poetry_version }} +python {{ cookiecutter.python_version }} diff --git a/{{ cookiecutter.project_name_dashed }}/Makefile b/{{ cookiecutter.project_name_dashed }}/Makefile index e5ba552..2f5e9fb 100644 --- a/{{ cookiecutter.project_name_dashed }}/Makefile +++ b/{{ cookiecutter.project_name_dashed }}/Makefile @@ -24,6 +24,7 @@ help: @echo " \033[1m\033[35mdocs\033[0m \033[37m(d)\033[0m: \033[36mGenerate project documentation.\033[0m\n" @echo "Environment Management --------------------------------------------------------" + @echo " \033[1m\033[35masdf-install\033[0m \033[37m(asdfi)\033[0m: \033[36mTry to install tools listed in .tool-versions.\033[0m" @echo " \033[1m\033[35mclean-venv\033[0m \033[37m(cv)\033[0m: \033[36mRemove virtual environment.\033[0m" @echo " \033[1m\033[35minstall\033[0m \033[37m(i)\033[0m: \033[36mInstall app and dependencies.\033[0m" @echo " \033[1m\033[35mvenv\033[0m \033[37m(v)\033[0m: \033[36mCreate virtual environment.\033[0m\n" @@ -39,6 +40,14 @@ help: # NOTE: Do not modify the autogenerated targets, unless necessary, write custom # targets in the custom section below.. +.PHONY: asdf-install asdfi +asdf-install: + @echo "\nInstalling ASDF Plugins & Tools +++++++++++++++++++++++++++++++++++++++++++++++\n" + @cat .tool-versions | cut -d' ' -f1 | grep "^[^\#]" | xargs -I {} asdf plugin add {} + @asdf install + +asdfi: asdf-install + .PHONY: clean-venv cv clean-venv: @echo "\nRemoving the virtual environment ++++++++++++++++++++++++++++++++++++++++++++++\n" diff --git a/{{ cookiecutter.project_name_dashed }}/README.md b/{{ cookiecutter.project_name_dashed }}/README.md index 1b101f2..246b184 100644 --- a/{{ cookiecutter.project_name_dashed }}/README.md +++ b/{{ cookiecutter.project_name_dashed }}/README.md @@ -19,6 +19,7 @@ - [Development](#development) - [Makefile](#makefile) - [Environment reproducibility](#environment-reproducibility) + - [asdf](#asdf) - [Dev containers](#dev-containers) - [Editor config](#editor-config) - [Setting environment variables (direnv)](#setting-environment-variables-direnv) @@ -128,6 +129,38 @@ make u ### Environment reproducibility +Below mentioned are some tools and configuration that you can use to make your +environment development-ready. This is optional and opinionated but can help you +set up your environment quickly. + +#### asdf + +We recommend using [asdf][asdf] to manage your development environment +efficiently. This tool allows you to handle multiple language versions and tools +seamlessly. You can install asdf by following the +[official installation guide][asdf-install]. If you are working within +[dev containers](#dev-containers), asdf will come pre-installed. + +The project includes a `.tool-versions` file, which lists the specific versions +of tools used. This ensures consistency across environments. To streamline the +installation process, use the following command to install the required tools +defined in the `.tool-versions` file: + +```sh +make asdfi +``` + +> **Note:** The `make asdfi` command might not install every tool listed in +> the `.tool-versions` file. After running the command, verify that all +> necessary tools are installed. If any tools are missing, install them +> manually using asdf. + +Example manual installation command: + +```sh +asdf install +``` + #### Dev Containers Our project supports [Dev Containers][devcontainers] for an easy and reproducible @@ -237,6 +270,8 @@ To get in touch with us, please use one of the following routes: [![logo-elixir]][elixir] [![logo-elixir-cloud-aai]][elixir-cloud-aai] +[asdf]: https://asdf-vm.com/ +[asdf-install]: https://asdf-vm.com/guide/getting-started.html [badge-chat-url]: https://join.slack.com/t/elixir-cloud/shared_invite/enQtNzA3NTQ5Mzg2NjQ3LTZjZGI1OGQ5ZTRiOTRkY2ExMGUxNmQyODAxMDdjM2EyZDQ1YWM0ZGFjOTJhNzg5NjE0YmJiZTZhZDVhOWE4MWM [badge-license-url]: http://www.apache.org/licenses/LICENSE-2.0 [code-of-conduct]: https://elixir-cloud-aai.github.io/about/code-of-conduct/