Skip to content

Commit f95106b

Browse files
authored
Makefile Rework (#463)
1 parent 2a9b7f0 commit f95106b

File tree

8 files changed

+49
-30
lines changed

8 files changed

+49
-30
lines changed

.github/workflows/continuous_integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@v5
3939

4040
- name: Build Tests
41-
run: make build-test
41+
run: make build-tests
4242

4343
- name: Execute tests
4444
run: make run-ci

Makefile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-dev:
1010
docker build ./ --tag "openslides-$(SERVICE)-reader-dev" --build-arg CONTEXT="dev" --build-arg MODULE=reader --build-arg PORT=9010 --target "dev"
1111
docker build ./ --tag "openslides-$(SERVICE)-writer-dev" --build-arg CONTEXT="dev" --build-arg MODULE=writer --build-arg PORT=9011 --target "dev"
1212

13-
build-test:
13+
build-tests:
1414
docker build ./ --tag "openslides-$(SERVICE)-tests" --build-arg CONTEXT="tests" --target "tests"
1515

1616
# TESTS
@@ -24,26 +24,25 @@ build_args=--build-arg MODULE=$(MODULE) --build-arg PORT=$(PORT)
2424
build:
2525
docker build -t openslides-datastore-$(MODULE) $(build_args) .
2626

27-
run-dev-standalone: | build-dev
27+
dev-standalone: | build-dev
2828
docker compose -f dc.dev.yml up -d $(MODULE)
2929

30-
run-dev-verbose: | build-dev
30+
dev-verbose: | build-dev
3131
docker compose -f dc.dev.yml up $(MODULE)
3232

33+
run-dev-standalone: | dev-standalone
34+
3335
endif
3436

3537

3638
# the available targets without a MODULE:
3739
ifndef MODULE
3840
## TESTS
3941

40-
build-tests:
41-
make build-test
42-
4342
rebuild-tests:
4443
docker build . --tag=openslides-datastore-tests --no-cache --build-arg CONTEXT=tests
4544

46-
setup-docker-compose: | build-tests-old
45+
setup-docker-compose: | build-tests
4746
docker compose -f dc.test.yml up -d
4847
docker compose -f dc.test.yml exec -T datastore bash -c "chown -R $$(id -u $${USER}):$$(id -g $${USER}) /app"
4948

@@ -52,13 +51,13 @@ run-tests-no-down: | setup-docker-compose
5251

5352
run-test:| run-tests-no-down
5453
docker compose -f dc.test.yml down
55-
@$(MAKE) run-dev
54+
@$(MAKE) dev
5655
@$(MAKE) run-full-system-tests
5756

5857
run-tests:
5958
bash dev/run-tests.sh
6059

61-
run-dev run-bash: | setup-docker-compose
60+
dev run-bash: | setup-docker-compose
6261
docker compose -f dc.test.yml exec -u $$(id -u $${USER}):$$(id -g $${USER}) datastore ./entrypoint.sh bash
6362

6463
run-coverage: | setup-docker-compose
@@ -111,12 +110,14 @@ run:
111110
run-verbose:
112111
docker compose up
113112

114-
run-dev-standalone: | build-dev
113+
dev-standalone: | build-dev
115114
docker compose -f dc.dev.yml up -d
116115

117-
run-dev-verbose: | build-dev
116+
dev-verbose: | build-dev
118117
docker compose -f dc.dev.yml up
119118

119+
run-dev-standalone: | dev-standalone
120+
120121
ci-run-system-tests:
121122
docker compose -f dc.dev.yml up -d
122123
make run-full-system-tests-check

dc.external.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22
services:
33
reader:
44
build:
5-
context: "https://github.com/OpenSlides/openslides-datastore-service.git#main"
5+
context: "https://github.com/OpenSlides/openslides-datastore-service.git#${COMPOSE_REFERENCE_BRANCH:-main}"
66
dockerfile: Dockerfile
77
target: "dev"
88
args:
@@ -21,7 +21,7 @@ services:
2121
- postgres
2222
writer:
2323
build:
24-
context: "https://github.com/OpenSlides/openslides-datastore-service.git#main"
24+
context: "https://github.com/OpenSlides/openslides-datastore-service.git#${COMPOSE_REFERENCE_BRANCH:-main}"
2525
dockerfile: Dockerfile
2626
target: "dev"
2727
args:

dev/run-ci.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
# Executes all tests for the CI/CD Pipeline. Should errors occur, CATCH will be set to 1, causing an erroneous exit code.
46

57
echo "########################################################################"
@@ -8,16 +10,14 @@ echo "########################################################################"
810

911
# Setup
1012
IMAGE_TAG=openslides-datastore-tests
11-
CATCH=0
1213
CHOWN="$(id -u "${USER}"):$(id -g "${USER}")"
1314

1415
# Safe Exit
1516
trap 'docker compose -f dc.test.yml down' EXIT
1617

1718
# Execution
18-
make build-test
19-
docker compose -f dc.test.yml up -d || CATCH=1
20-
docker compose -f dc.test.yml exec -T datastore bash -c "chown -R $CHOWN /app" || CATCH=1
21-
docker compose -f dc.test.yml exec -T datastore ./entrypoint.sh ./execute-ci.sh || CATCH=1
19+
make build-tests
20+
docker compose -f dc.test.yml up -d
21+
docker compose -f dc.test.yml exec -T datastore bash -c "chown -R $CHOWN /app"
22+
docker compose -f dc.test.yml exec -T datastore ./entrypoint.sh ./execute-ci.sh
2223

23-
exit $CATCH

dev/run-lint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# Executes all linters. Should errors occur, CATCH will be set to 1, causing an erroneous exit code.
4+
5+
echo "########################################################################"
6+
echo "################ Datastore has no linters ##############################"
7+
echo "########################################################################"

dev/run-tests.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
#!/bin/bash
22

3+
set -e
4+
35
# Executes all tests. Should errors occur, CATCH will be set to 1, causing an erroneous exit code.
46

57
echo "########################################################################"
68
echo "###################### Run Tests and Linters ###########################"
79
echo "########################################################################"
810

11+
# Parameters
12+
while getopts "s" FLAG; do
13+
case "${FLAG}" in
14+
s) SKIP_BUILD=true ;;
15+
*) echo "Can't parse flag ${FLAG}" && break ;;
16+
esac
17+
done
18+
919
# Setup
1020
IMAGE_TAG=openslides-datastore-tests
11-
CATCH=0
21+
LOCAL_PWD=$(dirname "$0")
1222
CHOWN="$(id -u "${USER}"):$(id -g "${USER}")"
1323

