Skip to content

Commit

Permalink
Install: Add checks to ensure installer dependencies are available (#702
Browse files Browse the repository at this point in the history
)

**Why?**

When running the make / install process of ADF, we need to ensure it will not
continue if some of the tools are not installed yet.

For example, in the past, if you did not install jq, it would still continue
with the build process. Resulting in a broken template at deployment time.

As reported in #696, the Python version in the environment was set to v3.8,
which resulted in a broken installation process too.

**What?**

* Updated the documentation to indicate that `jq` needs to be available too.
* Added checks in the build process to exit and warn the user about missing
  dependencies.
* Updated the version number of the Makefile.
  • Loading branch information
sbkok authored Apr 5, 2024
1 parent a937a5a commit e02ccae
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
53 changes: 50 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
# SPDX-License-Identifier: Apache-2.0

# Makefile versions
MAKEFILE_VERSION := 2.0
MAKEFILE_VERSION := 2.1
UPDATE_VERSION := make/latest

# This Makefile requires Python version 3.9 or later
REQUIRED_PYTHON_MAJOR_VERSION := 3
REQUIRED_PYTHON_MINOR_VERSION := 9
PYTHON_EXECUTABLE := "python$(REQUIRED_PYTHON_MAJOR_VERSION)"

# Repository versions
SRC_VERSION := $(shell git describe --tags --match 'v[0-9]*')
SRC_VERSION_TAG_ONLY := $(shell git describe --tags --abbrev=0 --match 'v[0-9]*')
Expand Down Expand Up @@ -50,7 +55,7 @@ all: build

.venv/is_ready:
( \
test -d .venv || python3 -m venv .venv; \
test -d .venv || $(PYTHON_EXECUTABLE) -m venv .venv; \
touch .venv/is_ready; \
)

Expand Down Expand Up @@ -175,6 +180,48 @@ docs:
@echo "* $(CLR_BLUE)$(SRC_TAGGED_URL_BASE)/docs/user-guide.md$(CLR_END)"
@echo ""

verify_tooling: .venv
@( \
. .venv/bin/activate; \
$(PYTHON_EXECUTABLE) --version &> /dev/null && \
( \
$(PYTHON_EXECUTABLE) -c "import sys; sys.version_info < ($(REQUIRED_PYTHON_MAJOR_VERSION),$(REQUIRED_PYTHON_MINOR_VERSION)) and sys.exit(1)" || \
( \
$(PYTHON_EXECUTABLE) --version && \
echo '$(CLR_RED)Python version is too old!$(CLR_END)' && \
echo '$(CLR_RED)Python v$(REQUIRED_PYTHON_MAJOR_VERSION).$(REQUIRED_PYTHON_MINOR_VERSION) or later is required.$(CLR_END)' && \
exit 1 \
) \
) || ( \
echo '$(CLR_RED)Python is not installed!$(CLR_END)' && \
exit 1 \
); \
)
@( \
docker --version &> /dev/null || ( \
echo '$(CLR_RED)Docker is not installed!$(CLR_END)' && \
exit 1 \
); \
)
@( \
git --version &> /dev/null || ( \
echo '$(CLR_RED)Git is not installed!$(CLR_END)' && \
exit 1 \
); \
)
@( \
sed --version &> /dev/null || ( \
echo '$(CLR_RED)Sed is not installed!$(CLR_END)' && \
exit 1 \
); \
)
@( \
jq --version &> /dev/null || ( \
echo '$(CLR_RED)Jq is not installed!$(CLR_END)' && \
exit 1 \
); \
)

pre_build: build_deps docker version_number git_ignore

pre_deps_build: deps docker version_number git_ignore
Expand All @@ -194,7 +241,7 @@ post_build:
@echo "$(CLR_GREEN)To deploy ADF, please run:$(CLR_END) make deploy"
@echo ""

build: pre_build sam_build post_build
build: verify_tooling pre_build sam_build post_build

deps_build: pre_deps_build sam_build post_build

Expand Down
5 changes: 4 additions & 1 deletion docs/installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ Please note that building on *Windows* is not supported, please use the
This should return 4.3 or later.
- [python 3](https://www.python.org/downloads/)
- To test if it is available, run `python --version`.
This should return 3.11 or later.
This should return 3.9 or later.
- [jq](https://github.com/jqlang/jq)
- To test if it is available, run `jq --version`.
This version should be 1.6 or later.
- [sed](https://www.gnu.org/software/sed/)
- To test if it is available, run `sed --version`.
This should return 4.3 or later.
Expand Down

0 comments on commit e02ccae

Please sign in to comment.