Skip to content

Commit f6713f5

Browse files
author
Zack Williams
committed
DRAFT Add Buildall automation
Add additional data to docker-list command - tag - version - use actual version instead of parsed branch information which doesn't build properly with tags - git tag prefix - build target - add nickname to avoid building more than is needed Fix spelling of LENGTH fix einv-* target in root Makefile
1 parent 4873b40 commit f6713f5

7 files changed

Lines changed: 34 additions & 16 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ docker-push: ## push all docker containers
4949
for dir in $(DOCKER_PROJECTS); do $(MAKE) -C $$dir $@; done
5050

5151
docker-list: ## list all docker containers
52+
@echo "images:"
5253
@for dir in $(DOCKER_PROJECTS); do $(MAKE) -C $$dir $@; done
5354

5455
test: ## test in all subprojects
@@ -68,7 +69,7 @@ bit-%: ## Run bulk-import-tools subproject's tasks, e.g. bit-test
6869
$(MAKE) -C bulk-import-tools $*
6970

7071
einv-%: ## Run exporters-inventory subproject's tasks, e.g. einv-test
71-
$(MAKE) -C exporter-inventory $*
72+
$(MAKE) -C exporters-inventory $*
7273

7374
inv-%: ## Run inventory subproject's tasks, e.g. inv-test
7475
$(MAKE) -C inventory $*

api/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ SWAGGERCLI := true
2222

2323
# Project variables
2424
PROJECT_NAME := api
25+
PROJECT_NICKNAME := api
2526
BINARY_NAME := $(PROJECT_NAME)
2627

2728
# Code versions, tags, and so on
@@ -31,6 +32,7 @@ VERSION_MAJOR := 0
3132
DOCKER_IMG_NAME := $(PROJECT_NAME)
3233
DOCKER_VERSION ?= $(shell git branch --show-current | sed 's/\//_/g')
3334
GIT_COMMIT ?= $(shell git rev-parse HEAD)
35+
GIT_TAG_PREFIX := $(PROJECT_NAME)/v
3436

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

bulk-import-tools/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ PROTOCGENDOC := true
1919

2020
# Project variables
2121
PROJECT_NAME := bulk-import-tools
22+
PROJECT_NICKNAME := bit
2223
BULK_IMPORT_BINARY_NAME := orch-host-bulk-import
2324
PREFLIGHT_BINARY_NAME := orch-host-preflight
2425

2526
# Versioning variables
26-
VERSION := $(shell cat VERSION)
27-
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
27+
VERSION := $(shell cat VERSION)
28+
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
29+
GIT_TAG_PREFIX := $(PROJECT_NAME)/v
2830

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

common.mk

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,24 @@ DEPS := go.mod go.sum
3434
# Docker variables
3535
DOCKER_ENV := DOCKER_BUILDKIT=1
3636
OCI_REGISTRY ?= 080137407410.dkr.ecr.us-west-2.amazonaws.com
37-
OCI_REPOSITORY ?= edge-orch/infra
37+
OCI_REPOSITORY ?= edge-orch
38+
DOCKER_SECTION := infra
3839
DOCKER_REGISTRY ?= $(OCI_REGISTRY)
3940
DOCKER_REPOSITORY ?= $(OCI_REPOSITORY)
40-
DOCKER_TAG := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_IMG_NAME):$(VERSION)
41-
DOCKER_TAG_BRANCH := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_IMG_NAME):$(DOCKER_VERSION)
41+
DOCKER_TAG := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_SECTION)/$(DOCKER_IMG_NAME):$(VERSION)
42+
DOCKER_TAG_BRANCH := $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY)/$(DOCKER_SECTION)/$(DOCKER_IMG_NAME):$(DOCKER_VERSION)
4243
# Decides if we shall push image tagged with the branch name or not.
4344
DOCKER_TAG_BRANCH_PUSH ?= true
4445
LABEL_REPO_URL ?= $(shell git remote get-url $(shell git remote | head -n 1))
4546
LABEL_VERSION ?= $(VERSION)
4647
LABEL_REVISION ?= $(GIT_COMMIT)
4748
LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
4849

49-
DB_CONTAINER_NAME := $(PROJECT_NAME)-db
50+
DB_CONTAINER_NAME := $(PROJECT_NAME)-db
5051

5152
YAML_FILES := $(shell find . -type f \( -name '*.yaml' -o -name '*.yml' \) -print )
5253
YAML_IGNORE ?= vendor, .github/workflows, $(VENV_NAME)
53-
YAML_LINE_LENGHT ?= 99
54+
YAML_LINE_LENGTH ?= 99
5455

