From bfb45c57b8cb71eabde971918b15c0a9519c980b Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Sun, 19 Mar 2023 15:02:37 +1000 Subject: [PATCH] ci(buildkite): localised node artifacts (#5087) This change ensures that vega Buildkite nodes will upload artifacts to a local MinIO instance and also retrieve artifacts from this location if the same constraint is met. --- .buildkite/hooks/post-artifact | 8 ++++++++ .buildkite/hooks/pre-artifact | 1 - .buildkite/hooks/pre-command | 20 +++++++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100755 .buildkite/hooks/post-artifact diff --git a/.buildkite/hooks/post-artifact b/.buildkite/hooks/post-artifact new file mode 100755 index 000000000..08fcae7bf --- /dev/null +++ b/.buildkite/hooks/post-artifact @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set +u + +if [[ "${BUILDKITE_LABEL}" == ":docker: Build Image [coverage]" && "${BUILDKITE_AGENT_NAME}" =~ ^vega[0-9]+$ ]]; then + mv authelia-image-coverage.tar.zst authelia-image-coverage-vega.tar.zst + BUILDKITE_S3_ENDPOINT="${S3_ENDPOINT}" BUILDKITE_ARTIFACT_UPLOAD_DESTINATION="${S3_BUCKET}" BUILDKITE_S3_ACCESS_URL="${S3_ACCESS_URL}" BUILDKITE_S3_ACCESS_KEY_ID="${S3_ACCESS_KEY_ID}" BUILDKITE_S3_SECRET_ACCESS_KEY="${S3_SECRET_ACCESS_KEY}" buildkite-agent artifact upload authelia-image-coverage-vega.tar.zst +fi diff --git a/.buildkite/hooks/pre-artifact b/.buildkite/hooks/pre-artifact index 6b9ab6bfb..da56bdc94 100755 --- a/.buildkite/hooks/pre-artifact +++ b/.buildkite/hooks/pre-artifact @@ -21,7 +21,6 @@ if [[ "${BUILDKITE_LABEL}" == ":hammer_and_wrench: Unit Test" ]]; then fi if [[ "${BUILDKITE_LABEL}" == ":docker: Build Image [coverage]" ]]; then - # Saving image for docker push docker save "${DOCKER_IMAGE}" | zstdmt -T0 -12 > "authelia-image-coverage.tar.zst" fi diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 543d822a4..623f5c909 100755 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -29,14 +29,20 @@ if [[ "${BUILDKITE_LABEL}" =~ ":debian: Build Package" ]]; then fi if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then - DEFAULT_ARCH=coverage echo "--- :docker: Extract and load build container" mkdir coverage - buildkite-agent artifact download "authelia-image-${DEFAULT_ARCH}*" . - if [[ "${SUITE}" == "Kubernetes" ]]; then - zstd -d authelia-image-coverage.tar.zst --stdout > ./internal/suites/example/kube/authelia-image-${DEFAULT_ARCH}.tar + + if [[ "${BUILDKITE_AGENT_NAME}" =~ ^vega[0-9]+$ ]]; then + BUILDKITE_S3_ENDPOINT="${S3_ENDPOINT}" BUILDKITE_ARTIFACT_UPLOAD_DESTINATION="${S3_BUCKET}" BUILDKITE_S3_ACCESS_URL="${S3_ACCESS_URL}" BUILDKITE_S3_ACCESS_KEY_ID="${S3_ACCESS_KEY_ID}" BUILDKITE_S3_SECRET_ACCESS_KEY="${S3_SECRET_ACCESS_KEY}" buildkite-agent artifact download "authelia-image-coverage-vega*" . + mv authelia-image-coverage-vega.tar.zst authelia-image-coverage.tar.zst else - zstdcat "authelia-image-${DEFAULT_ARCH}.tar.zst" | docker load + buildkite-agent artifact download "authelia-image-coverage.*" . + fi + + if [[ "${SUITE}" == "Kubernetes" ]]; then + zstd -d authelia-image-coverage.tar.zst --stdout > ./internal/suites/example/kube/authelia-image-coverage.tar + else + zstdcat "authelia-image-coverage.tar.zst" | docker load fi if [[ "${BUILD_DUO}" == "true" ]] && [[ "${SUITE}" == "DuoPush" ]]; then @@ -55,13 +61,13 @@ if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then fi if [[ "${BUILDKITE_LABEL}" == ":docker: Build and Deploy" ]]; then - echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin + echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin fi if [[ "${BUILDKITE_LABEL}" == ":docker: Deploy Manifest" ]]; then echo "--- :go: :react: :swagger: Extract pre-built binary" buildkite-agent artifact download "authelia-linux-*-musl.tar.gz" . - for archive in authelia-linux-*-musl.tar.gz; do tar xzf ${archive} --wildcards "authelia-linux-*"; done + for archive in authelia-linux-*-musl.tar.gz; do tar xzf "${archive}" --wildcards "authelia-linux-*"; done fi if [[ "${BUILDKITE_LABEL}" == ":github: Deploy Artifacts" ]]; then