From a4e121989de18df89ed32a5f01440f44993b59f6 Mon Sep 17 00:00:00 2001 From: Sergey Zabolotny Date: Thu, 14 Nov 2019 14:14:41 +0200 Subject: [PATCH 1/2] Switch travis build to ubuntu 18.04 (bionic) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4563a7e..18f59dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -dist: xenial +dist: bionic language: minimal From 910655305d0533564d1d93a3971f6b00997d88c9 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Wed, 2 Mar 2022 18:00:42 -0800 Subject: [PATCH 2/2] Switched to Github Actions + ARM64 builds - Switched CI builds to Github Actions - Dropped Travis CI config - Refactored Dockerfile to support multi-arch builds - Using http://localhost in tests instead of http://varnish.docksal (this way we don't need to install Docksal to run tests) - Supported Varnish versions: 6.0, 6.6, 7.0 (per https://varnish-cache.org/releases/) --- .github/scripts/docker-tag-delete.sh | 45 +++++ .github/scripts/docker-tags.sh | 74 +++++++ .github/workflows/default.yaml | 292 +++++++++++++++++++++++++++ .travis.yml | 28 --- Dockerfile | 19 +- Makefile | 49 +++-- release.sh | 28 --- tests/test.bats | 33 +-- 8 files changed, 465 insertions(+), 103 deletions(-) create mode 100755 .github/scripts/docker-tag-delete.sh create mode 100755 .github/scripts/docker-tags.sh create mode 100644 .github/workflows/default.yaml delete mode 100644 .travis.yml delete mode 100755 release.sh diff --git a/.github/scripts/docker-tag-delete.sh b/.github/scripts/docker-tag-delete.sh new file mode 100755 index 0000000..7ec78a8 --- /dev/null +++ b/.github/scripts/docker-tag-delete.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Deletes an image tag from Docker Hub +# +# Expects USER, PASSWORD +# Expects IMAGE:TAG as argument. +# +# Example: docker-tag-delete.sh docksal/cli:php7.3-build-01c92a2-amd64 + +# Credit: +# https://devopsheaven.com/docker/dockerhub/2018/04/09/delete-docker-image-tag-dockerhub.html + +set -euo pipefail + +# Get IMAGE and TAG from first argument +if [[ "${1}" == "" ]]; then + echo "Usage: ${0} image:tag" + exit 1 +else + # Split image:tag + IFS=$':' read IMAGE TAG <<< ${1}; + # Remove registry prefix from image if present + IMAGE=${IMAGE#"docker.io/"} +fi + +login_data() { +cat < image:[version_prefix][version-]edge[-version_suffix] +# master => image:[version_prefix][version][-][version_suffix] +# semver tag => image:[version_prefix][version-]major.minor[-version_suffix] + +# Declare expected variables +IMAGE=${IMAGE} # docksal/cli +VERSION_PREFIX=${VERSION_PREFIX} # php +VERSION=${VERSION} # 7.4 +VERSION_SUFFIX=${VERSION_SUFFIX} # ide +REGISTRY="${REGISTRY}" # ghcr.io +GITHUB_REF=${GITHUB_REF} # refs/heads/develop, refs/heads/master, refs/tags/v1.0.0 + +# Join arguments with hyphen (-) as a delimiter +# Usage: join [] +join() { + local IFS='-' # join delimiter + echo "$*" +} + +# Prints resulting image tags and sets output variable +set_output() { + local -n inputArr=${1} + + declare -a outputArr + for imageTag in ${inputArr[@]}; do + # Prepend registry to imageTag if provided + [[ "${REGISTRY}" != "" ]] && imageTag="${REGISTRY}/${imageTag}" + outputArr+=("${imageTag}") + done + + # Print with new lines for output in build logs + (IFS=$'\n'; echo "${outputArr[*]}") + # Using newlines in output variables does not seem to work, so we'll use comas + (IFS=$','; echo "::set-output name=tags::${outputArr[*]}") +} + +# Image tags +declare -a imageTagArr + +## On every build => build / build-sha7 +## Latest build tag (used with cache-from) +#imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX} build)") +## Specific build tag - SHA7 (first 7 characters of commit SHA) +#imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX} build ${GITHUB_SHA:0:7})") + +# develop => version-edge +if [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} edge ${VERSION_SUFFIX})") +fi + +# master => version +if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX})") +fi + +# tags/v1.0.0 => 1.0 +if [[ "${GITHUB_REF}" =~ "refs/tags/" ]]; then + # Extract version parts from release tag + IFS='.' read -a release_arr <<< "${GITHUB_REF#refs/tags/}" + releaseMajor=${release_arr[0]#v*} # 2.7.0 => "2" + releaseMinor=${release_arr[1]} # "2.7.0" => "7" + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${VERSION_SUFFIX})") + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${releaseMajor} ${VERSION_SUFFIX})") + imageTagArr+=("${IMAGE}:$(join ${VERSION_PREFIX}${VERSION} ${releaseMajor}.${releaseMinor} ${VERSION_SUFFIX})") +fi + +# Note: imageTagArr is passed as variable name ("reference") and then expanded inside the called function +# See https://stackoverflow.com/questions/16461656/how-to-pass-array-as-an-argument-to-a-function-in-bash/26443029#26443029 +# DockerHub tags +set_output imageTagArr diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml new file mode 100644 index 0000000..ff46bc2 --- /dev/null +++ b/.github/workflows/default.yaml @@ -0,0 +1,292 @@ +name: Default + +on: + schedule: + - cron: "0 10 * * 0" # Every Sunday at 10AM + push: + branches: + - master + - develop + - feature/* + tags: + - "v*.*.*" + workflow_dispatch: # Allow manually triggering a build + +defaults: + run: + shell: bash + +env: + IMAGE: docksal/varnish + #DOCKSAL_VERSION: develop + +jobs: + build: + name: "Build: ${{ matrix.version }}/${{ matrix.arch }}" + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false # Don't cancel other jobs if one fails + matrix: + include: + - + arch: amd64 + version: "6.0" + - + arch: arm64 + version: "6.0" + - + arch: amd64 + version: "6.6" + - + arch: arm64 + version: "6.6" + - + arch: amd64 + version: "7.0" + - + arch: arm64 + version: "7.0" + + env: + ARCH: ${{ matrix.arch }} + VERSION_PREFIX: "" + VERSION: ${{ matrix.version }} + UPSTREAM_IMAGE: varnish:${{ matrix.version }} + BUILD_DIR: "." + + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Environment variables + run: | + # Export variables for further steps + echo GIT_SHA7="${GITHUB_SHA:0:7}" | tee -a ${GITHUB_ENV} + echo BUILD_IMAGE_TAG="${IMAGE}:${VERSION_PREFIX}${VERSION}-build" | tee -a ${GITHUB_ENV} + # Pull the host public SSH key at runtime instead of relying on a static value stored in secrets. + echo ARM64_HOST_SSH_CERT="$(ssh-keyscan -t rsa ${{ secrets.ARM64_HOST }} 2>/dev/null)" | tee -a ${GITHUB_ENV} +# - +# # Switch docker context to a remote arm64 host +# # Used for building heavy images that take too long to build using QEMU + for native arm64 testing. +# name: Switch to arm64 builder host +# if: ${{ env.ARCH == 'arm64' }} +# uses: arwynfr/actions-docker-context@v2 +# with: +# docker_host: "ssh://ubuntu@${{ secrets.ARM64_HOST }}" +# context_name: arm64-host +# ssh_key: "${{ secrets.ARM64_HOST_SSH_KEY }}" +# ssh_cert: "${{ env.ARM64_HOST_SSH_CERT }}" +# use_context: true + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Check Docker + run: | + docker version + docker info + - + name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + # Build and cache image in the registry + name: Build image + uses: docker/build-push-action@v2 + with: + context: ${{ env.BUILD_DIR }} + file: ${{ env.BUILD_DIR }}/Dockerfile + build-args: | + UPSTREAM_IMAGE=${{ env.UPSTREAM_IMAGE }} + VERSION=${{ env.VERSION }} + platforms: linux/${{ env.ARCH }} + # Push intermediate arch-specific build tag to repo + tags: ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-${{ env.ARCH }} + push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs + # BUILD_IMAGE_TAG - persistent multi-arch tag, updated at the end of the build (success or failure) + cache-from: type=registry,ref=${{ env.BUILD_IMAGE_TAG }} + cache-to: type=inline # Write the cache metadata into the image configuration + + test: + name: "Test: ${{ matrix.version }}/${{ matrix.arch }}" + runs-on: ubuntu-20.04 + needs: build + + strategy: + fail-fast: false # Don't cancel other jobs if one fails + matrix: + include: + - + arch: amd64 + version: "6.0" + - + arch: amd64 + version: "6.6" + - + arch: amd64 + version: "7.0" + # Disabled arm64 tests. + # TODO: Refactor tests to be compatible with a remote host test runner. + # TODO: Remember to re-enabled the test results check in "push". + #- + # arch: arm64 + # version: 6.0 + + env: + ARCH: ${{ matrix.arch }} + VERSION_PREFIX: "" + VERSION: ${{ matrix.version }} + + steps: + - + name: Setup Bats + uses: mig4/setup-bats@v1 + with: + bats-version: "1.3.0" + - + name: Checkout + uses: actions/checkout@v2 + - + name: Environment variables + run: | + # Export variables for further steps + echo GIT_SHA7="${GITHUB_SHA:0:7}" | tee -a ${GITHUB_ENV} + echo BUILD_IMAGE_TAG="${IMAGE}:${VERSION_PREFIX}${VERSION}-build" | tee -a ${GITHUB_ENV} + # Pull the host public SSH key at runtime instead of relying on a static value stored in secrets. + echo ARM64_HOST_SSH_CERT="$(ssh-keyscan -t rsa ${{ secrets.ARM64_HOST }} 2>/dev/null)" | tee -a ${GITHUB_ENV} + - + # Switch docker context to a remote arm64 host + # Used for building heavy images that take too long to build using QEMU + for native arm64 testing. + name: Switch to arm64 builder host + if: ${{ env.ARCH == 'arm64' }} + uses: arwynfr/actions-docker-context@v2 + with: + docker_host: "ssh://ubuntu@${{ secrets.ARM64_HOST }}" + context_name: arm64-host + ssh_key: "${{ secrets.ARM64_HOST_SSH_KEY }}" + ssh_cert: "${{ env.ARM64_HOST_SSH_CERT }}" + use_context: true + - + name: Check Docker + run: | + docker version + docker info +# - +# name: Test preparations +# working-directory: ${{ env.BUILD_CONTEXT }} +# env: +# BUILD_IMAGE_TAG: ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-${{ env.ARCH }} +# run: | +# # Install Docksal using the passed DOCKSAL_VERSION value +# curl -sSL http://get.docksal.io | bash +# # Start the service using the build image tag +# make start + - + # Run tests + name: Test + id: tests + working-directory: ${{ env.BUILD_DIR }} + env: + BUILD_IMAGE_TAG: ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-${{ env.ARCH }} + VERSION: ${{ env.VERSION }} + run: | + make test + ([[ $? == 0 ]] && echo "pass" || echo "fail") | tee ${{ github.workspace }}/test-results-${VERSION_PREFIX}${VERSION}-${ARCH}.txt + # Store tests results as an artifact (used by downstream jobs) + # Note: Cannot use "::set-output name=var_name::var_value" as var_name would need to be dynamic here. + # Dynamic variable names cannot be used when mapping step outputs to job outputs. + # Step outputs cannot be accessed directly from other jobs. Dead end. + - name: Store test results + uses: actions/upload-artifact@v2 + with: + name: test-results + path: ${{ github.workspace }}/test-results-*.txt + + push: + name: "Push: ${{ matrix.version }}/multi" + runs-on: ubuntu-20.04 + + # Wait for test to either succeed or fail + needs: test + if: always() + + strategy: + matrix: + version: + - "6.0" + - "6.6" + - "7.0" + + env: + VERSION_PREFIX: "" + VERSION: ${{ matrix.version }} + + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Environment variables + run: | + # Export variables for further steps + echo GIT_SHA7="${GITHUB_SHA:0:7}" | tee -a ${GITHUB_ENV} + echo BUILD_IMAGE_TAG="${IMAGE}:${VERSION_PREFIX}${VERSION}-build" | tee -a ${GITHUB_ENV} + # Pull the host public SSH key at runtime instead of relying on a static value stored in secrets. + echo ARM64_HOST_SSH_CERT="$(ssh-keyscan -t rsa ${{ secrets.ARM64_HOST }} 2>/dev/null)" | tee -a ${GITHUB_ENV} + - + # Login to Docker Hub + name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Retrieve test results + uses: actions/download-artifact@v2 + with: + name: test-results + - + # Generate persistent tags (edge, stable, release) + name: Docker image tags + id: docker_tags + # Don't push broken builds to persistent tags (both amd64 and arm64 tests must pass) + # TODO: re-enable the arm64 test results check once those tests are re-enabled + run: | + amd64_tests=$(cat test-results-${VERSION_PREFIX}${VERSION}-amd64.txt) + #arm64_tests=$(cat test-results-${VERSION_PREFIX}${VERSION}-arm64.txt) + # && [[ "${arm64_tests}" == "pass" ]] + if [[ "${amd64_tests}" == "pass" ]]; then + .github/scripts/docker-tags.sh + fi + - + # Create and push multi-arch image manifests + name: Push multi-arch images + env: + # build tags are always pushed (build caching, debugging needs) + # edge, stage, release are only pushed if tests were successful (see docker_tags step) + TAGS: | + ${{ env.BUILD_IMAGE_TAG }} + ${{ steps.docker_tags.outputs.tags }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} # Needed for docker-tag-delete.sh + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} # Needed for docker-tag-delete.sh + run: | + set -xeuo pipefail + IFS="${IFS}," # Also split strings by comma (in case list of tag is comma-separated) + for tag in ${TAGS}; do + if [[ "${tag}" == "" ]]; then continue; fi + docker manifest create --amend ${tag} \ + ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-amd64 \ + ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-arm64 + docker manifest inspect ${tag} + docker manifest push ${tag} + done + # Clean up intermediate arch-specific image tags (DockerHub only) + .github/scripts/docker-tag-delete.sh ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-amd64 + .github/scripts/docker-tag-delete.sh ${{ env.BUILD_IMAGE_TAG }}-${{ env.GIT_SHA7 }}-arm64 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 18f59dc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -dist: bionic - -language: minimal - -env: - global: - - REPO=docksal/varnish - - matrix: - - VERSION=6.0 TAGS=6.0 - - VERSION=6.2 TAGS=6.2,latest - -install: - # Install Docksal to have a matching versions of Docker on the build host - - curl -fsSL https://get.docksal.io | bash - - fin version - - fin sysinfo - -script: - - make - - make start - - make test - -after_success: - - ${TRAVIS_BUILD_DIR}/release.sh - -after_failure: - - make logs diff --git a/Dockerfile b/Dockerfile index f0543da..63adcd5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ -ARG VERSION -FROM varnish:${VERSION} +ARG UPSTREAM_IMAGE +FROM ${UPSTREAM_IMAGE} -ARG VERSION -ENV VERSION=${VERSION} +ARG TARGETARCH # Install aditional dependencies -ARG GOMPLATE_VERSION=3.0.0 -RUN set -x && \ - apt-get update && \ - apt-get install -y --no-install-recommends curl net-tools && \ - rm -rf /var/lib/apt/lists/* && \ - curl -o /usr/local/bin/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim && \ +ARG GOMPLATE_VERSION=3.10.0 +RUN set -xe; \ + apt-get update; \ + apt-get install -y --no-install-recommends curl net-tools; \ + rm -rf /var/lib/apt/lists/*; \ + curl -sSLf -o /usr/local/bin/gomplate https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-${TARGETARCH}-slim; \ chmod 755 /usr/local/bin/gomplate COPY conf/default.vcl.tmpl /etc/varnish/default.vcl.tmpl diff --git a/Makefile b/Makefile index c489424..1f1d9e8 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,50 @@ +# Load test variables +-include tests/env_make + +# Allow using a different docker binary DOCKER ?= docker -VERSION ?= 6.2 -TAG ?= $(VERSION) +# Force BuildKit mode for builds +# See https://docs.docker.com/buildx/working-with-buildx/ +DOCKER_BUILDKIT=1 -REPO ?= docksal/varnish +IMAGE ?= docksal/varnish +VERSION ?= 7.0 +UPSTREAM_IMAGE ?= varnish:$(VERSION) +BUILD_IMAGE_TAG ?= $(IMAGE):$(VERSION)-build NAME = docksal-varnish-$(VERSION) -BASE_IMAGE_TAG = $(VERSION) - -ifneq ($(STABILITY_TAG),) - ifneq ($(TAG),latest) - override TAG := $(TAG)-$(STABILITY_TAG) - endif -endif - --include tests/env_make +# Make it possible to pass arguments to Makefile from command line +# https://stackoverflow.com/a/6273809/1826109 +ARGS = $(filter-out $@,$(MAKECMDGOALS)) .EXPORT_ALL_VARIABLES: -.PHONY: build test push shell run start stop logs clean release +.PHONY: build test push shell run start stop logs clean default: build build: - $(DOCKER) build -t $(REPO):$(TAG) --build-arg VERSION=$(VERSION) . + $(DOCKER) build -t $(BUILD_IMAGE_TAG) --build-arg UPSTREAM_IMAGE=$(UPSTREAM_IMAGE) --build-arg VERSION=$(VERSION) . test: - IMAGE=$(REPO):$(TAG) REPO=$(REPO) NAME=$(NAME) VERSION=$(VERSION) tests/test.bats + IMAGE=$(BUILD_IMAGE_TAG) NAME=$(NAME) VERSION=$(VERSION) ./tests/test.bats push: - $(DOCKER) push $(REPO):$(TAG) + $(DOCKER) push $(BUILD_IMAGE_TAG) start-dependencies: $(DOCKER) network create varnish - $(DOCKER) run -d --name $(NAME)-web -p 2581:80 --network=varnish -v $(PWD)/tests/docroot:/var/www/docroot docksal/apache + $(DOCKER) run -d --name $(NAME)-web -p 2581:80 --network=varnish -v $(PWD)/tests/docroot:/var/www/docroot docksal/apache:2.4-2.4 shell: clean start-dependencies - $(DOCKER) run --rm --name $(NAME) -i -t --network=varnish $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash + $(DOCKER) run --rm --name $(NAME) -it --network=varnish $(PORTS) $(VOLUMES) $(ENV) $(BUILD_IMAGE_TAG) /bin/bash run: clean start-dependencies - $(DOCKER) run --rm --name $(NAME) -e DEBUG=1 --network=varnish $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) $(CMD) + $(DOCKER) run --rm --name $(NAME) -it -e DEBUG=1 --network=varnish $(PORTS) $(VOLUMES) $(ENV) $(BUILD_IMAGE_TAG) $(CMD) start: clean start-dependencies - $(DOCKER) run -d --name $(NAME) --network=varnish $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) + $(DOCKER) run -d --name $(NAME) --network=varnish $(PORTS) $(VOLUMES) $(ENV) $(BUILD_IMAGE_TAG) exec: $(DOCKER) exec $(NAME) bash -lc '$(CMD)' @@ -60,10 +62,15 @@ logs: logs-follow: $(DOCKER) logs -f $(NAME) +debug: build start logs-follow + clean: $(DOCKER) rm -f $(NAME) || true $(DOCKER) rm -f $(NAME)-web || true $(DOCKER) network remove varnish || true rm -f tests/docroot/index2.html || true -release: build push +# Make it possible to pass arguments to Makefile from command line +# https://stackoverflow.com/a/6273809/1826109 +%: + @: diff --git a/release.sh b/release.sh deleted file mode 100755 index ee7407b..0000000 --- a/release.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# No pushes for PRs -if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then - # Image tag scheme: -[-] - if [[ "${TRAVIS_BRANCH}" == "develop" ]]; then - export STABILITY_TAG="edge" - elif [[ "${TRAVIS_BRANCH}" == "master" ]]; then - export STABILITY_TAG="" - elif [[ "${TRAVIS_TAG}" != "" ]]; then - export STABILITY_TAG="${TRAVIS_TAG:1:3}" - else - # No pushes for any other branches - exit 0 - fi - - docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}" - - IFS=',' read -ra tags <<< "${TAGS}" - - # Push all applicable tag variations - for tag in "${tags[@]}"; do - if [[ "${TRAVIS_BRANCH}" == "develop" ]] && [[ "${tag}" =~ "latest" ]]; then continue; fi - make release TAG="${tag}" - done -fi diff --git a/tests/test.bats b/tests/test.bats index 29f9955..741b856 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -58,11 +58,12 @@ _healthcheck_wait () @test "${NAME} container is up and using the \"${IMAGE}\" image" { [[ ${SKIP} == 1 ]] && skip - run _healthcheck_wait - unset output + # Setup + make start + _healthcheck_wait # Using "bash -c" here to expand ${DOCKER} (in case it's more that a single word). - # Without bats run returns "command not found" + # Without bash run returns "command not found" run bash -c "${DOCKER} ps --filter 'name=${NAME}' --format '{{ .Image }}'" [[ "$output" =~ "${IMAGE}" ]] unset output @@ -72,13 +73,13 @@ _healthcheck_wait () [[ $SKIP == 1 ]] && skip # Confirm a cache MISS 1st time - run curl -sSk -I http://varnish.docksal:2580/index.html + run curl -sSk -m 1 -I http://localhost:2580/index.html echo "$output" | grep "HTTP/1.1 200 OK" echo "$output" | grep "X-Varnish-Cache: MISS" unset output # Confirm a cache HIT 2nd time - run curl -sSk -I http://varnish.docksal:2580/index.html + run curl -sSk -m 1 -I http://localhost:2580/index.html [[ "$output" =~ "HTTP/1.1 200 OK" ]] [[ "$output" =~ "X-Varnish-Cache: HIT" ]] unset output @@ -88,13 +89,13 @@ _healthcheck_wait () [[ $SKIP == 1 ]] && skip # Confirm a cache MISS 1st time - run curl -sSk -I http://varnish.docksal:2580/nonsense.html + run curl -sSk -m 1 -I http://localhost:2580/nonsense.html [[ "$output" =~ "HTTP/1.1 404 Not Found" ]] [[ "$output" =~ "X-Varnish-Cache: MISS" ]] unset output # Confirm a cache HIT 2nd time - run curl -sSk -I http://varnish.docksal:2580/nonsense.html + run curl -sSk -m 1 -I http://localhost:2580/nonsense.html [[ "$output" =~ "HTTP/1.1 404 Not Found" ]] [[ "$output" =~ "X-Varnish-Cache: HIT" ]] unset output @@ -105,12 +106,12 @@ _healthcheck_wait () # Create a new file and warm-up the cache echo "TEST OUTPUT" > tests/docroot/index2.html - curl -sSk -i http://varnish.docksal:2580/index2.html + curl -sSk -i http://localhost:2580/index2.html # Modify the file echo "TEST OUTPUT2" >> tests/docroot/index2.html # Confirm the cached version is returned - run curl -sSk -i http://varnish.docksal:2580/index2.html + run curl -sSk -m 1 -i http://localhost:2580/index2.html [[ "$output" =~ "HTTP/1.1 200 OK" ]] [[ "$output" =~ "X-Varnish-Cache: HIT" ]] [[ "$output" =~ "TEST OUTPUT" ]] @@ -118,10 +119,10 @@ _healthcheck_wait () unset output # Confirm new file is returned after PURGE - curl -X PURGE http://varnish.docksal:2580/index2.html + curl -X PURGE http://localhost:2580/index2.html # Give varnish a bit of time to process the purge sleep 1 - run curl -sSk -i http://varnish.docksal:2580/index2.html + run curl -sSk -m 1 -i http://localhost:2580/index2.html [[ "$output" =~ "HTTP/1.1 200 OK" ]] [[ "$output" =~ "X-Varnish-Cache: MISS" ]] [[ "$output" =~ "TEST OUTPUT" ]] @@ -133,20 +134,20 @@ _healthcheck_wait () [[ $SKIP == 1 ]] && skip # Check cache tags header are present in the response from backend - run curl -sSk -I http://varnish.docksal:2581/ban.html + run curl -sSk -m 1 -I http://localhost:2581/ban.html [[ "$output" =~ "Cache-Tags: ban.test" ]] unset output # Warm-up cache, check for a HIT and that the cache tags header is stripped from Varnish response - curl -sSk http://varnish.docksal:2580/ban.html &>/dev/null - run curl -sSk -I http://varnish.docksal:2580/ban.html + curl -sSk http://localhost:2580/ban.html &>/dev/null + run curl -sSk -m 1 -I http://localhost:2580/ban.html [[ "$output" =~ "HTTP/1.1 200 OK" ]] [[ "$output" =~ "X-Varnish-Cache: HIT" ]] [[ ! "$output" =~ "Cache-Tags: ban.test" ]] unset output # Add a BAN - run curl -sSk -X BAN -I -H "Cache-Tags: ban.test" http://varnish.docksal:2580/ban.html + run curl -sSk -m 1 -X BAN -I -H "Cache-Tags: ban.test" http://localhost:2580/ban.html [[ "$output" =~ "HTTP/1.1 200 Ban added" ]] unset output @@ -156,7 +157,7 @@ _healthcheck_wait () unset output # Confirm cache was purged - run curl -sSk -I http://varnish.docksal:2580/ban.html + run curl -sSk -m 1 -I http://localhost:2580/ban.html [[ "$output" =~ "HTTP/1.1 200 OK" ]] [[ "$output" =~ "X-Varnish-Cache: MISS" ]] unset output