Skip to content

Commit ea75ec7

Browse files
authored
Update Makefile and prepare for buildall (#10)
1 parent c793321 commit ea75ec7

13 files changed

Lines changed: 98 additions & 94 deletions

File tree

.github/workflows/pre-merge.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
id: filter-changes
3434
run: |
3535
folders_to_remove='[".github",".reuse","LICENSES",""]'
36-
36+
3737
changed_projects='${{ steps.discover-changes.outputs.changed_projects }}'
3838
filtered_projects=$(echo "$changed_projects" | jq -cr --argjson folders_to_remove "$folders_to_remove" 'map(select(. as $item | $folders_to_remove | index($item) | not))')
3939
echo "filtered_projects=$filtered_projects" >> $GITHUB_OUTPUT
@@ -84,6 +84,7 @@ jobs:
8484
run_artifact: false
8585
prefix_tag_separator: "/"
8686
project_folder: ${{ matrix.project_folder }}
87+
trivy_image_skip: "postgres:16.4"
8788
secrets: inherit
8889
final-check:
8990
runs-on: ubuntu-latest
@@ -93,12 +94,12 @@ jobs:
9394
- name: Final Status Check
9495
run: |
9596
pre_merge_pipeline_result="${{ needs.pre-merge-pipeline.result }}"
96-
97+
9798
echo "Pre-merge pipeline result: $pre_merge_pipeline_result"
98-
99+
99100
if [ "$pre_merge_pipeline_result" == "success" ] || [ "$pre_merge_pipeline_result" == "skipped" ]; then
100101
echo "Pre-merge check passed successfully."
101102
else
102103
echo "Pre-merge checks failed. PR can't get merged"
103104
exit 1
104-
fi
105+
fi

Makefile

Lines changed: 60 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,88 @@
11
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4+
SHELL := bash -eu -o pipefail
5+
46
SUBPROJECTS := host networking maintenance os-resource telemetry attestationstatus
57

68
.DEFAULT_GOAL := help
79
.PHONY: all build clean clean-all help lint test
810

9-
all: build lint test
10-
@# Help: Runs build, lint, test stages for all subprojects
11+
# Repo root directory, where base makefiles are located
12+
REPO_ROOT := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
13+
14+
#### Python venv Target ####
15+
VENV_DIR := venv_managers
16+
17+
$(VENV_DIR): requirements.txt ## Create Python venv
18+
python3 -m venv $@ ;\
19+
set +u; . ./$@/bin/activate; set -u ;\
20+
python -m pip install --upgrade pip ;\
21+
python -m pip install -r requirements.txt
22+
23+
all: build lint test ## Runs build, lint, test stages for all subprojects
24+
25+
dependency-check: $(VENV_DIR)
26+
27+
lint: $(VENV_DIR) mdlint license ## lint common and all subprojects
28+
for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir lint; done
29+
30+
MD_FILES := $(shell find . -type f \( -name '*.md' \) -print )
31+
mdlint: ## lint all markdown README.md files
32+
markdownlint --version
33+
markdownlint *.md
34+
35+
license: $(VENV_DIR) ## Check licensing with the reuse tool
36+
set +u; . ./$</bin/activate; set -u ;\
37+
reuse --version ;\
38+
reuse --root . lint
1139

12-
build:
13-
@# Help: Runs build stage in all subprojects
14-
@echo "---MAKEFILE BUILD---"
40+
build: ## build in all subprojects
1541
for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir build; done
16-
@echo "---END MAKEFILE Build---"
17-
18-
lint:
19-
@# Help: Runs lint stage in all subprojects
20-
@echo "---MAKEFILE LINT---"
21-
@for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir lint; done
22-
@echo "---END MAKEFILE LINT---"
23-
24-
mdlint:
25-
@# Help: Runs md files linting
26-
@echo "---MAKEFILE LINT README---"
27-
@markdownlint --version
28-
@markdownlint "*.md"
29-
@echo "---END MAKEFILE LINT README---"
30-
31-
test:
32-
@# Help: Runs test stage in all subprojects
33-
@echo "---MAKEFILE TEST---"
42+
43+
docker-build: ## build all docker containers
44+
for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir $@; done
45+
46+
docker-push: ## push all docker containers
47+
for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir $@; done
48+
49+
docker-list: ## list all docker containers
50+
@echo "images:"
51+
@for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir $@; done
52+
53+
test: ## test in all subprojects
3454
for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir test; done
35-
@echo "---END MAKEFILE TEST---"
3655

37-
clean:
38-
@# Help: Runs clean stage in all subprojects
39-
@echo "---MAKEFILE CLEAN---"
56+
clean: ## clean in all subprojects
4057
for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir clean; done
41-
@echo "---END MAKEFILE CLEAN---"
4258

43-
clean-all:
44-
@# Help: Runs clean-all stage in all subprojects
45-
@echo "---MAKEFILE CLEAN-ALL---"
59+
clean-all: ## clean-all in all subprojects, and delete virtualenv
4660
for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir clean-all; done
47-
@echo "---END MAKEFILE CLEAN-ALL---"
61+
rm -rf $(VENV_DIR)
4862

49-
h-%:
50-
@# Help: Runs host subproject's tasks, e.g. h-test
63+
h-%: ## Runs host subproject's tasks, e.g. h-test
5164
$(MAKE) -C host $*
5265

53-
n-%:
54-
@# Help: Runs networking subproject's tasks, e.g. n-test
66+
n-%: ## Runs networking subproject's tasks, e.g. n-test
5567
$(MAKE) -C networking $*
5668

57-
m-%:
58-
@# Help: Runs maintenance subproject's tasks, e.g. m-test
69+
m-%: ## Runs maintenance subproject's tasks, e.g. m-test
5970
$(MAKE) -C maintenance $*
6071

61-
osr-%:
62-
@# Help: Runs os-resource subproject's tasks, e.g. osr-test
72+
osr-%: ## Runs os-resource subproject's tasks, e.g. osr-test
6373
$(MAKE) -C os-resource $*
6474

65-
t-%:
66-
@# Help: Runs telemetry subproject's tasks, e.g. t-test
75+
t-%: ## Runs telemetry subproject's tasks, e.g. t-test
6776
$(MAKE) -C telemetry $*
6877

69-
a-%:
70-
@# Help: Runs attestation subproject's tasks, e.g. a-test
78+
a-%: ## Runs attestationstatus subproject's tasks, e.g. a-test
7179
$(MAKE) -C attestationstatus $*
7280

73-
# TODO: move to a common file shared with common.mk
74-
venv_infra: requirements.txt ## Create Python venv
75-
python3 -m venv $@ ;\
76-
set +u; . ./$@/bin/activate; set -u ;\
77-
python -m pip install --upgrade pip ;\
78-
python -m pip install -r requirements.txt
79-
80-
license: venv_infra ## Check licensing with the reuse tool
81-
set +u; . ./$</bin/activate; set -u ;\
82-
reuse --version ;\
83-
reuse --root . lint
84-
85-
dependency-check:
86-
echo "No-op to enable CI to pass"
87-
88-
help:
89-
@printf "%-20s %s\n" "Target" "Description"
90-
@printf "%-20s %s\n" "------" "-----------"
91-
@grep -E '^[a-zA-Z0-9_%-]+:|^[[:space:]]+@# Help:' Makefile | \
92-
awk '\
93-
/^[a-zA-Z0-9_%-]+:/ { \
94-
target = $$1; \
95-
sub(":", "", target); \
96-
} \
97-
/^[[:space:]]+@# Help:/ { \
98-
if (target != "") { \
99-
help_line = $$0; \
100-
sub("^[[:space:]]+@# Help: ", "", help_line); \
101-
printf "%-20s %s\n", target, help_line; \
102-
target = ""; \
103-
} \
104-
}'
81+
#### Help Target ####
82+
help: ## print help for each target
83+
@echo infra-managers make targets
84+
@echo "Target Makefile:Line Description"
85+
@echo "-------------------- ---------------- -----------------------------------------"
86+
@grep -H -n '^[[:alnum:]%_-]*:.* ##' $(MAKEFILE_LIST) \
87+
| sort -t ":" -k 3 \
88+
| awk 'BEGIN {FS=":"}; {sub(".* ## ", "", $$4)}; {printf "%-20s %-16s %s\n", $$3, $$1 ":" $$2, $$4};'

