-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
161 lines (115 loc) · 5.23 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
.PHONY: *
BUILD_DIR=build
COOKIECUTTER_OUTPUT_DIR=$(BUILD_DIR)/a-generated-python-project
help:
@echo "help"
#################################################################
# setting up dev env
#################################################################
dev-env-minimal = -E format
dev-env-full = -E test -E git -E gitlab -E format -E lint -E repl
setup-dev-env-minimal: clean
poetry install --no-root $(dev-env-minimal)
setup-dev-env-full: clean
poetry install --no-root $(dev-env-full)
setup-dev-host:
./scripts/install_pyenv.sh
./scripts/install_poetry.sh
@echo "Host setup correctly. Restart your shell or source your shell config file to be up and running :)"
setup-pre-commit-hooks:
pre-commit install --hook-type pre-commit
#################################################################
# setting dependencies for automation (tox, cicd)
#################################################################
install-template-generation-dependencies:
poetry install --no-dev --no-root
install-test-dependencies:
poetry install --no-dev --no-root -E test
install-gitlab-pipelines-test-dependencies:
poetry install --no-dev --no-root -E test -E git -E gitlab
install-format-dependencies:
poetry install --no-dev --no-root -E format
install-lint-dependencies:
poetry install --no-dev --no-root -E lint
install-docs-dependencies:
poetry install --no-dev --no-root -E docs
#################################################################
# setting up ci-cd env
#################################################################
setup-cicd:
pip install --upgrade pip
#################################################################
# cleaning
#################################################################
clean:
rm -rf $(BUILD_DIR)
#################################################################
# generate project
#################################################################
overwrite:
# `rm` necessary due to bug in cookicutter, which does not overwrite all directories
rm -rf $(COOKIECUTTER_OUTPUT_DIR)/behave* $(COOKIECUTTER_OUTPUT_DIR)/features
poetry run cookiecutter --overwrite-if-exists --default-config --no-input -o $(BUILD_DIR) .
refresh: clean
poetry run cookiecutter --default-config --no-input -o $(BUILD_DIR) .
refresh-: refresh
refresh-pytest: refresh
refresh-cli-cleo: refresh
refresh-cli-click: clean
poetry run cookiecutter --overwrite-if-exists --default-config --no-input -o $(BUILD_DIR) . command_line_interface=Click
refresh-cli-none: clean
poetry run cookiecutter --overwrite-if-exists --default-config --no-input -o $(BUILD_DIR) . command_line_interface=None
refresh-gitlab: clean
poetry run cookiecutter --overwrite-if-exists --default-config --no-input -o $(BUILD_DIR) . hosting=GitLab
#################################################################
# template generation testing
#################################################################
test-generated-project: refresh-$(OPTION)
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) install-test-dependencies
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) test
bdd-generated-project: refresh-$(OPTION)
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) install-bdd-dependencies
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) bdd
format-generated-project: refresh-$(OPTION)
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) install-format-dependencies
# seed-isort-config needs a `git` repository to work
cd $(COOKIECUTTER_OUTPUT_DIR) && git init .
cd $(COOKIECUTTER_OUTPUT_DIR) && git config user.name "foo" && git config user.email "[email protected]"
cd $(COOKIECUTTER_OUTPUT_DIR) && git add --all && git commit -m'foo'
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) format
lint-generated-project: refresh-$(OPTION)
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) install-lint-dependencies
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) lint
type-generated-project: refresh-$(OPTION)
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) install-type-dependencies
$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) type
test-gitlab-cleanness: refresh-gitlab
poetry run pytest tests/test_no_github_in_gitlab_generated_project.py
#################################################################
# template pipelines/workflows testing
#################################################################
test-gitlab-pipeline:
poetry run pytest tests/test_gitlab_pipeline.py
#################################################################
# other (to cleanup)
#################################################################
setup: refresh
@echo "setting up poetry in directory $(COOKIECUTTER_OUTPUT_DIR)"
@$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) setup-dev-env-minimal
#%: refresh
# @echo "calling target(s) [$(MAKECMDGOALS)] on Makefile in directory $(COOKIECUTTER_OUTPUT_DIR)"
# @$(MAKE) -C $(COOKIECUTTER_OUTPUT_DIR) $(MAKECMDGOALS)
#################################################################
# git targets
#################################################################
prune-branches:
git remote prune origin
git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $$1; }' | xargs git branch -d
prune-branches-force:
git remote prune origin
git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $$1; }' | xargs git branch -D
pbf: prune-branches-force
post-PR-merge-sync-step-1:
git switch master
git pull
pms: post-PR-merge-sync-step-1 prune-branches-force