-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathci.mk
More file actions
49 lines (42 loc) · 1.43 KB
/
ci.mk
File metadata and controls
49 lines (42 loc) · 1.43 KB
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
include Makefile
.PHONY: .push
push:
docker push --all-tags ${IMG_NAME}
.PHONY: pr-check
pr-check: main-check check-modified-migrations
.PHONY: main-check
main-check: tidy-check check-duplicated-migrations check-generated-code
.PHONY: check-duplicated-migrations
check-duplicated-migrations:
@set -e; \
echo "Performing duplicated migration check"; \
output="$$(ls -1 store/migrations/ | cut -d "_" -f1 | uniq -D)"; \
if [ -n "$$output" ]; then \
echo "Found duplicate migration versions:"; \
echo "$$output"; \
exit 1; \
fi; \
echo "No duplicated migrations found"
.PHONY: check-modified-migrations
check-modified-migrations:
@set -e; \
if test -z "$$BASE_REF"; then \
echo "BASE_REF must be set"; \
exit 1; \
fi; \
if test -z "$$HEAD_REF"; then \
echo "HEAD_REF must be set"; \
exit 1; \
fi; \
echo "Performing migration verification on PR against $$BASE_REF"; \
git fetch origin $$BASE_REF; \
git fetch origin $$HEAD_REF; \
git diff --exit-code --name-only --diff-filter=a origin/$$BASE_REF origin/$$HEAD_REF -- store/migrations/ || (echo "Migrations files are out of sync, please rebase" && exit 1); \
echo "No modified migrations found"
.PHONY: check-generated-code
check-generated-code: generate
@git diff --exit-code --name-only || (printf "Generated code isn't up to date.\nRun make generate before commiting" && exit 1)
.PHONY: tidy-check
tidy-check:
go mod tidy
git diff --exit-code --name-status -- go.mod go.sum