1424
# Safe Exit
1525
trap 'docker compose -f dc.test.yml down' EXIT
1626

1727
# Execution
18-
make build-test
19-
docker compose -f dc.test.yml up -d || CATCH=1
20-
docker compose -f dc.test.yml exec -T datastore bash -c "chown -R $CHOWN /app" || CATCH=1
21-
docker compose -f dc.test.yml exec datastore ./entrypoint.sh pytest || CATCH=1
28+
if [ -z "$SKIP_BUILD" ]; then make build-tests; fi
29+
docker compose -f dc.test.yml up -d
30+
docker compose -f dc.test.yml exec -T datastore bash -c "chown -R $CHOWN /app"
31+
docker compose -f dc.test.yml exec datastore ./entrypoint.sh pytest
2232

23-
exit $CATCH
33+
# Linters
34+
bash "$LOCAL_PWD"/run-lint.sh

docs/layout.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ Utility:
2828

2929
Development environment:
3030
- `make build-dev`: builds all development images
31-
- `make run-dev-standalone`: runs the development environment
32-
- `make run-dev-verbose`: same as `make run-dev-standalone`, but doesn't detach the containers so the output is directly visible and the process can be stopped with CTRL+C.
31+
- `make dev-standalone`: runs the development environment
32+
- `make dev-verbose`: same as `make dev-standalone`, but doesn't detach the containers so the output is directly visible and the process can be stopped with CTRL+C.
3333
- `make stop-dev`: stops all dev containers
3434

3535
All these commands are also available inside the modules and only affect the current module there. Additional commands available inside the modules (primarily for testing purposes):
3636

37-
- `make run-bash`, `make run-dev`: opens a bash console in the container, so tests/cleanup can be run interactively
37+
- `make run-bash`, `make dev`: opens a bash console in the container, so tests/cleanup can be run interactively
3838
- `make run-coverage`: creates a coverage report for all tests. The needed coverage to pass is defined in `scripts/setup.cfg`.

scripts/make-targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
MAKE_TARGETS_MODULES=build build-dev run-dev run-dev-verbose stop stop-dev
1+
MAKE_TARGETS_MODULES=build build-dev dev dev-verbose stop stop-dev
22
export

0 commit comments

Comments
 (0)