generated from honeycombio/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (81 loc) · 3.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
# A Makefile? For a Ruby project?!? What about a Rakefile?
# Yes, a Makefile. We've standardized on Makefiles as a portable way to automate tasks
# across our polyglot projects.
# set shell to bash to make shell builtin behaviour consistent
SHELL := /usr/bin/env bash
#: run the unit tests
test:
@echo "+++ Running tests"
bundle exec rake spec
#: clean up the dev environment
clean: clean-smoke-tests
#: run the smoke tests
smoke: smoke-app smoke-sinatra
#: cleanup the smoke and smoke it again
resmoke: unsmoke smoke
#: run the smoke test for a simple, instrumented Ruby script
smoke-app: smoke-tests/collector/data.json
@echo ""
@echo "+++ Running example app smoke tests."
@echo ""
cd smoke-tests && bats ./smoke-example-app.bats --report-formatter junit --output ./
#: run the smoke test for a simple, instrumented Ruby script
smoke-sinatra: smoke-tests/collector/data.json
@echo ""
@echo "+++ Running example sinatra smoke tests."
@echo ""
cd smoke-tests && bats ./smoke-example-app-sinatra.bats --report-formatter junit --output ./
#: clear data from smoke tests
smoke-tests/collector/data.json:
@echo ""
@echo "+++ Zhuzhing smoke test's Collector data.json"
@touch $@ && chmod o+w $@
#: cleans up smoke test output
clean-smoke-tests:
rm -rf ./smoke-tests/collector/data.json
rm -rf ./smoke-tests/collector/data-results/*.json
rm -rf ./smoke-tests/report.*
#: tear down the smoke test environment
unsmoke:
@echo ""
@echo "+++ Spinning down the smokers."
@echo ""
cd smoke-tests && docker-compose down --volumes
JOB ?= test
#: run a CI job in docker locally, set JOB to override default 'run_tests'
local_ci_exec: local_ci_prereqs
circleci local execute $(JOB) --config .circleci/process.yml
### Utilities
# ^(a_|b_|c_) :: name starts with any of 'a_', 'b_', or 'c_'
# [^=] :: [^ ] is inverted set, so any character that isn't '='
# + :: + is 1-or-more of previous thing
#
# So the match the prefixes, then chars up-to-but-excluding the first '='.
# example: OTEL_VAR=HEY -> OTEL_VAR
#
# egrep to get the extended regex syntax support.
# --only-matching to output only what matches, not the whole line.
OUR_CONFIG_ENV_VARS := $(shell env | egrep --only-matching "^(HONEYCOMB_|OTEL_)[^=]+")
# To use the circleci CLI to run jobs on your laptop.
circle_cli_docs_url = https://circleci.com/docs/local-cli/
local_ci_prereqs: forbidden_in_real_ci circle_cli_available .circleci/process.yml
# the config must be processed to do things like expand matrix jobs.
.circleci/process.yml: circle_cli_available .circleci/config.yml
circleci config process .circleci/config.yml > .circleci/process.yml
circle_cli_available:
ifneq (, $(shell which circleci))
@echo "🔎:✅ circleci CLI available"
else
@echo "🔎:💥 circleci CLI command not available for local run."
@echo ""
@echo " ❓ Is it installed? For more info: ${circle_cli_docs_url}\n\n" && exit 1
endif
forbidden_in_real_ci:
ifeq ($(CIRCLECI),) # if not set, safe to assume not running in CircleCI compute
@echo "🔎:✅ not running in real CI"
else
@echo "🔎:🛑 CIRCLECI environment variable is present, a sign that we're running in real CircleCI compute."
@echo ""
@echo " 🙈 circleci CLI can't local execute in Circle. That'd be 🍌🍌🍌."
@echo "" && exit 1
endif