Skip to content

Commit

Permalink
Merge pull request #297 from City-of-Helsinki/UHF-11184
Browse files Browse the repository at this point in the history
UHF-11184: Simplify toolkit
  • Loading branch information
tuutti authored Jan 15, 2025
2 parents b38dd23 + 163d578 commit 1e51d3a
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 854 deletions.
31 changes: 25 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
PHONY :=
PROJECT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))

# Colors
NO_COLOR=\033[0m
CYAN=\033[36m
GREEN=\033[0;32m
RED=\033[0;31m
YELLOW=\033[0;33m

ENV := local

# Include project env vars (if exists)
-include .env
-include .env.local

# Include druidfi/tools config
include $(PROJECT_DIR)/tools/make/Makefile
define step
@printf "\n⭐ ${YELLOW}${1}${NO_COLOR}\n"
endef

PHONY += help
help: ## List all make commands
$(call step,Available make commands:\n)
@cat $(MAKEFILE_LIST) | grep -e "^[a-zA-Z_\-]*: *.*## *" | awk 'BEGIN {FS = ":.*?## "}; {printf "${CYAN}%-30s${NO_COLOR} %s\n", $$1, $$2}'

# Include project specific make files (if they exist)
-include $(PROJECT_DIR)/tools/make/project/*.mk
# Allow projects to specify makefiles.
-include tools/make/project/*.mk

# Project specific overrides for variables (if they exist)
-include $(PROJECT_DIR)/tools/make/override.mk
include tools/make/docker.mk
include tools/make/composer.mk
include tools/make/drupal.mk
include tools/make/git.mk
include tools/make/theme.mk
include tools/make/qa.mk

.PHONY: $(PHONY)
48 changes: 0 additions & 48 deletions tools/make/Makefile

This file was deleted.

35 changes: 0 additions & 35 deletions tools/make/ansible.mk

This file was deleted.

75 changes: 0 additions & 75 deletions tools/make/common.mk

This file was deleted.

18 changes: 2 additions & 16 deletions tools/make/composer.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
BUILD_TARGETS += composer-install
COMPOSER_PROD_FLAGS := --no-dev --optimize-autoloader --prefer-dist

PHONY += composer-info
composer-info: ## Composer info
$(call step,Do Composer info...\n)
$(call composer,info)

PHONY += composer-update
composer-update: ## Update Composer packages
$(call step,Do Composer update...\n)
Expand All @@ -14,19 +6,13 @@ composer-update: ## Update Composer packages
PHONY += composer-install
composer-install: ## Install Composer packages
$(call step,Do Composer install...\n)
$(call composer,install$(if $(filter production,$(ENV)), $(COMPOSER_PROD_FLAGS),))
$(call composer,install)

PHONY += composer-outdated
composer-outdated: ## Show outdated Composer packages
$(call step,Show outdated Composer packages...\n)
$(call composer,outdated --direct)

ifeq ($(RUN_ON),docker)
define composer
$(call docker_compose_exec,composer --ansi$(if $(filter $(COMPOSER_JSON_PATH),.),, --working-dir=$(COMPOSER_JSON_PATH)) $(1))
endef
else
define composer
@composer --ansi$(if $(filter $(COMPOSER_JSON_PATH),.),, --working-dir=$(COMPOSER_JSON_PATH)) $(1)
$(call docker_compose_exec,composer $(1))
endef
endif
56 changes: 4 additions & 52 deletions tools/make/docker.mk
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
CLI_SERVICE := app
CLI_SHELL := sh
# Note: specification says this file would be compose.yaml
DOCKER_COMPOSE_YML_PATH ?= compose.yaml
DOCKER_COMPOSE_YML_EXISTS := $(shell test -f $(DOCKER_COMPOSE_YML_PATH) && echo yes || echo no)
DOCKER_PROJECT_ROOT ?= /app
DOCKER_WARNING_INSIDE := You are inside the Docker container!

# If docker-compose.yml exists
ifeq ($(DOCKER_COMPOSE_YML_EXISTS),yes)
RUN_ON := docker
endif

PHONY += config
config: ## Show docker-compose config
$(call step,Show Docker Compose config...\n)
$(call docker_compose,config)

PHONY += pull
pull: ## Pull docker images
$(call step,Pull the latest docker images...\n)
Expand Down Expand Up @@ -43,43 +25,13 @@ up: ## Launch the environment

PHONY += shell
shell: ## Login to CLI container
ifeq ($(RUN_ON),docker)
$(call docker_compose,exec $(CLI_SERVICE) $(CLI_SHELL))
else
$(call warn,$(DOCKER_WARNING_INSIDE))
endif

PHONY += ssh-check
ssh-check: ## Check SSH keys on CLI container
$(call docker_compose_exec,ssh-add -L)

ifeq ($(RUN_ON),docker)
define docker
@docker $(1) > /dev/null 2>&1 && $(if $(2),echo "$(2)",)
endef
else
define docker
$(call sub_step,$(DOCKER_WARNING_INSIDE))
endef
endif
$(call docker_compose,exec app bash)

ifeq ($(RUN_ON),docker)
define docker_compose_exec
$(call docker_compose,exec$(if $(CLI_USER), -u $(CLI_USER),) $(CLI_SERVICE) $(CLI_SHELL) -c "$(1)")
$(if $(2),@echo "$(2)",)
endef
else
define docker_compose_exec
@$(1) && echo $(2)
$(call docker_compose,exec app bash -c "$(1)")
endef
endif

ifeq ($(RUN_ON),docker)
define docker_compose
@docker compose$(if $(filter $(DOCKER_COMPOSE_YML_PATH),$(DOCKER_COMPOSE_YML_PATH)),, -f $(DOCKER_COMPOSE_YML_PATH)) $(1)
@docker compose $(1)
endef
else
define docker_compose
$(call sub_step,$(DOCKER_WARNING_INSIDE))
endef
endif

Loading

0 comments on commit 1e51d3a

Please sign in to comment.