Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (71 loc) · 1.79 KB
/
Copy pathMakefile
File metadata and controls
96 lines (71 loc) · 1.79 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
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
.PHONY: test test-withoutsq
# Docker
DOCKER = docker
IMAGE_NAME = nethr-backend
CONTAINER_NAME = Nethr-server
DB_CONTAINER = nethr-srv-db
# Testing
PRISMA = prisma
NPX = npx
NPM = npm
TESTING_CONTAINER = test-postgres
JEST = jest
all: run
build: test
$(DOCKER) build -t $(IMAGE_NAME) .
$(DOCKER) run -d --rm \
--name $(DB_CONTAINER) \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=testdb \
-p 5432:5432 \
postgres
frbuild:
$(DOCKER) build -t $(IMAGE_NAME) .
$(DOCKER) run -d --rm \
--name $(DB_CONTAINER) \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=testdb \
-p 5432:5432 \
postgres
run:
$(DOCKER) run -d --name $(CONTAINER_NAME) -p 5679:5679 $(IMAGE_NAME):latest
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/testdb?schema=public
export JWT_SECRET="TESTSECRET"
lint:
$(NPM) run lint
test-run: lint
$(DOCKER) run -d --rm \
--name $(TESTING_CONTAINER) \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=testdb \
-p 5432:5432 \
postgres
$(NPX) $(PRISMA) generate
$(NPX) $(PRISMA) migrate deploy
$(NPX) $(JEST) --coverage
$(DOCKER) stop $(TESTING_CONTAINER)
test: test-run coverage/lcov.info
$(DOCKER) run --rm \
-e SONAR_HOST_URL="http://sonarqube:9000" \
-e SONAR_SCANNER_OPTS="-Dsonar.projectKey=Nethr" \
-e SONAR_TOKEN="sqa_6222ed2405055267669af129dd3f3dd597803adf" \
--network sonar-net \
-v .:/usr/src \
-u $(id -u):$(id -g) \
sonarsource/sonar-scanner-cli
clean-coverage:
$(NPX) rimraf coverage
test-withoutsq:
$(MAKE) test-run
$(NPX) rimraf coverage
sonar:
$(DOCKER) compose up -d
reset:
$(DOCKER) stop $(TESTING_CONTAINER)
clean:
$(DOCKER) stop $(CONTAINER_NAME)
$(DOCKER) rm $(CONTAINER_NAME)
$(DOCKER) rmi $(IMAGE_NAME)