attestationstatus/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PROTOCGENGRPCGATEWAY := true
2626

2727
# Project variables
2828
PROJECT_NAME := attestationstatusmgr
29+
PROJECT_NICKNAME := a
2930
BINARY_NAME := ${PROJECT_NAME}
3031

3132
# Code versions, tags, and so on
@@ -34,6 +35,7 @@ VERSION_MAJOR := $(shell cut -c 1 VERSION)
3435
DOCKER_IMG_NAME := $(PROJECT_NAME)
3536
DOCKER_VERSION ?= $(shell git branch --show-current | sed 's/\//_/g')
3637
GIT_COMMIT ?= $(shell git rev-parse HEAD)
38+
GIT_TAG_PREFIX := attestationstatus/v
3739

3840
# Test variables
3941
# Set TEST_TARGET to '<testname1>' or '<testname1\|testname2>' to run specific tests or use regex '<testname.*>' - example:

attestationstatus/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.0
1+
0.5.1-dev

common.mk

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ DEPS := go.mod go.sum
4141

4242
# Docker variables
4343
DOCKER_ENV := DOCKER_BUILDKIT=1
44-
DOCKER_REGISTRY ?= 080137407410.dkr.ecr.us-west-2.amazonaws.com
45-
DOCKER_REPOSITORY ?= edge-orch/infra
46-
DOCKER_TAG := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_IMG_NAME):$(VERSION)
47-
DOCKER_TAG_BRANCH := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_IMG_NAME):$(DOCKER_VERSION)
44+
OCI_REGISTRY ?= 080137407410.dkr.ecr.us-west-2.amazonaws.com
45+
OCI_REPOSITORY ?= edge-orch
46+
DOCKER_SECTION := infra
47+
DOCKER_REGISTRY ?= $(OCI_REGISTRY)
48+
DOCKER_REPOSITORY ?= $(OCI_REPOSITORY)
49+
DOCKER_TAG := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_SECTION)/$(DOCKER_IMG_NAME):$(VERSION)
50+
DOCKER_TAG_BRANCH := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_SECTION)/$(DOCKER_IMG_NAME):$(DOCKER_VERSION)
4851
# Decides if we shall push image tagged with the branch name or not.
4952
DOCKER_TAG_BRANCH_PUSH ?= true
5053
LABEL_REPO_URL ?= $(shell git remote get-url $(shell git remote | head -n 1))
@@ -111,7 +114,7 @@ docker-build: ## Build Docker image
111114
$(GOCMD) mod vendor
112115
cp ../common.mk ../version.mk .
113116
docker build . -f Dockerfile \
114-
-t $(DOCKER_IMG_NAME):$(DOCKER_VERSION) \
117+
-t $(DOCKER_IMG_NAME):$(VERSION) \
115118
--build-arg http_proxy="$(http_proxy)" --build-arg HTTP_PROXY="$(HTTP_PROXY)" \
116119
--build-arg https_proxy="$(https_proxy)" --build-arg HTTPS_PROXY="$(HTTPS_PROXY)" \
117120
--build-arg no_proxy="$(no_proxy)" --build-arg NO_PROXY="$(NO_PROXY)" \
@@ -124,15 +127,19 @@ docker-build: ## Build Docker image
124127
docker-push: ## Tag and push Docker image
125128
# TODO: remove ecr create
126129
aws ecr create-repository --region us-west-2 --repository-name $(DOCKER_REPOSITORY)/$(DOCKER_IMG_NAME) || true
127-
docker tag $(DOCKER_IMG_NAME):$(DOCKER_VERSION) $(DOCKER_TAG_BRANCH)
128-
docker tag $(DOCKER_IMG_NAME):$(DOCKER_VERSION) $(DOCKER_TAG)
130+
docker tag $(DOCKER_IMG_NAME):$(VERSION) $(DOCKER_TAG_BRANCH)
131+
docker tag $(DOCKER_IMG_NAME):$(VERSION) $(DOCKER_TAG)
129132
docker push $(DOCKER_TAG)
130133
ifeq ($(DOCKER_TAG_BRANCH_PUSH), true)
131134
docker push $(DOCKER_TAG_BRANCH)
132135
endif
133136

