From 9eb15371b3819a63ebd82888e9de1e15bbe9e35a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 30 Jan 2019 22:16:16 +0100 Subject: [PATCH 1/2] Allow overriding repository and branch in validate scripts When running CI in other repositories (e.g. Docker's downstream docker/engine repository), or other branches, the validation scripts were calculating the list of changes based on the wrong information. This lead to weird failures in CI in a branch where these values were not updated ':-) (CI on a pull request failed because it detected that new tests were added to the deprecated `integration-cli` test-suite, but the pull request did not actually make changes in that area). This patch allows overriding the target repository (and branch) to compare to (without having to edit the scripts). Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 2a08f33166247da9d4c09d4c6c72cbb8119bf8df) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 748f37022df465c39a76461c4970f4c678f629e3 Component: engine --- components/engine/Makefile | 7 +++++++ components/engine/hack/validate/.validate | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/engine/Makefile b/components/engine/Makefile index 403c6792ee..28c87bdda4 100644 --- a/components/engine/Makefile +++ b/components/engine/Makefile @@ -13,6 +13,11 @@ DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $$ DOCKER_GITCOMMIT := $(shell git rev-parse --short HEAD || echo unsupported) export DOCKER_GITCOMMIT +# allow overriding the repository and branch that validation scripts are running +# against these are used in hack/validate/.validate to check what changed in the PR. +export VALIDATE_REPO +export VALIDATE_BRANCH + # env vars passed through directly to Docker's build scripts # to allow things like `make KEEPBUNDLE=1 binary` easily # `project/PACKAGERS.md` have some limited documentation of some of these @@ -49,6 +54,8 @@ DOCKER_ENVS := \ -e TESTDIRS \ -e TESTFLAGS \ -e TIMEOUT \ + -e VALIDATE_REPO \ + -e VALIDATE_BRANCH \ -e HTTP_PROXY \ -e HTTPS_PROXY \ -e NO_PROXY \ diff --git a/components/engine/hack/validate/.validate b/components/engine/hack/validate/.validate index 32cb6b6d64..acc985d41b 100644 --- a/components/engine/hack/validate/.validate +++ b/components/engine/hack/validate/.validate @@ -6,8 +6,8 @@ if [ -z "$VALIDATE_UPSTREAM" ]; then # this is kind of an expensive check, so let's not do this twice if we # are running more than one validate bundlescript - VALIDATE_REPO='https://github.com/docker/docker.git' - VALIDATE_BRANCH='master' + VALIDATE_REPO="${VALIDATE_REPO:-https://github.com/docker/docker.git}" + VALIDATE_BRANCH="${VALIDATE_BRANCH:-master}" VALIDATE_HEAD="$(git rev-parse --verify HEAD)" From c14d8be35a9f8d1af2097c24a2ab56a7c6ee4f43 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Mon, 4 Feb 2019 19:05:10 +0000 Subject: [PATCH 2/2] hack: no need to git fetch in CI CIs are assumed to do a git fetch and git merge before running tests. Therefore, no need for a git fetch inside our validate scripts in CI. If VALIDATE_ORIGIN_BRANCH is set, then git fetch is skipped and VALIDATE_ORIGIN_BRANCH is used in validate scripts. Otherwise, behavior is unchanged. Signed-off-by: Tibor Vass (cherry picked from commit feb70fd5c9e2fb3f300e953dd83053f0830f3895) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 7b9ec00eec7ffe745ebd2f807daa50d84b3e10e7 Component: engine --- components/engine/Makefile | 2 ++ components/engine/hack/validate/.validate | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/engine/Makefile b/components/engine/Makefile index 28c87bdda4..7767409a6f 100644 --- a/components/engine/Makefile +++ b/components/engine/Makefile @@ -17,6 +17,7 @@ export DOCKER_GITCOMMIT # against these are used in hack/validate/.validate to check what changed in the PR. export VALIDATE_REPO export VALIDATE_BRANCH +export VALIDATE_ORIGIN_BRANCH # env vars passed through directly to Docker's build scripts # to allow things like `make KEEPBUNDLE=1 binary` easily @@ -56,6 +57,7 @@ DOCKER_ENVS := \ -e TIMEOUT \ -e VALIDATE_REPO \ -e VALIDATE_BRANCH \ + -e VALIDATE_ORIGIN_BRANCH \ -e HTTP_PROXY \ -e HTTPS_PROXY \ -e NO_PROXY \ diff --git a/components/engine/hack/validate/.validate b/components/engine/hack/validate/.validate index acc985d41b..6ed3a59a73 100644 --- a/components/engine/hack/validate/.validate +++ b/components/engine/hack/validate/.validate @@ -11,8 +11,11 @@ if [ -z "$VALIDATE_UPSTREAM" ]; then VALIDATE_HEAD="$(git rev-parse --verify HEAD)" - git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH" - VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)" + if [ -z "$VALIDATE_ORIGIN_BRANCH" ]; then + git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH" + VALIDATE_ORIGIN_BRANCH=FETCH_HEAD + fi + VALIDATE_UPSTREAM="$(git rev-parse --verify $VALIDATE_ORIGIN_BRANCH)" VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD" VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"