forked from spiral/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (91 loc) · 3.07 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Docker binary to use, when executing docker tasks
DOCKER ?= docker
YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
-v $(shell pwd):/app \
--workdir /app \
cytopia/yamllint:latest \
-f colored .
ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
-v $(shell pwd):/app \
--workdir /app \
rhysd/actionlint:latest \
-color
MARKDOWN_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
-v $(shell pwd):/app \
--workdir /app \
davidanson/markdownlint-cli2-rules:latest
#
# Self documenting Makefile code
# ------------------------------------------------------------------------------------
ifneq ($(TERM),)
BLACK := $(shell tput setaf 0)
RED := $(shell tput setaf 1)
GREEN := $(shell tput setaf 2)
YELLOW := $(shell tput setaf 3)
LIGHTPURPLE := $(shell tput setaf 4)
PURPLE := $(shell tput setaf 5)
BLUE := $(shell tput setaf 6)
WHITE := $(shell tput setaf 7)
RST := $(shell tput sgr0)
else
BLACK := ""
RED := ""
GREEN := ""
YELLOW := ""
LIGHTPURPLE := ""
PURPLE := ""
BLUE := ""
WHITE := ""
RST := ""
endif
MAKE_LOGFILE = /tmp/cycle-dot-github.log
MAKE_CMD_COLOR := $(BLUE)
default: all
help: ## Show this menu
@echo 'Management commands for package:'
@echo 'Usage:'
@echo ' ${MAKE_CMD_COLOR}make${RST} Installs pre-commit hooks and does linting'
@grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
@echo
@echo ' 📑 Logs are stored in $(MAKE_LOGFILE)'
@echo
@echo ' 📦 Package .github (https://github.com/cycle/.github)'
@echo ' 🤠 Makefile Author Andrij Orlenko (https://github.com/lotyp)'
@echo ' 🏢 ${YELLOW}Org cycle (https://github.com/cycle)${RST}'
@echo
.PHONY: help
.EXPORT_ALL_VARIABLES:
#
# Default action
# Defines default command when `make` is executed without additional parameters
# ------------------------------------------------------------------------------------
all: hooks lint
.PHONY: all
#
# Code Quality, Git, Linting
# ------------------------------------------------------------------------------------
hooks: ## Install git hooks from pre-commit-config
pre-commit install
pre-commit install --hook-type commit-msg
pre-commit autoupdate
.PHONY: hooks
lint: lint-yaml lint-actions lint-md ## Lint all files
.PHONY: lint
lint-yaml: ## Lint all yaml files
@$(YAML_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
.PHONY: lint-yaml
lint-actions: ## Lint all github actions
@$(ACTION_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
.PHONY: lint-actions
lint-md: ## Lint all markdown files using markdownlint-cli2
@$(MARKDOWN_LINT_RUNNER) --fix "**/*.md" | tee -a $(MAKE_LOGFILE)
.PHONY: lint-md
lint-md-dry: ## Lint all markdown files using markdownlint-cli2 in dry-run mode
@$(MARKDOWN_LINT_RUNNER) "**/*.md" | tee -a $(MAKE_LOGFILE)
.PHONY: lint-md-dry
#
# Release
# ------------------------------------------------------------------------------------
commit:
czg commit --config="./.github/.cz.config.js"
.PHONY: commit