134-
docker-list: ## Print all container image names with tags
135-
docker images --format "{{.Repository}}:{{.Tag}}"
137+
docker-list: ## Print name of docker container image
138+
@echo " $(DOCKER_IMG_NAME):"
139+
@echo " name: '$(DOCKER_TAG)'"
140+
@echo " version: '$(VERSION)'"
141+
@echo " gitTagPrefix: '$(GIT_TAG_PREFIX)'"
142+
@echo " buildTarget: '$(PROJECT_NICKNAME)-docker-build'"
136143

137144
#### Python venv Target ####
138145

host/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ PROTOCGENGRPCGATEWAY := true
2828

2929
# Project variables
3030
PROJECT_NAME := hostmgr
31+
PROJECT_NICKNAME := h
3132
BINARY_NAME := $(PROJECT_NAME)
3233

3334
# Code versions, tags, and so on
@@ -36,6 +37,7 @@ VERSION_MAJOR := $(shell cut -c 1 VERSION)
3637
DOCKER_IMG_NAME := $(PROJECT_NAME)
3738
DOCKER_VERSION ?= $(shell git branch --show-current | sed 's/\//_/g')
3839
GIT_COMMIT ?= $(shell git rev-parse HEAD)
40+
GIT_TAG_PREFIX := host/v
3941