5556
# Docker networking flags for the database container.
5657
# The problem is as follows: On a local MacOS machine we want to expose the port
@@ -106,7 +107,7 @@ common-docker-build: ## Build Docker image
106107
$(GOCMD) mod vendor
107108
cp ../common.mk ../version.mk .
108109
docker build . -f Dockerfile \
109-
-t $(DOCKER_IMG_NAME):$(DOCKER_VERSION) \
110+
-t $(DOCKER_IMG_NAME):$(VERSION) \
110111
--build-arg http_proxy="$(http_proxy)" --build-arg HTTP_PROXY="$(HTTP_PROXY)" \
111112
--build-arg https_proxy="$(https_proxy)" --build-arg HTTPS_PROXY="$(HTTPS_PROXY)" \
112113
--build-arg no_proxy="$(no_proxy)" --build-arg NO_PROXY="$(NO_PROXY)" \
@@ -119,15 +120,19 @@ common-docker-build: ## Build Docker image
119120
common-docker-push: ## Tag and push Docker image
120121
# TODO: remove ecr create
121122
aws ecr create-repository --region us-west-2 --repository-name $(DOCKER_REPOSITORY)/$(DOCKER_IMG_NAME) || true
122-
docker tag $(DOCKER_IMG_NAME):$(DOCKER_VERSION) $(DOCKER_TAG_BRANCH)
123-
docker tag $(DOCKER_IMG_NAME):$(DOCKER_VERSION) $(DOCKER_TAG)
123+
docker tag $(DOCKER_IMG_NAME):$(VERSION) $(DOCKER_TAG_BRANCH)
124+
docker tag $(DOCKER_IMG_NAME):$(VERSION) $(DOCKER_TAG)
124125
docker push $(DOCKER_TAG)
125126
ifeq ($(DOCKER_TAG_BRANCH_PUSH), true)
126127
docker push $(DOCKER_TAG_BRANCH)
127128
endif
128129

129130
docker-list: ## Print name of docker container image
130-
@echo $(DOCKER_TAG)
131+
@echo " $(DOCKER_IMG_NAME):"
132+
@echo " name: '$(DOCKER_TAG)'"
133+
@echo " version: '$(VERSION)'"
134+
@echo " gitTagPrefix: '$(GIT_TAG_PREFIX)'"
135+
@echo " buildTarget: '$(PROJECT_NICKNAME)-docker-build'"
131136

132137
#### Python venv Target ####
133138

@@ -169,10 +174,12 @@ checksec: go-build ## Check various security properties that are available for e
169174
checksec --output=json --file=$(OUT_DIR)/$(BINARY_NAME)
170175
checksec --fortify-file=$(OUT_DIR)/$(BINARY_NAME)
171176

177+
YAML_FILES := $(shell find . -type f \( -name '*.yaml' -o -name '*.yml' \) -print )
178+
YAML_IGNORE ?= vendor, .github/workflows, $(VENV_NAME)
172179
yamllint: $(VENV_NAME) ## Lint YAML files
173180
. ./$</bin/activate; set -u ;\
174181
yamllint --version ;\
175-
yamllint -d '{extends: default, rules: {line-length: {max: $(YAML_LINE_LENGHT)}}, ignore: [$(YAML_IGNORE)]}' -s $(YAML_FILES)
182+
yamllint -d '{extends: default, rules: {line-length: {max: $(YAML_LINE_LENGTH)}}, ignore: [$(YAML_IGNORE)]}' -s $(YAML_FILES)
176183

177184
mdlint: ## Link MD files
178185
markdownlint --version ;\

exporters-inventory/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GOCOBERTURA := true
1818

1919
# Project variables
2020
PROJECT_NAME := exporter
21+
PROJECT_NICKNAME := einv
2122
BINARY_NAME := $(PROJECT_NAME)
2223

2324
# Code versions, tags, and so on
@@ -26,6 +27,7 @@ VERSION_MAJOR := $(shell cut -c 1 VERSION)
2627
DOCKER_IMG_NAME := $(PROJECT_NAME)
2728
DOCKER_VERSION ?= $(shell git branch --show-current | sed 's/\//_/g')
2829
GIT_COMMIT ?= $(shell git rev-parse HEAD)
30+
GIT_TAG_PREFIX := exporters-inventory/v
2931

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

inventory/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ PROTOCGENGOGRPC := true
2727

2828
# Project variables
2929
PROJECT_NAME := inventory
30+
PROJECT_NICKNAME := inv
3031
BINARY_NAME := $(PROJECT_NAME)
3132

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

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

tenant-controller/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ OPA := true
1919
PROTOCGENENT := true
2020

2121
# Project variables
22-
PROJECT_NAME := tenant-controller
23-
BINARY_NAME := $(PROJECT_NAME)
22+
PROJECT_NAME := tenant-controller
23+
PROJECT_NICKNAME := tc
24+
BINARY_NAME := $(PROJECT_NAME)
2425

2526
# Versioning variables
2627
VERSION := $(shell cat VERSION)
2728
VERSION_MAJOR := $(shell cut -c 1 VERSION)
2829
DOCKER_IMG_NAME := $(PROJECT_NAME)
2930
DOCKER_VERSION ?= $(shell git branch --show-current | sed 's/\//_/g')
3031
GIT_COMMIT ?= $(shell git rev-parse HEAD)
32+
GIT_TAG_PREFIX := $(PROJECT_NAME)/v
3133

3234
# Test variables
3335
# Set TEST_TARGET to '<testname1>' or '<testname1\|testname2>' to run specific tests or use regex '<testname.*>' - example:
@@ -66,7 +68,7 @@ buf-lint: common-buf-lint ## Lint and format protobuf files
6668
#### Development Targets ####
6769

6870
build: go-build ## Build local binaries
69-
71+
7072
lint: $(OUT_DIR) license yamllint hadolint go-lint mdlint ## Run all lint tools
7173

7274
test: $(OUT_DIR) go-test ## Run all unit tests

0 commit comments

Comments
 (0)