Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devenv: Use tools from environment, where possible
Initially, I had wanted to also use the devcontainer in the CI pipelines so that there was a consistent environment used everywhere. However, the devcontainer is built with a `vscode` user so all tools live under `/home/vscode/.local/bin`. But when the container is run by Github Actions, `HOME` is set to something like `/github/home` so none of the pre-installed tools are found! Not only does this lead to re-installing all the required tools with each build, scripts like `make_release.py` break as they expect tools like `hatch` to be sitting on the `PATH`. I did find that there is a `devcontainers/ci` action available which looks like it could work, but has its own set of trade-offs with would require re-designing the pipelines altogether... Instead, this commit introduces a pattern which *assuming it works* should lead to a much nicer experience all around: TOOL ?= $(or $(shell command v tool), $(BIN)/tool) where - `?=` means the expression is only evaluated if `TOOL` is not already set. Allowing someone to override it at invocation time e.g. `TOOL=/path/to/tool make <target>` - `$(shell command -v tool)` will resolve to the full path to the `tool` executable, if it exists on the user's `PATH` - `$(BIN)/tool`, being the second option passed to `$(or` this will be the fallback option if the user does not already have `tool` available on their `PATH` When coupled with the `$(TOOL):` rules, this has the effect of installing the given tool, only if the user does not have a version of it installed already. Hopefully, this should mean that the `Makefiles` will be useful both inside and outside of a devcontainer!
- Loading branch information