-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
201 lines (150 loc) · 7.56 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
.PHONY: build build-typecheck bundle_install cicoverage citypecheck citest citypecoverage clean clean-coverage clean-typecheck clean-typecoverage coverage default gem_dependencies help overcommit quality repl report-coverage rubocop rubocop-ratchet test typecheck typecoverage update_from_cookiecutter
.DEFAULT_GOAL := default
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
default: clean-typecoverage build typecheck typecoverage clean-coverage test coverage overcommit_branch quality rubocop-ratchet ## run default typechecking, tests and quality
SOURCE_FILE_GLOBS = ['{config,lib,app,script}/**/*.rb', 'ext/**/*.{c,rb}']
SOURCE_FILES := $(shell ruby -e "puts Dir.glob($(SOURCE_FILE_GLOBS))")
start: ## run code continously and watch files for changes
echo "Teach me how to 'make start'"
exit 1
rbi/checkoff.rbi: yardoc.installed $(wildcard config/annotations_*.rb) $(SOURCE_FILES) ## Generate Sorbet types from Yard docs
rm -f rbi/checkoff.rbi
bin/sord --replace-errors-with-untyped --exclude-messages OMIT --no-regenerate rbi/checkoff.rbi
sig/checkoff.rbs: yardoc.installed ## Generate RBS file
bundle exec sord --replace-errors-with-untyped --exclude-messages OMIT --no-regenerate sig/checkoff.rbs
types.installed: tapioca.installed Gemfile.lock Gemfile.lock.installed sorbet/tapioca/require.rb sorbet/config rbi/checkoff.rbi ## Ensure typechecking dependencies are in place
bundle exec yard gems 2>&1 || bundle exec yard gems --safe 2>&1 || bundle exec yard gems 2>&1
bin/spoom srb bump || true
# spoom rudely updates timestamps on files, so let's keep up by
# touching yardoc.installed so we dont' end up in a vicious
# cycle
touch yardoc.installed rbi/checkoff.rbi
# bundle exec solargraph scan 2>&1
touch types.installed
build: bundle_install pip_install build-typecheck ## Update 3rd party packages as well and produce any artifacts needed from code
sorbet/machine_specific_config:
echo "--cache-dir=$$HOME/.sorbet-cache" > sorbet/machine_specific_config
build-typecheck: Gemfile.lock.installed types.installed sorbet/machine_specific_config ## Fetch information that type checking depends on
sorbet/tapioca/require.rb:
make sorbet/machine_specific_config vendor/.keep
bin/tapioca init
tapioca.installed: sorbet/tapioca/require.rb Gemfile.lock.installed ## Install Tapioca-generated type information
make sorbet/machine_specific_config
bin/tapioca gems
bin/tapioca annotations
# bin/tapioca dsl
bin/tapioca todo
touch tapioca.installed
yardoc.installed: $(wildcard config/annotations_*.rb) $(SOURCE_FILES) ## Generate YARD documentation
bin/yard doc $?
touch yardoc.installed
clean-typecheck: ## Refresh the easily-regenerated information that type checking depends on
bin/solargraph clear || true
rm -fr .yardoc/ rbi/checkoff.rbi types.installed yardoc.installed
rm -fr ../checkoff/.yardoc || true
echo all clear
realclean-typecheck: clean-typecheck ## Remove all type checking artifacts
rm -fr ~/.cache/solargraph
rm tapioca.installed
realclean: clean realclean-typecheck
rm -fr vendor/bundle .bundle
rm -f .make/*
rm -f *.installed
typecheck: build-typecheck ## validate types in code and configuration
bin/srb tc
bin/overcommit_branch # ideally this would just run solargraph
citypecheck: build-typecheck ## Run type check from CircleCI
bin/srb tc
# overcommit_branch gets run in quality chain
typecoverage: typecheck ## Run type checking and then ratchet coverage in metrics/
clean-typecoverage: ## Clean out type-related coverage previous results to avoid flaky results
citypecoverage: citypecheck ## Run type checking, ratchet coverage, and then complain if ratchet needs to be committed
config/env: config/env.1p ## Create file suitable for docker-compose usage
cat config/env.1p | cut -d= -f1 > config/env
requirements_dev.txt.installed: requirements_dev.txt
pip install -q --disable-pip-version-check -r requirements_dev.txt
touch requirements_dev.txt.installed
pip_install: requirements_dev.txt.installed ## Install Python dependencies
Gemfile.lock: Gemfile checkoff.gemspec .bundle/config
bundle lock
.bundle/config:
touch .bundle/config
gem_dependencies: .bundle/config
# Ensure any Gemfile.lock changes, even pulled from git, ensure a
# bundle is installed.
Gemfile.lock.installed: Gemfile checkoff.gemspec vendor/.keep
touch Gemfile.lock.installed
vendor/.keep: Gemfile.lock
make gem_dependencies
bundle install
touch vendor/.keep
bundle_install: Gemfile.lock.installed ## Install Ruby dependencies
clear_metrics: ## remove or reset result artifacts created by tests and quality tools
bundle exec rake clear_metrics || true
clean: clear_metrics clean-typecoverage clean-typecheck clean-coverage ## remove all built artifacts
citest: test ## Run unit tests from CircleCI
overcommit: ## run precommit quality checks
bin/overcommit_branch
overcommit_branch: ## run precommit quality checks only on changed files
@bundle exec overcommit_branch
quality: overcommit ## run precommit quality checks
test: ## Run lower-level tests
@bundle exec rake test
rubocop: ## Run rubocop
@bundle exec rubocop
rubocop-ratchet: rubocop ## Run rubocop and then ratchet numbers of errors in todo file
@bundle exec rubocop --regenerate-todo --no-exclude-limit --auto-gen-only-exclude --no-auto-gen-timestamp
@if [ -f .rubocop_todo.yml ]; \
then \
git diff --exit-code .rubocop.yml; \
git diff --exit-code .rubocop_todo.yml; \
fi
repl: bundle_install ## Launch an interactive development shell
@bundle exec rake repl
clean-coverage: clear_metrics ## Clean out previous output of test coverage to avoid flaky results from previous runs
coverage: test report-coverage ## check code coverage
@bundle exec rake undercover
release: sig/checkoff.rbs rbi/checkoff.rbi ## Create a new release
bundle exec rake release
report-coverage: test ## Report summary of coverage to stdout, and generate HTML, XML coverage report
update_apt: .make/apt_updated
.make/apt_updated:
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
touch .make/apt_updated
cicoverage: citest coverage ## check code coverage
update_from_cookiecutter: ## Bring in changes from template project used to create this repo
bundle exec overcommit --uninstall
# cookiecutter_project_upgrader does its work in
# .git/cookiecutter/checkoff, but RuboCop wants to inherit
# config from all directories above it - avoid config
# mismatches by moving this out of the way
mv .rubocop.yml .rubocop-renamed.yml || true
cookiecutter_project_upgrader --help >/dev/null
IN_COOKIECUTTER_PROJECT_UPGRADER=1 cookiecutter_project_upgrader || true
mv .rubocop-renamed.yml .rubocop.yml
git checkout cookiecutter-template && git push --no-verify
git checkout main; overcommit --sign && overcommit --sign pre-commit && git checkout main && git pull && git checkout -b update-from-cookiecutter-$$(date +%Y-%m-%d-%H%M)
git merge cookiecutter-template || true
git checkout --theirs sorbet/rbi/gems || true
git checkout --ours Gemfile.lock || true
# update frequently security-flagged gems while we're here
bundle update --conservative json nokogiri rack rexml yard || true
( make build && git add Gemfile.lock ) || true
bin/spoom srb bump || true
bundle exec overcommit --install || true
@echo
@echo "Please resolve any merge conflicts below and push up a PR with:"
@echo
@echo ' gh pr create --title "Update from cookiecutter" --body "Automated PR to update from cookiecutter boilerplate"'
@echo
@echo