Skip to content

Commit 84f15d0

Browse files
authored
Chore: Reduce verbosity of buildall (#247)
1 parent e6d3819 commit 84f15d0

File tree

8 files changed

+84
-67
lines changed

8 files changed

+84
-67
lines changed

buildall/Makefile

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ SCRATCH_DIR := scratch
2626
CHARTS_DIR := charts
2727

2828
$(REPO_DIR):
29-
mkdir -p $@
29+
@mkdir -p $@
3030

3131
$(SCRATCH_DIR):
32-
mkdir -p $@
32+
@mkdir -p $@
3333

3434
$(CHARTS_DIR):
35-
mkdir -p $@
35+
@mkdir -p $@
3636

3737
check: ## check for prereqs (currently noOp)
3838

@@ -48,7 +48,8 @@ VENV_DIR := venv_$(PROJECT_NAME)
4848

4949
# virtualenv activate script has undefined variables, disable then re-enable in bash
5050
$(VENV_DIR): requirements.txt
51-
python3 -m venv $@ ;\
51+
@echo "## Building Python Virtualenv ##"
52+
@python3 -m venv $@ ;\
5253
set +u; . ./$@/bin/activate; set -u ;\
5354
python -m pip install --upgrade pip ;\
5455
python -m pip install -r requirements.txt
@@ -86,18 +87,16 @@ $(REPO_DIR)/%: | $(REPO_LIST)
8687
git clone https://github.com/$(GITHUB_ORG)/$*.git $(REPO_DIR)/$*
8788

8889
checkout-repos: $(REPOS) | $(REPO_LIST) ## checkout all repos
89-
@echo "All checked out"
90+
@echo "## All repos have been checked out ##"
9091

9192
GIT_BRANCH ?= main
92-
branch-checkout: checkout-repos ## refresh and checkout all repos with a specific branch
93-
for repo in $(REPOS); do \
93+
branch-checkout: checkout-repos ## refresh and checkout all repos at branch GIT_BRANCH (default: main)
94+
@for repo in $(REPOS); do \
9495
pushd $$repo ;\
9596
git checkout $(GIT_BRANCH) ; git pull --ff-only ;\
9697
popd ;\
9798
done
9899

99-
# git fetch ; git checkout $(GIT_BRANCH) ; git pull --ff-only ;\
100-
#
101100
# Check if there are the right make targets needed in the repo
102101
MAKEFILE_CHECKS := $(addprefix $(SCRATCH_DIR)/make_check_, $(shell tr '\n' ' ' < $(REPO_LIST)))
103102
check-makefiles: $(REPOS) | $(MAKEFILE_CHECKS)
@@ -106,64 +105,65 @@ $(SCRATCH_DIR)/make_check_%:
106105
$(SCRIPTS_DIR)/check_makefile.sh repos/$* |tee $@
107106

108107
## targets used to run buildall ##
109-
110108
buildall: $(SCRATCH_DIR) ## perform the entire build
111-
$(SCRIPTS_DIR)/buildall.sh
109+
@$(SCRIPTS_DIR)/buildall.sh
112110

113-
timed-buildall: $(SCRATCH_DIR)
111+
timed-buildall: $(SCRATCH_DIR) ## perform the entire build with build times and verbose output
114112
$(SCRIPTS_DIR)/timed_buildall.sh
115113

116114
# list all artifacts used in each repo
117115
ARTIFACT_LIST := $(addprefix $(SCRATCH_DIR)/artifacts_, $(addsuffix .yaml, $(shell tr '\n' ' ' < $(REPO_LIST))))
118116
list-artifacts: $(REPOS) | $(SCRATCH_DIR) $(ARTIFACT_LIST) ## list charts/images provided by each repo
117+
@echo "## All artifact lists have been created ##"
119118

120119
$(SCRATCH_DIR)/artifacts_%.yaml:
121-
$(SCRIPTS_DIR)/list_artifacts.sh repos/$* |tee $@
120+
@echo "### Generating artifact list in 'repos/$*' ###" ;\
121+
$(SCRIPTS_DIR)/list_artifacts.sh repos/$* > $@
122122

123123
# determine work needed with orch-deploy manifest
124124
chart-manifest: $(SCRATCH_DIR)/manifest_charts.yaml ## build chart manifest
125125

126126
$(SCRATCH_DIR)/manifest_charts.yaml: $(SCRATCH_DIR)
127-
pushd .. ;\
128-
echo "### Generating releaseManifest ####" ;\
127+
@pushd .. > /dev/null ;\
128+
echo "## Generating releaseManifest of required helm charts ##" ;\
129129
mage gen:releaseManifest $(PROJECT_NAME)/$@ ;\
130-
echo "### Generated releaseManifest ####" ;\
131-
popd
130+
popd > /dev/null
132131

133132
sort-charts: $(VENV_DIR) ## determine which repos can build charts required by manifest, and write to htags_
134-
set +u; . ./$</bin/activate; set -u ;\
133+
@set +u; . ./$</bin/activate; set -u ;\
135134
python scripts/sort_charts.py
136135

137136
image-manifest: $(SCRATCH_DIR)/manifest_images.yaml ## build image manifest
138137
$(SCRATCH_DIR)/manifest_images.yaml: $(SCRATCH_DIR)
139-
pushd .. ;\
140-
echo "### Generating localReleaseImageManifest from charts ####" ;\
138+
@pushd .. > /dev/null ;\
139+
echo "## Generating localReleaseImageManifest of docker images from charts ###" ;\
141140
mage gen:localReleaseImageManifest $(PROJECT_NAME)/$@ > $(PROJECT_NAME)/$@.log ;\
142-
echo "### Generated localReleaseImageManifest ####" ;\
143-
popd
141+
popd > /dev/null
144142

145143
sort-images: $(VENV_DIR) ## determine which repos can build images required by manifest, and write to itags_
146-
set +u; . ./$</bin/activate; set -u ;\
144+
@set +u; . ./$</bin/activate; set -u ;\
147145
python scripts/sort_images.py
148146

149147
# build charts
150148
HELM_BUILDS := $(addprefix $(SCRATCH_DIR)/hbuild_, $(shell tr '\n' ' ' < $(REPO_LIST)))
151149
helm-build: $(HELM_BUILDS) $(CHARTS_DIR) ## build all helm charts
150+
@echo "## All helm charts have been created ##"
152151

153152
$(SCRATCH_DIR)/hbuild_%: $(CHARTS_DIR)
154-
$(SCRIPTS_DIR)/helm_build.sh $* $@
153+
@$(SCRIPTS_DIR)/helm_build.sh $* $@
155154

156-
clean-helm: ## clean up helm charts to rebuild
155+
clean-helm: ## clean up helm chart scratchfiles to force rebuild
157156
rm -rf $(SCRATCH_DIR)/hbuild_*
158157

159158
# build images
160159
IMAGE_BUILDS := $(addprefix $(SCRATCH_DIR)/ibuild_, $(shell tr '\n' ' ' < $(REPO_LIST)))
161160
image-build: $(IMAGE_BUILDS) ## build all container images
161+
@echo "## All docker images have been created ##"
162162

163163
$(SCRATCH_DIR)/ibuild_%:
164-
$(SCRIPTS_DIR)/image_build.sh $* $@
164+
@$(SCRIPTS_DIR)/image_build.sh $* $@
165165

166-
clean-image: ## clean up docker images to rebuild
166+
clean-image: ## clean up docker image scratchfiles to force rebuild
167167
rm -rf $(SCRATCH_DIR)/ibuild_*
168168

169169
clean: clean-helm clean-image ## clean up scratch files

buildall/README.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ To ensure that a tested Best Known Configuration set of components are used,
77
the versions rebuilt are derived from the versions specified in the current
88
checkout of the `edge-manageability-framework` repository.
99

10+
Please see the [Edge Orchestrator docs on
11+
buildall](https://docs.openedgeplatform.intel.com/edge-manage-docs/main/developer_guide/platform/buildall.html)
12+
to decide whether this process is suitable for your development or deployment
13+
process.
14+
1015
## Prerequisites
1116

1217
Performing a buildall requires the following tools to be installed in a
@@ -18,13 +23,26 @@ Linux/Unix like environment:
1823
- The built docker images require around 5GB of space
1924
- Approximately roughly 50GB for build cache. See `DOCKER_PRUNE` below
2025
to optionally prune the build cache during the build process.
21-
- Helm 3
26+
- Helm 3 (3.17 or later recommended)
2227
- Python 3 (in-support version such as 3.10 or later, tested on 3.12)
23-
- Mage
24-
25-
Additionally, some of the containers that are build require the following
26-
27-
- Open Policy Agent v0.69.0 (or possibly later) for infra-core repo
28+
- Mage 1.15 or later
29+
30+
Additionally, some of the Makefiles in component repos require the following
31+
dependencies to run properly:
32+
33+
- Open Policy Agent (`opa` cli tool) v0.69.0 (or possibly later) for infra-core repo
34+
- golangci-lint (v1.64.8 or later)
35+
- go-junit-report (v2.1.0 or later)
36+
- oapi-codegen (v1.12.0 or later)
37+
- protoc-gen-doc (1.5.1 or later)
38+
- buf (1.45.0 or later)
39+
- protoc-gen-go-grpc (1.2.0 or later)
40+
- protoc-gen-go (v1.30.0 or later)
41+
- protoc-gen-openapi (latest from
42+
https://github.com/kollalabs/protoc-gen-openapi)
43+
- protoc-gen-grpc-gateway (v2.26.3)
44+
- swagger (4.0.4 or later)
45+
- yq (4.44.3 or later)
2846

2947
## Configuration
3048

@@ -47,6 +65,8 @@ docker build, set `DOCKER_PRUNE` to `Y`.
4765

4866
## Usage
4967

68+
### Build
69+
5070
All commands are run using `make`.
5171

5272
You can get a list of all the make targets with `make help`
@@ -57,7 +77,8 @@ To run the full process with the BKC from the currently checked out copy of
5777
To cleanup internal scratch state, run `make clean`
5878

5979
To fully cleanup (including tools), run `make clean-all`. Note that this only
60-
cleans up local files, not container images that were built.
80+
cleans up local files, not container images that were built, which can be done
81+
with `docker rmi` or similar commands.
6182

6283
### How it works
6384

buildall/env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export DOCKER_PRUNE=
3333
# don't color output
3434
export NO_COLOR=1
3535

36+
# avoid checking for tool versions/presence
37+
export TOOL_VERSION_CHECK=0
38+
3639
# Github Token - used to build certain images
3740
# Obtain from: https://github.com/settings/tokens
3841
export GITHUB_TOKEN=

buildall/scripts/buildall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# buildall.sh
77

8-
set -xeu -o pipefail
8+
set -eu -o pipefail
99

1010
# bring in environmental variables. Where MAKE_JOBS is set
1111
source env.sh

buildall/scripts/helm_build.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ fi
3434
TAGS_PATH="scratch/htags_${REPO}"
3535

3636
if [ ! -f "${TAGS_PATH}" ]; then
37-
echo "'${TAGS_PATH}' does not exist, so repo does not create any helm charts"
37+
echo "### No helm charts built in repos/${REPO} ###"
3838
exit 0
3939
fi
4040

4141
TAG_FILE=$(cat "${TAGS_PATH}")
4242

43-
pushd "${REPO_PATH}"
43+
pushd "${REPO_PATH}" >> "${LOGFILE}"
4444
for tline in $TAG_FILE; do
4545

4646
tag=$(cut -d '|' -f 1 <<< "$tline")
@@ -51,33 +51,32 @@ pushd "${REPO_PATH}"
5151
outDir="."
5252
fi
5353

54-
git switch --detach "${tag}"
54+
git switch --detach "${tag}" >> "${LOGFILE}" 2>&1
5555

5656
# check if helm-build target exists in Makefile
57-
set +eu
57+
set +e
5858
HELM_BUILD_TARGET=$(grep ^helm-build Makefile)
59-
set -eu
59+
set -e
6060

6161
if [ ! "${HELM_BUILD_TARGET}" ]; then
62-
echo "### Copying Makefile from main branch as helm-build target doesn't exist ###"
63-
git checkout main Makefile
62+
echo "#### Copying Makefile from main branch as helm-build target doesn't exist ####" \
63+
| tee -a "${LOGFILE}"
64+
git checkout main Makefile >> "${LOGFILE}" 2>&1
6465
fi
6566

66-
echo "### Starting make helm-build in: '${REPO}', tag: '${tag}' ###"
67+
echo "### Running 'make helm-build' in 'repos/${REPO}', tag: '${tag}' ###"
6768

6869
make helm-build >> "${LOGFILE}" 2>&1
6970

7071
mv "${outDir}"/*.tgz ../../charts
7172

7273
# clean up repo
73-
git checkout HEAD .
74-
75-
echo "### Finished make helm-build in: '${REPO}', tag: '${tag}', output in: '${outDir}' ###"
74+
git checkout HEAD . >> "${LOGFILE}" 2>&1
7675

7776
done
78-
popd
77+
popd >> "${LOGFILE}"
7978

8079
END_TS=$(date +"%s")
8180
ELAPSED=$(( END_TS - START_TS ))
8281

83-
echo "### helm-build took ${ELAPSED} seconds in repo: '${REPO}' ###"
82+
echo "### All helm chart builds complete in 'repos/${REPO}', took ${ELAPSED}s ###"

buildall/scripts/image_build.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ fi
3434
TAGS_PATH="scratch/itags_${REPO}"
3535

3636
if [ ! -f "${TAGS_PATH}" ]; then
37-
echo "'${TAGS_PATH}' does not exist, so repo does not create any container images"
37+
echo "### No docker images built in repos/${REPO} ###"
3838
exit 0
3939
fi
4040

4141
TAG_FILE=$(cat "${TAGS_PATH}")
4242

43-
pushd "${REPO_PATH}"
43+
pushd "${REPO_PATH}" >> "${LOGFILE}"
4444
for tline in $TAG_FILE; do
4545

4646
tag=$(cut -d '|' -f 1 <<< "$tline")
@@ -51,9 +51,9 @@ pushd "${REPO_PATH}"
5151
target='docker-build'
5252
fi
5353

54-
echo "*** Starting docker build in: '${REPO}', tag: '${tag}', target: '${target}' ***"
54+
echo "### Running 'make ${target}' in 'repos/${REPO}', tag: '${tag}' ###"
5555

56-
git switch --detach "${tag}"
56+
git switch --detach "${tag}" >> "${LOGFILE}" 2>&1
5757

5858
# regex matches all the end-of-string numbers/dots
5959
if [[ "${tag}" =~ ([0-9.]+)$ ]]
@@ -68,16 +68,15 @@ pushd "${REPO_PATH}"
6868
GITHUB_TOKEN=$GITHUB_TOKEN \
6969
make "${target}" >> "${LOGFILE}" 2>&1
7070

71-
echo "*** Finished docker build in: '${REPO}', tag: '${tag}', target: '${target}' ***"
7271
done
73-
popd
72+
popd >> "${LOGFILE}"
7473

7574
# optionally cleanup docker buildx cache
7675
if [ -n "${DOCKER_PRUNE}" ]; then
77-
echo "### Pruning docker buildx cache ###"
78-
docker buildx prune -f
76+
echo "#### Pruning docker buildx cache ####" | tee "${LOGFILE}"
77+
docker buildx prune -f >> "${LOGFILE}" 2>&1
7978
fi
8079

8180
END_TS=$(date +"%s")
8281
ELAPSED=$(( END_TS - START_TS ))
83-
echo "### Docker build in: '${REPO}' took ${ELAPSED} seconds ###"
82+
echo "### All docker image builds complete in: 'repos/${REPO}', took ${ELAPSED}s ###"

buildall/scripts/sort_charts.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ def match_charts(chart_mf, chart_to_repo, artifacts):
7373
for line in data["charts"]:
7474
htagout.write(f"{line}\n")
7575

76-
print("chart builds needed in each repo:")
77-
yaml.dump(repo_tags_to_build, sys.stdout)
78-
79-
if req_charts: # only print missing charts if they exist
80-
print(f"missing charts: {req_charts}")
76+
if req_charts: # die if missing charts if they exist
77+
print(f"ERROR - Missing charts: {req_charts}")
78+
sys.exit(1)

buildall/scripts/sort_images.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ def parse_image_manifest(image_mf_raw):
5353
if len(split) == 1:
5454
name, version = split[0]
5555
else:
56-
print(f"Underspecified image name: {rawi}")
56+
print(f"INFO: Underspecified image name: {rawi}")
5757

5858
if name in image_mf_fix["images"]:
5959
if image_mf_fix["images"][name]["registry"] != registry:
6060
print(
61-
f"Duplicate image: '{name}' has registry '{registry}' which "
61+
f"INFO: Duplicate image: '{name}' has registry '{registry}' which "
6262
f"doesn't match earlier '{image_mf_fix['images'][name]['registry']}'"
6363
)
6464
else:
@@ -102,9 +102,6 @@ def match_images(image_mf, image_to_repo, artifacts):
102102

103103
match_images(image_manifest, itr, repo_artifacts)
104104

105-
print("builds needed in each repo")
106-
print(repo_tags_to_build)
107-
108105
for rname, data in repo_tags_to_build.items():
109106
if data["images"]: # If there are charts in the repo
110107

0 commit comments

Comments
 (0)