-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
152 lines (123 loc) · 4.44 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
# Makefile for building and running the project.
# The purpose of this Makefile is to avoid developers having to remember
# project-specific commands for building, running, etc. Recipes longer
# than one or two lines should live in script files of their own in the
# bin/ directory.
CONFIG = config/application.yml
HOST ?= localhost
PORT ?= 3000
GZIP_COMMAND ?= gzip
ARTIFACT_DESTINATION_FILE ?= ./tmp/idp.tar.gz
.PHONY: \
brakeman \
check \
clobber_db \
clobber_logs \
fast_setup \
fast_test \
help \
lint \
lint_lockfiles \
lint_yaml \
lintfix \
normalize_yaml \
run \
tidy \
update \
urn \
README.md \
setup \
test \
help: ## Show this help
@echo "--- Help ---"
@ruby lib/makefile_help_parser.rb
all: check
setup $(CONFIG): config/application.yml.default ## Runs setup scripts (updates packages, dependencies, databases, etc)
bin/setup
fast_setup: ## Abbreviated setup script that skips linking some files
bin/fast_setup
check: lint test ## Runs lint tests and spec tests
lint: ## Runs all lint tests
# Ruby
@echo "--- rubocop ---"
ifdef JUNIT_OUTPUT
bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed
else
bundle exec rubocop --parallel
endif
@echo "--- brakeman ---"
make brakeman
# Other
# @echo "--- lint yaml ---"
# make lint_yaml
@echo "--- lint lockfiles ---"
make lint_lockfiles
@echo "--- README.md ---"
make lint_readme
@echo "--- lint migrations ---"
make lint_migrations
audit: ## Checks packages for vulnerabilities
@echo "--- bundler-audit ---"
bundle exec bundler-audit check --update
lint_yaml: normalize_yaml ## Lints YAML files
(! git diff --name-only | grep "^config/.*\.yml$$") || (echo "Error: Run 'make normalize_yaml' to normalize YAML"; exit 1)
lint_migrations:
scripts/migration_check
lint_gemfile_lock: Gemfile Gemfile.lock ## Lints the Gemfile and its lockfile
@bundle check
@git diff-index --quiet HEAD Gemfile.lock || (echo "Error: There are uncommitted changes after running 'bundle install'"; exit 1)
lint_lockfiles: lint_gemfile_lock ## Lints to ensure lockfiles are in sync
lint_readme: README.md ## Lints README.md
(! git diff --name-only | grep "^README.md$$") || (echo "Error: Run 'make README.md' to regenerate the README.md"; exit 1)
lintfix: ## Try to automatically fix any Ruby, ERB, JavaScript, YAML, or CSS lint errors
@echo "--- rubocop fix ---"
bundle exec rubocop -a
@echo "--- normalize yaml ---"
make normalize_yaml
brakeman: ## Runs brakeman code security check
(bundle exec brakeman) || (echo "Error: update code as needed to remove security issues. For known exceptions already in brakeman.ignore, use brakeman to interactively update exceptions."; exit 1)
test: export RAILS_ENV := test
test: $(CONFIG) ## Runs RSpec
bundle exec rspec
test_serial: export RAILS_ENV := test
test_serial: $(CONFIG) ## Runs RSpec serially
bundle exec rake spec
fast_test: export RAILS_ENV := test
fast_test: ## Abbreviated test run, runs RSpec tests without accessibility specs
bundle exec rspec --exclude-pattern "**/features/accessibility/*_spec.rb"
tmp/$(HOST)-$(PORT).key tmp/$(HOST)-$(PORT).crt: ## Self-signed cert for local HTTPS development
mkdir -p tmp
openssl req \
-newkey rsa:2048 \
-x509 \
-sha256 \
-nodes \
-days 365 \
-subj "/C=US/ST=District of Columbia/L=Washington/O=GSA/OU=Login.gov/CN=$(HOST):$(PORT)" \
-keyout tmp/$(HOST)-$(PORT).key \
-out tmp/$(HOST)-$(PORT).crt
run: ## Runs the development server
foreman start -p $(PORT)
urn:
@echo "⚱️"
make run
run-https: tmp/$(HOST)-$(PORT).key tmp/$(HOST)-$(PORT).crt ## Runs the development server with HTTPS
HTTPS=on FOREMAN_HOST="ssl://$(HOST):$(PORT)?key=tmp/$(HOST)-$(PORT).key&cert=tmp/$(HOST)-$(PORT).crt" foreman start -p $(PORT)
normalize_yaml: ## Normalizes YAML files (alphabetizes keys, fixes line length, smart quotes)
normalize-yaml .rubocop.yml --disable-sort-keys --disable-smart-punctuation
update: ## Update dependencies, useful after a git pull
bundle install
bundle exec rails db:migrate
README.md: docs/ ## Generates README.md based on the contents of the docs directory
bundle exec ruby scripts/generate_readme.rb --docs-dir $< > $@
clobber_db: ## Resets the database for make setup
bin/rake db:create
bin/rake db:environment:set
bin/rake db:reset
bin/rake db:environment:set
bin/rake dev:prime
clobber_logs: ## Purges logs and tmp/
rm -f log/*
rm -rf tmp/cache/*
tidy: clobber_logs ## Remove logs, and unused gems, but leave DB alone
bundle clean