From 921c1eb52e0be540d6861ec73521aa891183e659 Mon Sep 17 00:00:00 2001 From: TBS093A Date: Fri, 17 Mar 2023 12:40:56 +0100 Subject: [PATCH] add Makefile example for command automatization --- gitlab/Makefile | 154 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 gitlab/Makefile diff --git a/gitlab/Makefile b/gitlab/Makefile new file mode 100644 index 0000000..80689b4 --- /dev/null +++ b/gitlab/Makefile @@ -0,0 +1,154 @@ +PYTHON_VERSION_MIN=3.8 +UBUNTU_VERSION=22.04.02 +sys_ver = $(shell cat /etc/issue | cut -d " " -f2) # get version of ubuntu +tag = # tag for docker images + +hello: + # _ _ _ + # | | | | | | + # | |__| | ___| |_ __ + # | __ |/ _ \ | '_ \ + # | | | | __/ | |_) | + # |_| |_|\___|_| .__/ + # | | + # |_| + + @echo "available commands:" + @echo "make setUp developer environment, install all needed tools and packages " + @echo "make reqTests install test requirements" + @echo "make ut run unittests with coverage report" + @echo "make lint run isort, flake8, pylint " + @echo "make isort print isort check report " + @echo "make flake8 print flake8 check report" + @echo "make pylint print plint check report" + @echo "make installDocker install and config docker" + @echo "make install_venv install python-venv package " + @echo "make venv create virtual env (venv)" + @echo "make req install project requirements " + @echo "make build tag= build docker image with given tag " + + +# stetUp developer environment +# install: +# docker, python-env package, create venv, install requirements and tests requirements, run unit tests +setUp: checkSys installDocker install_venv venv req reqTest ut + + +checkSys: + @echo "Check ubuntu version, if version >= 22 install additional package required by Azure speech engine" +ifeq ($(shell expr $(sys_ver) \>= 22.0 ), 1) + @echo "ubuntu ver " $(shell cat /etc/issue | cut -d " " -f2) + wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb + sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb && rm libssl1.1_1.1.0g-2ubuntu4_amd64.deb +endif + +installDocker: + # _____ _ _ _ _____ _ + # |_ _| | | | | | | __ \ | | + # | | _ __ ___| |_ __ _| | | | | | | ___ ___| | _____ _ __ + # | | | '_ \/ __| __/ _` | | | | | | |/ _ \ / __| |/ / _ \ '__| + # _| |_| | | \__ \ || (_| | | | | |__| | (_) | (__| < __/ | + # |_____|_| |_|___/\__\__,_|_|_| |_____/ \___/ \___|_|\_\___|_| + # + # + sudo apt update + sudo apt install apt-transport-https curl gnupg-agent ca-certificates software-properties-common -y + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" + sudo apt install docker-ce docker-ce-cli containerd.io -y + sudo usermod -aG docker $$USER + newgrp docker + docker version + +install_venv: + # _____ _ _ _ + # |_ _| | | | | | + # | | _ __ ___| |_ __ _| | | + # | | | '_ \/ __| __/ _` | | | + # _| |_| | | \__ \ || (_| | | | + # |_____|_| |_|___/\__\__,_|_|_| + # + sudo apt install python3-venv + +venv: + # _____ _ + # / ____| | | + # | | _ __ ___ __ _| |_ ___ __ _____ _ ____ __ + # | | | '__/ _ \/ _` | __/ _ \ \ \ / / _ \ '_ \ \ / / + # | |____| | | __/ (_| | || __/ \ V / __/ | | \ V / + # \_____|_| \___|\__,_|\__\___| \_/ \___|_| |_|\_/ + # + # + python3 -m venv ./venv + @. venv/bin/activate + +req: + # _____ _ _ _ _____ _ _ + # |_ _| | | | | | | __ \ (_) | | + # | | _ __ ___| |_ __ _| | | | |__) |___ __ _ _ _ _ _ __ ___ _ __ ___ ___ _ __ | |_ ___ + # | | | '_ \/ __| __/ _` | | | | _ // _ \/ _` | | | | | '__/ _ \ '_ ` _ \ / _ \ '_ \| __/ __| + # _| |_| | | \__ \ || (_| | | | | | \ \ __/ (_| | |_| | | | | __/ | | | | | __/ | | | |_\__ \ + # |_____|_| |_|___/\__\__,_|_|_| |_| \_\___|\__, |\__,_|_|_| \___|_| |_| |_|\___|_| |_|\__|___/ + # | | + # |_| + @. venv/bin/activate && pip install -r requirements.txt + +reqTest: + # _____ _ _ _ _______ _ _____ _ _ + # |_ _| | | | | | |__ __| | | | __ \ (_) | | + # | | _ __ ___| |_ __ _| | | | | ___ ___| |_ ___ | |__) |___ __ _ _ _ _ _ __ ___ _ __ ___ ___ _ __ | |_ ___ + # | | | '_ \/ __| __/ _` | | | | |/ _ \/ __| __/ __| | _ // _ \/ _` | | | | | '__/ _ \ '_ ` _ \ / _ \ '_ \| __/ __| + # _| |_| | | \__ \ || (_| | | | | | __/\__ \ |_\__ \ | | \ \ __/ (_| | |_| | | | | __/ | | | | | __/ | | | |_\__ \ + # |_____|_| |_|___/\__\__,_|_|_| |_|\___||___/\__|___/ |_| \_\___|\__, |\__,_|_|_| \___|_| |_| |_|\___|_| |_|\__|___/ + # | | + # |_| + + @. venv/bin/activate && pip install -r tests/requirements.txt + + +build: + # ______ _ _ _ + # | ___ \ (_) | | | + # | |_/ /_ _ _| | __| | + # | ___ \ | | | | |/ _` | + # | |_/ / |_| | | | (_| | + # \____/ \__,_|_|_|\__,_| + # + @echo "build docker image with tag $(tag)" + docker build . -t $(tag) + + +isort: + isort . + +flake8: + flake8 + +pylint: + pylint *.py **/*.py + +lint: + # _ _ _ _____ _ _ + # | | (_) | | / ____| | | | + # | | _ _ __ | |_ ___ _ __ | | | |__ ___ ___| | __ + # | | | | '_ \| __/ _ \ '__| | | | '_ \ / _ \/ __| |/ / + # | |____| | | | | || __/ | | |____| | | | __/ (__| < + # |______|_|_| |_|\__\___|_| \_____|_| |_|\___|\___|_|\_\ + # + # + + isort . + flake8 + pylint *.py **/*.py + +ut: reqTest + # _ _ _____ + # | | | |_ _| + # | | | | | | + # | | | | | | + # | |_| | | | + # \___/ \_/ + # + # + @echo "run UT tests " + @. venv/bin/activate && pytest --cov-report term --cov=control_application tests