From 5ee9b32248285ec1f26240015ca4f12c981dc80a Mon Sep 17 00:00:00 2001 From: Timofey Myagkikh Date: Tue, 9 Apr 2024 19:18:39 +0300 Subject: [PATCH] scripts replaced with makefile --- README.md | 19 +++++++++-------- src/Makefile | 44 ++++++++++++++++++++++++++++++++++++++++ src/analyze.sh | 4 ---- src/api/src/endpoints.rs | 2 +- src/build.sh | 3 --- src/build_images.sh | 3 --- src/format.sh | 4 ---- src/run.sh | 3 --- src/run_tests.sh | 4 ---- 9 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 src/Makefile delete mode 100755 src/analyze.sh delete mode 100755 src/build.sh delete mode 100755 src/build_images.sh delete mode 100755 src/format.sh delete mode 100755 src/run.sh diff --git a/README.md b/README.md index fb4702f..1572ac0 100644 --- a/README.md +++ b/README.md @@ -37,14 +37,17 @@ For deploing with helm `/etc/hosts` require `127.0.0.1 dev-wep-api.com` entry fo ## Up & Running From src folder: -- `docker-compose up -d` - up dev environment -- `run.sh` - run api application for local debuging -- `build.sh` - build all workspaces -- `build_images.sh` - build `acl` and `api` dev images -- `docker-compose --profile dev-build up -d` - up `acl` and `api` dev images with compose -- `format.sh` - format code -- `analyze.sh` - static analysis -- `run_tests.sh` - build and run tests +- `make setup` - setup environment +- `make up flag=e` - up environment only +- `make up flag=a` - up all include applications +- `make down flag=e` - down environment only +- `make down flag=a` - down all include applications +- `make build flag=l` - build local binaries +- `make build flag=i` - build apps images +- `make lint` - run clippy for static analysis +- `make format` - run fmt for code formatting +- `make tests` - run tests +- `make run` - run local build From root folder: - `generate_cert.sh` - generate self signed cert and create kubernetes secret diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..6679ea4 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,44 @@ +setup: + rustup component add rustfmt + rustup component add clippy + rustup component add llvm-tools-preview + cargo install grcov + +up: +ifeq ($(flag),e) + docker-compose up -d +else ifeq ($(flag),a) + docker-compose --profile dev-build up -d +else + $(warning "pass flag=e (environment only) or flag=a (all include applications)") +endif + +down: +ifeq ($(flag),e) + docker-compose down +else ifeq ($(flag),a) + docker-compose --profile dev-build down +else + $(warning "pass flag=e (environment only) or flag=a (all include applications)") +endif + +build: +ifeq ($(flag),l) + cargo build --workspace +else ifeq ($(flag),i) + docker-compose --profile dev-build build +else + $(warning "pass flag=l (for build local) or flag=i (for build images)") +endif + +lint: + cargo clippy + +format: + cargo fmt + +run: + ./target/debug/host + +tests: + ./run_tests.sh \ No newline at end of file diff --git a/src/analyze.sh b/src/analyze.sh deleted file mode 100755 index fcd2f04..0000000 --- a/src/analyze.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -rustup component add clippy -cargo clippy \ No newline at end of file diff --git a/src/api/src/endpoints.rs b/src/api/src/endpoints.rs index 69cc39b..b8c83ca 100644 --- a/src/api/src/endpoints.rs +++ b/src/api/src/endpoints.rs @@ -93,6 +93,6 @@ pub async fn track_activity( match result { Some(_) => HttpResponse::Ok().json(()), - None => HttpResponse::BadRequest().json(ErrorResponse { code: 103 }) + None => HttpResponse::BadRequest().json(ErrorResponse { code: 103 }), } } diff --git a/src/build.sh b/src/build.sh deleted file mode 100755 index aeb32ea..0000000 --- a/src/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -cargo build --workspace \ No newline at end of file diff --git a/src/build_images.sh b/src/build_images.sh deleted file mode 100755 index 0b6dff2..0000000 --- a/src/build_images.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker-compose --profile dev-build build \ No newline at end of file diff --git a/src/format.sh b/src/format.sh deleted file mode 100755 index ea78c1c..0000000 --- a/src/format.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -rustup component add rustfmt -cargo fmt \ No newline at end of file diff --git a/src/run.sh b/src/run.sh deleted file mode 100755 index 265b335..0000000 --- a/src/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./target/debug/host \ No newline at end of file diff --git a/src/run_tests.sh b/src/run_tests.sh index 4d24163..3fcc6fb 100755 --- a/src/run_tests.sh +++ b/src/run_tests.sh @@ -1,9 +1,5 @@ #!/bin/bash -# install tools -cargo install grcov -rustup component add llvm-tools-preview - # set coverage directory path timestamp="$(date '+%Y-%m-%d_%H-%M-%S')" directory_path="target/coverage/${timestamp}"