4042
# Test variables
4143
# Set TEST_TARGET to '<testname1>' or '<testname1\|testname2>' to run specific tests or use regex '<testname.*>' - example:

host/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.21.0
1+
1.21.1-dev

maintenance/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ PROTOCGENVALIDATEGO := true
2525

2626
# Project variables
2727
PROJECT_NAME := maintmgr
28+
PROJECT_NICKNAME := m
2829
BINARY_NAME := $(PROJECT_NAME)
2930

3031
# Code versions, tags, and so on
@@ -33,6 +34,7 @@ VERSION_MAJOR := $(shell cut -c 1 VERSION)
3334
DOCKER_IMG_NAME := $(PROJECT_NAME)
3435
DOCKER_VERSION ?= $(shell git branch --show-current | sed 's/\//_/g')
3536
GIT_COMMIT ?= $(shell git rev-parse HEAD)
37+
GIT_TAG_PREFIX := maintenance/v
3638

3739
# Test variables
3840
# Set TEST_TARGET to '<testname1>' or '<testname1\|testname2>' to run specific tests or use regex '<testname.*>' - example:

maintenance/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.21.0
1+
1.21.1-dev

networking/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ GOJUNITREPORT := true
1919

2020
# Project variables
2121
PROJECT_NAME := netmgr
22+
PROJECT_NICKNAME := n
2223
BINARY_NAME := $(PROJECT_NAME)
2324

2425
# Code Versions
@@ -27,6 +28,7 @@ VERSION_MAJOR := $(shell cut -c 1 VERSION)
2728
DOCKER_IMG_NAME := $(PROJECT_NAME)
2829
DOCKER_VERSION ?= $(shell git branch --show-current | sed 's/\//_/g')
2930
GIT_COMMIT ?= $(shell git rev-parse HEAD)
31+
GIT_TAG_PREFIX := networking/v
3032

3133
# Test variables
3234
# Set TEST_TARGET to '<testname1>' or '<testname1\|testname2>' to run specific tests or use regex '<testname.*>' - example:

0 commit comments

Comments
 (0)