Skip to content

Commit be7bdef

Browse files
committed
chore(ci): parallelize build
- some targets in makefile first did sth. to core and then to each service - the work on the services can be done in parallel - create a target for core, use pattern rules to create targets for each service - change workflows to use makes `-j` for parallelism
1 parent 815ef3e commit be7bdef

3 files changed

Lines changed: 58 additions & 29 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
version: "0.10.4"
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install
22-
run: make install-dev
22+
run: make install-dev -j
2323
- name: Lint
24-
run: make lint-services
24+
run: make lint-services -j
2525
- name: Test
26-
run: make test-services
26+
run: make test-services -j

.github/workflows/dependency-checker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
3030
pr_name=$(echo "Dependency Updates")
3131
32-
make update-dependencies
32+
make update-dependencies -j
3333
branch_name="dependency-updater-${{ github.run_id }}"
3434
git checkout -b "$branch_name"
3535

Makefile

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,72 @@
11
SERVICES_DIR := services
2+
SERVICES := $(shell ls $(SERVICES_DIR))
23

3-
install:
4-
# install core
4+
INSTALL_TARGETS := $(addprefix install-,$(SERVICES))
5+
INSTALL_DEV_TARGETS := $(addprefix install-dev-,$(SERVICES))
6+
TEST_TARGETS := $(addprefix test-,$(SERVICES))
7+
LINT_TARGETS := $(addprefix lint-,$(SERVICES))
8+
UPDATE_TARGETS := $(addprefix update-dependencies-,$(SERVICES))
9+
10+
.PHONY: install install-core $(INSTALL_TARGETS)
11+
install: install-core $(INSTALL_TARGETS)
12+
13+
install-core:
514
uv sync --no-dev --directory core/
6-
# install services
7-
@for f in $(shell ls ${SERVICES_DIR}); do uv sync --no-dev --directory ${SERVICES_DIR}/$${f}; done
815

9-
install-dev:
10-
# install services
11-
@for f in $(shell ls ${SERVICES_DIR}); do set -e;uv sync --frozen --directory ${SERVICES_DIR}/$${f}; done
16+
$(INSTALL_TARGETS): install-%:
17+
# install service $*
18+
uv sync --no-dev --directory $(SERVICES_DIR)/$*
19+
20+
.PHONY: install-dev $(INSTALL_DEV_TARGETS)
21+
install-dev: $(INSTALL_DEV_TARGETS)
1222
# install core. This needs to be done last or it will get overriden by the dependency installation of the services
1323
uv sync --frozen --directory core
1424

15-
test-services:
16-
# test core
25+
$(INSTALL_DEV_TARGETS): install-dev-%:
26+
# install service $*
27+
uv sync --frozen --directory $(SERVICES_DIR)/$*
28+
29+
.PHONY: test-services test-core $(TEST_TARGETS)
30+
test-services: test-core $(TEST_TARGETS)
31+
32+
test-core:
1733
cd core && uv run pytest
18-
# test services
19-
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f}; sh -c ' uv run pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'; cd ../..; done
2034

21-
lint-services:
22-
# lint core
35+
$(TEST_TARGETS): test-%:
36+
# test service $*
37+
cd $(SERVICES_DIR)/$* && sh -c 'uv run pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'
38+
39+
.PHONY: lint-services lint-core lint-examples lint-versions $(LINT_TARGETS)
40+
lint-services: lint-core lint-examples $(LINT_TARGETS) lint-versions
41+
42+
lint-core:
2343
cd core && uv run flake8 .
44+
45+
lint-examples:
2446
# lint examples. Use configuration from core
25-
cd core && uv run flake8 --toml-config pyproject.toml --black-config pyproject.toml ../examples;
26-
# lint services
27-
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};uv run flake8 .; cd ../..; done
47+
cd core && uv run flake8 --toml-config pyproject.toml --black-config pyproject.toml ../examples
48+
49+
$(LINT_TARGETS): lint-%:
50+
# lint service $*
51+
cd $(SERVICES_DIR)/$* && uv run flake8 .
52+
53+
lint-versions:
2854
# lint versions
29-
@./scripts/lint-versions.sh
55+
./scripts/lint-versions.sh
3056

57+
# Old parameterized targets for single service, aliased to pattern rules
3158
test:
32-
echo "Testing service ${service}"
33-
cd ${SERVICES_DIR}/${service}; sh -c ' uv run pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'; cd ../..;
59+
$(MAKE) test-$(service)
3460

3561
lint:
36-
echo "Linting service ${service}"
37-
cd ${SERVICES_DIR}/${service};uv run flake8 .; cd ../..;
62+
$(MAKE) lint-$(service)
63+
64+
.PHONY: update-dependencies update-dependencies-core $(UPDATE_TARGETS)
65+
update-dependencies: update-dependencies-core $(UPDATE_TARGETS)
3866

39-
update-dependencies:
40-
# lock core
67+
update-dependencies-core:
4168
cd core && uv lock
42-
# lock services
43-
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};uv lock; cd ../..; done
69+
70+
$(UPDATE_TARGETS): update-dependencies-%:
71+
# lock service $*
72+
cd $(SERVICES_DIR)/$* && uv lock

0 commit comments

Comments
 (0)