-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
84 lines (66 loc) · 2.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
APP_IMAGE_NAME=selfservice-portal
BUILD_NUMBER=n/a
OUTPUT_DIR=$(subst " ",\ ,${PWD})/.output
OUTPUT_DIR_APP=${OUTPUT_DIR}/app
OUTPUT_DIR_MANIFESTS=${OUTPUT_DIR}/manifests
MIN_NODE_VERSION = 16.0.0
.PHONY: default
default: help
.PHONY: init
init: clean restore build ## Remove all generated files, install and update, and build
.PHONY: clean
clean: ## Remove all generated files
@rm -Rf "$(OUTPUT_DIR)"
@mkdir "$(OUTPUT_DIR)"
@mkdir "$(OUTPUT_DIR_APP)"
@mkdir "$(OUTPUT_DIR_MANIFESTS)"
.PHONY: restore
restore: ## Install and update npm dependencies
@cd src && npm install
.PHONY: check-node-version
check-node-version: ## Verify node version dependencies
@if [ "$(shell node -v | cut -c2-)" \< "$(MIN_NODE_VERSION)" ]; then \
echo "Error: Node.js version must be >= $(MIN_NODE_VERSION)"; \
exit 1; \
fi
.PHONY: build
build: check-node-version ## Build and copy build artifacts over
@cd src && REACT_APP_DATE_OF_RELEASE="$(shell date -u +"%Y-%m-%d %H:%M") UTC" npm run build
@cp -r ./src/build/* "$(OUTPUT_DIR_APP)"
.PHONY: container
container: ## Build docker image
@docker build -t $(APP_IMAGE_NAME) .
.PHONY: manifests
manifests: ## Copy manifests over and update build number
@cp -r ./k8s/. "$(OUTPUT_DIR_MANIFESTS)"
@find "$(OUTPUT_DIR_MANIFESTS)" -type f -name '*.yml' | xargs sed -i 's:{{BUILD_NUMBER}}:${BUILD_NUMBER}:g'
.PHONY: ci
ci: clean restore build container manifests ## Build from scratch
.PHONY: deliver
deliver: ci ## Build from scratch and push containers
@sh ./tools/push-container.sh "${APP_IMAGE_NAME}" "${BUILD_NUMBER}"
.PHONY: dev
dev: ## Run the portal locally, listening for updates
@cd src && npm run start
.PHONY: runcontainer
runcontainer: clean build container ## Run the portal in a container
@docker run -it --rm -p 8080:80 selfservice-portal
.PHONY: setup-pre-commit-hook
setup-pre-commit-hook:
@sh ./setup-pre-commit-hook.sh
.PHONY: pre-commit-hook
pre-commit-hook:
@sh ./.git/hooks/pre-commit
.PHONY: format
format: ## Runs prettier
@cd src && $(MAKE) format
.PHONY: stylecheck
stylecheck: ## checks formatting and linting
@cd src && $(MAKE) stylecheck
.PHONY: help
help: ## Shows this list
@grep -F -h "##" $(MAKEFILE_LIST) | sed -e 's/\(\:.*\#\#\)/\:\ /' | grep -F -v grep -F | sed -e 's/\\$$//' | sed -e 's/##//'
.PHONY: test
test: ## Run playwright tests
@cd src && npx npx playwright test --project parallel
@cd src && npx npx playwright test --project sequential --workers 1