Skip to content

Commit

Permalink
[bugfix] gcc environment for ARM Fix format-diff error problem (#2345)…
Browse files Browse the repository at this point in the history
… Merge branch 'main' into bugfix/docker/gcc-environment-for-arm fix: warning message for diff Bugfix go binary execution for format and crd (#2348) fix: checkout cargo.lock file Bugfix go binary execution for format and crd (#2348)

Fix setup-helm version (#2349)

Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed Feb 14, 2024
1 parent 82380d8 commit d6f06c1
Show file tree
Hide file tree
Showing 45 changed files with 380 additions and 439 deletions.
4 changes: 3 additions & 1 deletion .github/actions/setup-helm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ runs:
echo "version=${HELM_VERSION}" >> $GITHUB_OUTPUT
env:
HELM_VERSION: ${{ inputs.helm_version }}
- uses: azure/setup-helm@v3
# This will change when the v4 version is released.
# Ref: https://github.com/Azure/setup-helm/issues/126
- uses: azure/[email protected]
with:
version: ${{ steps.helm_version.outputs.version }}
- name: Check Helm version
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/dockers-agent-faiss-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: "Build docker image: agent-faiss"
on:
push:
branches:
- "main"
- "release/v*.*"
- "!release/v*.*.*"
tags:
- "*.*.*"
- "v*.*.*"
- "*.*.*-*"
- "v*.*.*-*"
paths:
- ".github/actions/docker-build/actions.yaml"
- ".github/workflows/_docker-image.yaml"
- ".github/workflows/dockers-agent-faiss-image.yml"
- "go.mod"
- "go.sum"
- "internal/**"
- "!internal/**/*_test.go"
- "!internal/db/**"
- "!internal/k8s/**"
- "apis/grpc/**"
- "pkg/agent/core/faiss/**"
- "cmd/agent/core/faiss/**"
- "dockers/agent/core/faiss/Dockerfile"
- "versions/GO_VERSION"
- "versions/FAISS_VERSION"
pull_request:
paths:
- ".github/actions/docker-build/actions.yaml"
- ".github/workflows/_docker-image.yaml"
- ".github/workflows/dockers-agent-faiss-image.yml"
- "go.mod"
- "go.sum"
- "internal/**"
- "!internal/**/*_test.go"
- "!internal/db/**"
- "!internal/k8s/**"
- "apis/grpc/**"
- "pkg/agent/core/faiss/**"
- "cmd/agent/core/faiss/**"
- "dockers/agent/core/faiss/Dockerfile"
- "versions/GO_VERSION"
- "versions/FAISS_VERSION"
pull_request_target:
paths:
- ".github/actions/docker-build/actions.yaml"
- ".github/workflows/_docker-image.yaml"
- ".github/workflows/dockers-agent-faiss-image.yml"
- "go.mod"
- "go.sum"
- "internal/**"
- "!internal/**/*_test.go"
- "!internal/db/**"
- "!internal/k8s/**"
- "apis/grpc/**"
- "pkg/agent/core/faiss/**"
- "cmd/agent/core/faiss/**"
- "dockers/agent/core/faiss/Dockerfile"
- "versions/GO_VERSION"
- "versions/FAISS_VERSION"
jobs:
build:
uses: ./.github/workflows/_docker-image.yaml
with:
target: agent-faiss
platforms: linux/amd64
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/dockers-agent-ngt-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ jobs:
uses: ./.github/workflows/_docker-image.yaml
with:
target: agent-ngt
platforms: linux/amd64,linux/arm64
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/dockers-benchmark-job-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ jobs:
uses: ./.github/workflows/_docker-image.yaml
with:
target: benchmark-job
platforms: linux/amd64,linux/arm64
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/dockers-helm-operator-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ jobs:
uses: ./.github/workflows/_docker-image.yaml
with:
target: operator/helm
platforms: linux/amd64,linux/arm64
secrets: inherit
6 changes: 3 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: Run formatter and license.go
run: |
make format
git checkout go.mod go.sum
git checkout go.mod go.sum ./rust/Cargo.lock
- name: Check and Push to main branch
continue-on-error: true
run: |
Expand Down Expand Up @@ -105,13 +105,13 @@ jobs:
run: |
make deps/install
make format
git checkout go.mod go.sum
git checkout go.mod go.sum ./rust/Cargo.lock
- name: Check format and deps difference
run: |
if git diff --quiet --exit-code; then
echo "Nothing updated"
else
git diff
echo "Please execute \`make format\` and \`make deps/install\` locally."
echo "Please execute \`make format\` locally."
exit 1
fi
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ DATETIME = $(eval DATETIME := $(shell date -u +%Y/%m/%d_%
TAG ?= latest
CRORG ?= $(ORG)
GHCRORG = ghcr.io/$(ORG)/$(NAME)
AGENT_IMAGE = $(NAME)-agent-ngt
AGENT_NGT_IMAGE = $(NAME)-agent-ngt
AGENT_FAISS_IMAGE = $(NAME)-agent-faiss
AGENT_SIDECAR_IMAGE = $(NAME)-agent-sidecar
CI_CONTAINER_IMAGE = $(NAME)-ci-container
DEV_CONTAINER_IMAGE = $(NAME)-dev-container
Expand Down Expand Up @@ -97,6 +98,7 @@ SWAP_TAG ?= latest
BINDIR ?= /usr/local/bin

UNAME := $(eval UNAME := $(shell uname -s))$(UNAME)
OS := $(eval OS := $(shell echo $(UNAME) | tr '[:upper:]' '[:lower:]'))$(OS)
ARCH := $(eval ARCH := $(shell uname -m))$(ARCH)
PWD := $(eval PWD := $(shell pwd))$(PWD)

Expand Down Expand Up @@ -386,11 +388,7 @@ clean-generated:
.PHONY: license
## add license to files
license:
GOPRIVATE=$(GOPRIVATE) \
MAINTAINER=$(MAINTAINER) \
GOARCH=$(GOARCH) \
GOOS=$(GOOS) \
go run -mod=readonly hack/license/gen/main.go $(ROOTDIR)
$(call gen-license,$(ROOTDIR),$(MAINTAINER))

.PHONY: init
## initialize development environment
Expand Down Expand Up @@ -571,7 +569,7 @@ faiss/install: /usr/local/lib/libfaiss.so
curl -LO https://github.com/facebookresearch/faiss/archive/v$(FAISS_VERSION).tar.gz
tar zxf v$(FAISS_VERSION).tar.gz -C $(TEMP_DIR)/
cd $(TEMP_DIR)/faiss-$(FAISS_VERSION) && \
cmake -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -B build . && \
cmake -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -B build . && \
make -C build -j faiss && \
make -C build install
rm -rf v$(FAISS_VERSION).tar.gz
Expand Down
2 changes: 1 addition & 1 deletion Makefile.d/actions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ list/actions:
.PHONY: update/actions
# update github actions version
update/actions:
@$(call update-github-actions, $(ACTIONS_LIST))
$(call update-github-actions, $(ACTIONS_LIST))
26 changes: 13 additions & 13 deletions Makefile.d/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ binary/build: \
cmd/agent/core/ngt/ngt: \
ngt/install
$(eval CGO_ENABLED = 1)
$(call go-build,agent/core/ngt,-linkmode 'external',-fPIC -pthread -fopenmp -std=gnu++20 -lstdc++ -lm -z relro -z now $(EXTLDFLAGS), cgo,NGT-$(NGT_VERSION),$@)
$(call go-build,agent/core/ngt,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lstdc++ -lm -z relro -z now $(EXTLDFLAGS), cgo,NGT-$(NGT_VERSION),$@)

cmd/agent/core/faiss/faiss: \
faiss/install
Expand All @@ -45,50 +45,50 @@ cmd/agent/core/faiss/faiss: \

cmd/agent/sidecar/sidecar:
$(eval CGO_ENABLED = 0)
$(call go-build,agent/sidecar,,,,,$@)
$(call go-build,agent/sidecar,,-static,,,$@)

cmd/discoverer/k8s/discoverer:
$(eval CGO_ENABLED = 0)
$(call go-build,discoverer/k8s,,,,,$@)
$(call go-build,discoverer/k8s,,-static,,,$@)

cmd/gateway/lb/lb:
$(eval CGO_ENABLED = 0)
$(call go-build,gateway/lb,,,,,$@)
$(call go-build,gateway/lb,,-static,,,$@)

cmd/gateway/filter/filter:
$(eval CGO_ENABLED = 0)
$(call go-build,gateway/filter,,,,,$@)
$(call go-build,gateway/filter,,-static,,,$@)

cmd/gateway/mirror/mirror:
$(eval CGO_ENABLED = 0)
$(call go-build,gateway/mirror,,,,,$@)
$(call go-build,gateway/mirror,,-static,,,$@)

cmd/manager/index/index:
$(eval CGO_ENABLED = 0)
$(call go-build,manager/index,,,,,$@)
$(call go-build,manager/index,,-static,,,$@)

cmd/index/job/correction/index-correction:
$(eval CGO_ENABLED = 0)
$(call go-build,index/job/correction,,,,,$@)
$(call go-build,index/job/correction,,-static,,,$@)

cmd/index/job/creation/index-creation:
$(eval CGO_ENABLED = 0)
$(call go-build,index/job/creation,,,,,$@)
$(call go-build,index/job/creation,,-static,,,$@)

cmd/index/job/save/index-save:
$(eval CGO_ENABLED = 0)
$(call go-build,index/job/save,,,,,$@)
$(call go-build,index/job/save,,-static,,,$@)

cmd/index/job/readreplica/rotate/readreplica-rotate:
$(eval CGO_ENABLED = 0)
$(call go-build,index/job/readreplica/rotate,,,,,$@)
$(call go-build,index/job/readreplica/rotate,,-static,,,$@)

cmd/tools/benchmark/job/job:
$(call go-build,tools/benchmark/job,-linkmode 'external',-fPIC -pthread -fopenmp -std=gnu++20 -lhdf5 -lhdf5_hl -lm -ldl, cgo,$(HDF5_VERSION),$@)
$(call go-build,tools/benchmark/job,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lhdf5 -lhdf5_hl -lm -ldl, cgo,$(HDF5_VERSION),$@)

cmd/tools/benchmark/operator/operator:
$(eval CGO_ENABLED = 0)
$(call go-build,tools/benchmark/operator,,,,,$@)
$(call go-build,tools/benchmark/operator,,-static,,,$@)

.PHONY: binary/build/zip
## build all binaries and zip them
Expand Down
8 changes: 4 additions & 4 deletions Makefile.d/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ endif

.PHONY: docker/name/agent-ngt
docker/name/agent-ngt:
@echo "$(ORG)/$(AGENT_IMAGE)"
@echo "$(ORG)/$(AGENT_NGT_IMAGE)"

.PHONY: docker/build/agent-ngt
## build agent-ngt image
docker/build/agent-ngt:
@make DOCKERFILE="$(ROOTDIR)/dockers/agent/core/ngt/Dockerfile" \
IMAGE=$(AGENT_IMAGE) \
IMAGE=$(AGENT_NGT_IMAGE) \
docker/build/image

.PHONY: docker/name/agent-faiss
docker/name/agent-faiss:
@echo "$(ORG)/$(AGENT_IMAGE)"
@echo "$(ORG)/$(AGENT_FAISS_IMAGE)"

.PHONY: docker/build/agent-faiss
## build agent-faiss image
docker/build/agent-faiss:
@make DOCKERFILE="$(ROOTDIR)/dockers/agent/core/faiss/Dockerfile" \
IMAGE=$(AGENT_IMAGE) \
IMAGE=$(AGENT_FAISS_IMAGE) \
docker/build/image

.PHONY: docker/name/agent-sidecar
Expand Down
32 changes: 29 additions & 3 deletions Makefile.d/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ define go-build
GO_VERSION=$(GO_VERSION) \
go build \
--ldflags "-w $2 \
-extldflags '-static $3' \
-extldflags '$3' \
-X '$(GOPKG)/internal/info.AlgorithmInfo=$5' \
-X '$(GOPKG)/internal/info.BuildCPUInfoFlags=$(CPU_INFO_FLAGS)' \
-X '$(GOPKG)/internal/info.BuildTime=$(DATETIME)' \
Expand Down Expand Up @@ -278,15 +278,41 @@ define gen-go-option-test-sources
done
endef

define gen-license
BIN_PATH="$(TEMP_DIR)/vald-license-gen"; \
rm -rf $$BIN_PATH; \
MAINTAINER=$2 \
GOPRIVATE=$(GOPRIVATE) \
GOARCH=$(GOARCH) \
GOOS=$(GOOS) \
go build -mod=readonly -a -o $$BIN_PATH $(ROOTDIR)/hack/license/gen/main.go; \
$$BIN_PATH $1; \
rm -rf $$BIN_PATH
endef

define gen-vald-helm-schema
BIN_PATH="$(TEMP_DIR)/vald-helm-schema-gen"; \
rm -rf $$BIN_PATH; \
GOPRIVATE=$(GOPRIVATE) \
GOARCH=$(GOARCH) \
GOOS=$(GOOS) \
go build -mod=readonly -a -o $$BIN_PATH $(ROOTDIR)/hack/helm/schema/gen/main.go; \
$$BIN_PATH charts/$1.yaml > charts/$1.schema.json; \
rm -rf $$BIN_PATH
endef

define gen-vald-crd
if [[ -f $(ROOTDIR)/charts/$1/crds/$2.yaml ]]; then \
mv $(ROOTDIR)/charts/$1/crds/$2.yaml $(TEMP_DIR)/$2.yaml; \
fi;
BIN_PATH="$(TEMP_DIR)/vald-helm-crd-schema-gen"; \
rm -rf $$BIN_PATH; \
GOPRIVATE=$(GOPRIVATE) \
GOARCH=$(GOARCH) \
GOOS=$(GOOS) \
go run -mod=readonly $(ROOTDIR)/hack/helm/schema/crd/main.go \
$(ROOTDIR)/charts/$3.yaml > $(TEMP_DIR)/$2-spec.yaml
go build -mod=readonly -a -o $$BIN_PATH $(ROOTDIR)/hack/helm/schema/crd/main.go; \
$$BIN_PATH $(ROOTDIR)/charts/$3.yaml > $(TEMP_DIR)/$2-spec.yaml; \
rm -rf $$BIN_PATH; \
$(BINDIR)/yq eval-all 'select(fileIndex==0).spec.versions[0].schema.openAPIV3Schema.properties.spec = select(fileIndex==1).spec | select(fileIndex==0)' \
$(TEMP_DIR)/$2.yaml $(TEMP_DIR)/$2-spec.yaml > $(ROOTDIR)/charts/$1/crds/$2.yaml
endef
Expand Down
Loading

0 comments on commit d6f06c1

Please sign in to comment.