Skip to content

Commit 9b23b10

Browse files
vk-outreachmalept
andauthored
feat: add pre-action steps and use double-colon to Makefile (#15)
* feat: add pre-action steps and use double-colon to Makefile This adds pre-action targets for most targets and also used double-colon to allow creating post-action steps. * remove double-colon from targets fly-login and update-pipeline * Update root/Makefile (PR feedback) Co-authored-by: Mark Lee <malept@users.noreply.github.com> * remove newline Co-authored-by: Mark Lee <malept@users.noreply.github.com>
1 parent 1c9f332 commit 9b23b10

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

root/Makefile

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,29 @@ BASE_TEST_ENV ?= GOPROXY=$(GOPROXY) GOPRIVATE=$(GOPRIVATE) OUTREACH_ACCOUN
3535
.PHONY: default
3636
default: build
3737

38+
# All the pre-action steps are bunched together here.
39+
.PHONY: pre-release pre-build pre-test pre-coverage pre-integration pre-e2e pre-benchmark pre-gogenerate pre-devserver pre-debug pre-docker-build pre-fmt
40+
pre-release::
41+
pre-build::
42+
pre-test::
43+
pre-coverage::
44+
pre-integration::
45+
pre-e2e::
46+
pre-benchmark::
47+
pre-gogenerate::
48+
pre-devserver::
49+
pre-debug::
50+
pre-docker-build::
51+
pre-fmt::
52+
3853
## release: tag a new release with goreleaser
3954
.PHONY: release
40-
release:
55+
release:: pre-release
4156
@# Create a tag for our version
4257
@git tag -d "$(APP_VERSION)" >&2 || true
4358
@git tag "$(APP_VERSION)" >&2
4459
@./.bootstrap/shell/gobin.sh github.com/goreleaser/goreleaser@v0.157.0 release --skip-publish --rm-dist
45-
@# Delete the tag once we're done.
60+
@# Delete the tag once we are done.
4661
@git tag -d "$(APP_VERSION)" >&2
4762

4863
## help show this help
@@ -62,34 +77,34 @@ pre-commit: fmt
6277

6378
## build: run codegen and build application binary
6479
.PHONY: build
65-
build: gobuild
80+
build:: pre-build gobuild
6681

6782
## test: run unit tests
6883
.PHONY: test
69-
test:
84+
test:: pre-test
7085
$(BASE_TEST_ENV) ./.bootstrap/shell/test.sh
7186

7287
## coverage: generate code coverage
7388
.PHONY: coverage
74-
coverage:
89+
coverage:: pre-coverage
7590
WITH_COVERAGE=true GOPROXY=$(GOPROXY) GOPRIVATE=$(GOPRIVATE) ./.bootstrap/shell/test.sh
7691
go tool cover --html=/tmp/coverage.out
7792

7893
## integration: run integration tests
7994
.PHONY: integration
80-
integration:
95+
integration:: pre-integration
8196
TEST_TAGS=${TEST_TAGS} $(BASE_TEST_ENV) ./.bootstrap/shell/test.sh
8297

8398
## e2e: run e2e tests
8499
.PHONY: e2e
85-
e2e:
100+
e2e:: pre-e2e
86101
@devenv --skip-update status -q || \
87102
(echo "Starting developer environment"; set -x; devenv --skip-update provision ${E2E_ARGS})
88103
TEST_TAGS=or_test,or_e2e $(BASE_TEST_ENV) MY_NAMESPACE=$(E2E_NAMESPACE) MY_POD_SERVICE_ACCOUNT=$(E2E_SERVICE_ACCOUNT) OUTREACH_DOMAIN=$(OUTREACH_DOMAIN) ./.bootstrap/shell/test.sh
89104

90105
## benchmark: run benchmarks
91106
.PHONY: benchmark
92-
benchmark:
107+
benchmark:: pre-benchmark
93108
BENCH_FLAGS=${BENCH_FLAGS} TEST_TAGS=${TEST_TAGS} $(BASE_TEST_ENV) ./.bootstrap/shell/test.sh | tee /tmp/benchmark.txt
94109
@$(LOG) info "Results of benchmarks: "
95110
./.bootstrap/shell/gobin.sh golang.org/x/perf/cmd/benchstat /tmp/benchmark.txt
@@ -102,7 +117,7 @@ dep:
102117

103118
## gogenerate: run go codegen
104119
.PHONY: gogenerate
105-
gogenerate: check-deps
120+
gogenerate:: pre-gogenerate check-deps
106121
@$(LOG) info "Running gogenerate"
107122
@GOPROXY=$(GOPROXY) GOPRIVATE=$(GOPRIVATE) $(GO) generate ./...
108123

@@ -119,27 +134,27 @@ grpcui:
119134
./.bootstrap/shell/grpcui.sh localhost:5000
120135
## devserver: run the service
121136
.PHONY: devserver
122-
devserver: build
137+
devserver:: pre-devserver build
123138
if [[ -z $$SKIP_DEVCONFIG ]]; then ./.bootstrap/shell/devconfig.sh; fi
124139
OUTREACH_ACCOUNTS_BASE_URL=$(ACCOUNTS_URL) MY_NAMESPACE=$(E2E_NAMESPACE) OUTREACH_DOMAIN=$(OUTREACH_DOMAIN) $(BINDIR)/$(BIN_NAME)
125140

126141
## debug: run the service via delve
127142
.PHONY: debug
128-
debug: build
143+
debug:: pre-debug build
129144
if [[ -z $$SKIP_DEVCONFIG ]]; then ./.bootstrap/shell/devconfig.sh; fi
130145
OUTREACH_ACCOUNTS_BASE_URL=$(ACCOUNTS_URL) MY_NAMESPACE=$(E2E_NAMESPACE) OUTREACH_DOMAIN=$(OUTREACH_DOMAIN) ./.bootstrap/shell/debug.sh
131146

132147
## docker-build: build docker image for dev environment
133148
.PHONY: docker-build
134-
docker-build:
149+
docker-build:: pre-docker-build
135150
@echo " ===> building docker image <==="
136151
@ssh-add -L
137152
@echo " ===> If you run into credential issues, ensure that your key is in your SSH agent (ssh-add <ssh-key-path>) <==="
138153
DOCKER_BUILDKIT=1 docker build --ssh default -t gcr.io/outreach-docker/$(APP) -f deployments/$(APP)/Dockerfile . --build-arg VERSION=${APP_VERSION}
139154

140155
## fmt: run source code formatters
141156
.PHONY: fmt
142-
fmt:
157+
fmt:: pre-fmt
143158
@./.bootstrap/shell/fmt.sh
144159

145160
## fly-login: log into concourse

0 commit comments

Comments
 (0)