-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (108 loc) · 4.51 KB
/
Makefile
File metadata and controls
122 lines (108 loc) · 4.51 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.PHONY: help
MAKEFLAGS += --silent
.DEFAULT_GOAL := help
PUPPETEER_CACHE_DIR := $(CURDIR)/.github/actions/generate-resume-pdf/.cache/puppeteer
help: ## Show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
setup: ## Setup development environment
@echo "Setting up development environment..."
@npm install --prefix resume/theme
@if sudo -n true > /dev/null 2>&1; then \
sudo apt-get update > /dev/null 2>&1; \
sudo apt-get install -y ghostscript > /dev/null 2>&1; \
fi
@for packageFile in ./.github/actions/**/package.json; do \
dir=$$(dirname "$$packageFile"); \
npm install --prefix "$$dir"; \
done
@if sudo -n true > /dev/null 2>&1; then \
sudo apt-get update > /dev/null 2>&1; \
sudo env PATH="$$PATH" PUPPETEER_CACHE_DIR="$(PUPPETEER_CACHE_DIR)" npx --prefix ./.github/actions/generate-resume-pdf puppeteer browsers install chrome --install-deps > /dev/null 2>&1; \
sudo chown -R "$$(id -u):$$(id -g)" "$(PUPPETEER_CACHE_DIR)" > /dev/null 2>&1; \
else \
PUPPETEER_CACHE_DIR="$(PUPPETEER_CACHE_DIR)" npx --prefix ./.github/actions/generate-resume-pdf puppeteer browsers install chrome > /dev/null 2>&1; \
fi
@echo "Development environment setup complete."
lint: ## Execute linting
$(call run_linter,)
lint-fix: ## Execute linting and fix
$(MAKE) humanize-resume
$(call run_linter, \
-e FIX_JSON_PRETTIER=true \
-e FIX_JAVASCRIPT_PRETTIER=true \
-e FIX_YAML_PRETTIER=true \
-e FIX_MARKDOWN=true \
-e FIX_MARKDOWN_PRETTIER=true \
-e FIX_NATURAL_LANGUAGE=true\
-e FIX_HTML_PRETTIER=true\
-e FIX_CSS=true\
-e FIX_CSS_PRETTIER=true\
-e FIX_JSX_PRETTIER=true\
-e FIX_TYPESCRIPT_PRETTIER=true\
)
audit-fix: ## Audit and fix npm packages
@echo "Auditing and fixing npm packages in resume/theme..."
@cd resume/theme && npm audit fix
@echo "Auditing and fixing npm packages in GitHub Actions..."
@for packageFile in ./.github/actions/**/package.json; do \
dir=$$(dirname "$$packageFile"); \
echo "Auditing and fixing npm packages in $$dir..."; \
npm audit fix --prefix "$$dir"; \
done
@echo "NPM package audit and fix complete."
test: ## Run tests
@echo "Running tests..."
@cd resume/theme && npm install && npm test
humanize-resume: ## Normalize resume text with humanize-ai-lib
@echo "Discovering resume files..."
@RESUME_FILES="$$(node .github/actions/get-available-resumes/get-available-resumes.js | jq -r '.[].path') $(CURDIR)/resume/resume.common.json"; \
cd .github/actions/humanize-resume && \
npm install && \
npm run humanize -- $$RESUME_FILES
preview-resume: ## Preview resume in the browser
@cd resume/theme && \
npm install && npm run dev
validate-resume: ## Validate resume JSON files
@echo "Discovering and validating resume files..."
@node .github/actions/get-available-resumes/get-available-resumes.js | jq -r '.[].path' | while read -r resume; do \
echo "Validating $$resume..."; \
cd ./.github/actions/validate-resume && npm install > /dev/null 2>&1 && npm run validate -- "$$resume" || exit 1; \
cd - > /dev/null; \
done
generate-pdfs: ## Generate all resumes PDFs
@echo "Building theme..."
@cd resume/theme && npm install > /dev/null 2>&1 && npm run build > /dev/null
@echo "Discovering and generating PDFs for all resume files..."
@node .github/actions/get-available-resumes/get-available-resumes.js | jq -c '.[]' | while read -r resume; do \
RESUME_NAME=$$(echo "$$resume" | jq -r '.name'); \
RESUME_PATH=$$(echo "$$resume" | jq -r '.path'); \
PDF_PATH=$$(echo "$$resume" | jq -r '.["pdf-path"]'); \
echo "Generating PDF for $$RESUME_NAME..."; \
cd ./.github/actions/generate-resume-pdf && PUPPETEER_CACHE_DIR="$(PUPPETEER_CACHE_DIR)" npm run generate-pdf -- "$$RESUME_PATH" "$$PDF_PATH" || exit 1; \
cd - > /dev/null; \
done
ci: ## Run all CI tasks
$(MAKE) setup
$(MAKE) lint-fix
$(MAKE) test
$(MAKE) validate-resume
$(MAKE) generate-pdfs
define run_linter
DEFAULT_WORKSPACE="$(CURDIR)"; \
LINTER_IMAGE="linter:latest"; \
VOLUME="$$DEFAULT_WORKSPACE:$$DEFAULT_WORKSPACE"; \
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \
docker run \
-e DEFAULT_WORKSPACE="$$DEFAULT_WORKSPACE" \
-e FILTER_REGEX_INCLUDE="$(filter-out $@,$(MAKECMDGOALS))" \
-e IGNORE_GITIGNORED_FILES=true \
$(1) \
-v $$VOLUME \
--rm \
$$LINTER_IMAGE
endef
#############################
# Argument fix workaround
#############################
%:
@: