blob: 1f9fc178dd19d90d79be372661a464a928788f3b (
plain)
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
|
# Development tasks. Everything runs through the Ruby that is on PATH — the
# library and its test suite have no dependencies beyond the standard library,
# so there is nothing to install first.
#
# make list the targets
# make test run the suite with minitest
# make lint syntax and warning checks, no files touched
# make build build the gem into pkg/
RUBY ?= ruby
GEM ?= gem
SOURCES = $(shell find lib test -name '*.rb') cepis.gemspec
TESTS = $(shell find test -name '*_test.rb')
VERSION = $(shell $(RUBY) -Ilib -e 'require "cepis/version"; print Cepis::VERSION')
.DEFAULT_GOAL := help
.PHONY: help test lint format build check clean
help:
@echo 'Targets:'
@echo ' test run the test suite'
@echo ' lint ruby -w -c over the tree, plus rubocop when installed'
@echo ' format apply rubocop -A, when installed (writes)'
@echo ' build build the gem into pkg/'
@echo ' check lint + test + build, in that order'
@echo ' clean remove build artefacts'
test:
@set -e; for f in $(TESTS); do $(RUBY) -Ilib -Itest $$f; done
# Read-only by design, so it is safe in CI and in a pre-commit hook. Ruby has
# no formatter or linter in the standard library; rubocop is not a dependency
# of this gem, so it is used only when it happens to be installed.
lint:
@set -e; for f in $(SOURCES); do $(RUBY) -w -c $$f >/dev/null; done
@echo 'syntax OK: $(words $(SOURCES)) files'
$(RUBY) -w -Ilib -e 'require "cepis"'
@if command -v rubocop >/dev/null 2>&1; then rubocop; else \
echo 'rubocop not installed: syntax and warning checks only'; fi
format:
@if command -v rubocop >/dev/null 2>&1; then rubocop -A; else \
echo 'rubocop not installed: nothing to format with'; fi
build:
@mkdir -p pkg
$(GEM) build cepis.gemspec --output pkg/cepis-$(VERSION).gem
# The order matters: lint is the fastest to fail, build the slowest, so a
# broken run reports the cheapest problem first.
check: lint test build
clean:
rm -rf pkg doc .yardoc
|