Skip to content

Commit

Permalink
Update common files. (envoyproxy#2488)
Browse files Browse the repository at this point in the history
  • Loading branch information
geeknoid authored and istio-testing committed Nov 7, 2019
1 parent a36b279 commit 23e58a9
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 20 deletions.
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ else
$(error This system's OS $(LOCAL_OS) isn't supported)
endif

export TARGET_OUT ?= $(shell pwd)/out/$(TARGET_ARCH)_$(TARGET_OS)
export TARGET_OUT ?= $(shell pwd)/out/$(TARGET_OS)_$(TARGET_ARCH)

ifeq ($(BUILD_WITH_CONTAINER),1)
export TARGET_OUT = /work/out/$(TARGET_ARCH)_$(TARGET_OS)
export TARGET_OUT = /work/out/$(TARGET_OS)_$(TARGET_ARCH)
CONTAINER_CLI ?= docker
DOCKER_SOCKET_MOUNT ?= -v /var/run/docker.sock:/var/run/docker.sock
IMG ?= gcr.io/istio-testing/build-tools:2019-10-11T13-37-52
IMG ?= gcr.io/istio-testing/build-tools:2019-10-24T14-05-17
UID = $(shell id -u)
GID = `grep docker /etc/group | cut -f3 -d:`
PWD = $(shell pwd)

$(info Building with the build container: $(IMG).)
Expand All @@ -67,7 +68,20 @@ $(info Building with the build container: $(IMG).)
# the path of the file.
TIMEZONE=`readlink $(READLINK_FLAGS) /etc/localtime | sed -e 's/^.*zoneinfo\///'`

RUN = $(CONTAINER_CLI) run -t -i --sig-proxy=true -u $(UID):docker --rm \
# Determine the docker.push credential bind mounts.
# Docker and GCR are supported credentials. At this time docker.push may
# not work well on Docker-For-Mac. This will be handled in a follow-up PR.
DOCKER_CREDS_MOUNT:=
ifneq (,$(wildcard $(HOME)/.docker))
$(info Using docker credential directory $(HOME)/.docker.)
DOCKER_CREDS_MOUNT+=--mount type=bind,source="$(HOME)/.docker",destination="/config/.docker",readonly
endif
ifneq (,$(wildcard $(HOME)/.config/gcloud))
$(info Using gcr credential directory $(HOME)/.config/gcloud.)
DOCKER_CREDS_MOUNT+=--mount type=bind,source="$(HOME)/.config/gcloud",destination="/config/.config/gcloud",readonly
endif

RUN = $(CONTAINER_CLI) run -t -i --sig-proxy=true -u $(UID):$(GID) --rm \
-e IN_BUILD_CONTAINER="$(BUILD_WITH_CONTAINER)" \
-e TZ="$(TIMEZONE)" \
-e TARGET_ARCH="$(TARGET_ARCH)" \
Expand All @@ -81,6 +95,7 @@ RUN = $(CONTAINER_CLI) run -t -i --sig-proxy=true -u $(UID):docker --rm \
--mount type=bind,source="$(PWD)",destination="/work" \
--mount type=volume,source=go,destination="/go" \
--mount type=volume,source=gocache,destination="/gocache" \
$(DOCKER_CREDS_MOUNT) \
-w /work $(IMG)

MAKE = $(RUN) make --no-print-directory -e -f Makefile.core.mk
Expand Down
2 changes: 1 addition & 1 deletion common/.commonfiles.sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6c1a9ea348417a19b3d970ba46a6fcb52601dc97
26f7e5e5e9866f63ff4233e5f5f7459288ee358c
32 changes: 22 additions & 10 deletions common/Makefile.common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FINDFILES=find . \( -path ./common-protos -o -path ./.git -o -path ./.github \) -prune -o -type f
FINDFILES=find . \( -path ./common-protos -o -path ./.git -o -path ./.github -o -path ./licenses \) -prune -o -type f
XARGS = xargs -0 -r

lint-dockerfiles:
Expand Down Expand Up @@ -63,7 +63,10 @@ lint-licenses:

lint-all: lint-dockerfiles lint-scripts lint-yaml lint-helm lint-copyright-banner lint-go lint-python lint-markdown lint-sass lint-typescript lint-protos lint-licenses

format-go:
tidy-go:
@go mod tidy

format-go: tidy-go
@${FINDFILES} -name '*.go' \( ! \( -name '*.gen.go' -o -name '*.pb.go' \) \) -print0 | ${XARGS} goimports -w -local "istio.io"

format-python:
Expand All @@ -80,19 +83,28 @@ dump-licenses-csv:
@go mod download
@license-lint --config common/config/license-lint.yml --csv

mirror-licenses:
@go mod download
@license-lint --mirror

TMP := $(shell mktemp -d -u)
UPDATE_BRANCH ?= "master"

update-common:
@git clone -q --depth 1 --single-branch --branch master https://github.com/istio/common-files
@cd common-files ; git rev-parse HEAD >files/common/.commonfiles.sha
@mkdir -p $(TMP)
@git clone -q --depth 1 --single-branch --branch $(UPDATE_BRANCH) https://github.com/istio/common-files $(TMP)/common-files
@cd $(TMP)/common-files ; git rev-parse HEAD >files/common/.commonfiles.sha
@rm -fr common
@cp -rT common-files/files .
@rm -fr common-files
@cp -rT $(TMP)/common-files/files $(shell pwd)
@rm -fr $(TMP)/common-files

update-common-protos:
@git clone -q --depth 1 --single-branch --branch master https://github.com/istio/common-files
@cd common-files ; git rev-parse HEAD > common-protos/.commonfiles.sha
@mkdir -p $(TMP)
@git clone -q --depth 1 --single-branch --branch $(UPDATE_BRANCH) https://github.com/istio/common-files $(TMP)/common-files
@cd $(TMP)/common-files ; git rev-parse HEAD > common-protos/.commonfiles.sha
@rm -fr common-protos
@cp -ar common-files/common-protos common-protos
@rm -fr common-files
@cp -ar $(TMP)/common-files/common-protos $(shell pwd)/common-protos
@rm -fr $(TMP)/common-files

check-clean-repo:
@common/scripts/check_clean_repo.sh
Expand Down
11 changes: 8 additions & 3 deletions common/config/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

service:
# When updating this, also update the version stored in docker/build-tools/Dockerfile in the istio/tools repo.
golangci-lint-version: 1.18.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.21.x # use the fixed version to not introduce new linters unexpectedly
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 20m
Expand All @@ -32,18 +32,23 @@ run:
linters:
enable-all: true
disable:
- bodyclose
- depguard
- dogsled
- dupl
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocyclo
- godox
- gosec
- nakedret
- prealloc
- scopelint
- funlen
- bodyclose
- whitespace
- wsl
fast: false

linters-settings:
Expand Down
2 changes: 1 addition & 1 deletion common/scripts/check_clean_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

if [[ -n $(git status --porcelain) ]]; then
git status
echo "ERROR: Some files need to be updated, please run make and include any changed files in your PR"
echo "ERROR: Some files need to be updated, please run 'make gen' and include any changed files in your PR"
exit 1
fi
2 changes: 1 addition & 1 deletion common/scripts/lint_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GOGC=25 golangci-lint run -c ./common/config/.golangci.yml
golangci-lint run -c ./common/config/.golangci.yml
2 changes: 2 additions & 0 deletions common/scripts/report_build_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ if [[ -n ${ISTIO_VERSION} ]]; then
fi

GIT_DESCRIBE_TAG=$(git describe --tags)
HUB=${HUB:-""}

# used by common/scripts/gobuild.sh
echo "istio.io/pkg/version.buildVersion=${VERSION}"
echo "istio.io/pkg/version.buildGitRevision=${BUILD_GIT_REVISION}"
echo "istio.io/pkg/version.buildStatus=${tree_status}"
echo "istio.io/pkg/version.buildTag=${GIT_DESCRIBE_TAG}"
echo "istio.io/pkg/version.buildHub=${HUB}"

0 comments on commit 23e58a9

Please sign in to comment.