diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 62177a884..11de5c228 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -125,3 +125,17 @@ if test "${BUILDKITE_AGENT_META_DATA_QUEUE}" = "release"; then fi sudo sysctl -w kernel.print-fatal-signals=1 + +pipeline_add_env() { + sed -i "/^env:/a\ $1: '$2'" .buildkite/pipeline.yaml +} + +# Try to skip unaffected tests on pre-submits. +# BUILDKITE_PIPELINE_ID is set only on the pipeline upload step. +if [[ -n "${BUILDKITE_PIPELINE_ID}" && "${BUILDKITE_BRANCH}" =~ ^test/ ]]; then + # Skip load-all-images tests if the change doesn't affect images. + if ./tools/builkite-check-paths.sh images/ tools/images.mk Makefile; then + echo "Skip load-all-images tests" + pipeline_add_env SKIP_LOADING_IMAGES 1 + fi +fi diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index e8af6414a..7bbe922c8 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -213,14 +213,14 @@ steps: # Images tests. - <<: *common - <<: *source_test label: ":docker: Images (x86_64)" + if: build.env("SKIP_LOADING_IMAGES") == null && build.env("STAGED_BINARIES") == null command: make ARCH=x86_64 load-all-images agents: arch: "amd64" - <<: *common - <<: *source_test label: ":docker: Images (aarch64)" + if: build.env("SKIP_LOADING_IMAGES") == null && build.env("STAGED_BINARIES") == null command: make ARCH=aarch64 load-all-images agents: arch: "arm64" diff --git a/tools/builkite-check-paths.sh b/tools/builkite-check-paths.sh new file mode 100755 index 000000000..d7883bbc3 --- /dev/null +++ b/tools/builkite-check-paths.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright 2019 The gVisor Authors. +# +# 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 +# +# http://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. + +# Check if any changes are in specified paths. The script exits with 0 if no +# changes were detected. + +set -xeo pipefail + +exec 1>&2 + +git fetch origin master +baseid=$(git merge-base origin/master "origin/${BUILDKITE_BRANCH}") + +git diff --stat "${baseid}" --exit-code "$@"