From 63bea75ee1d7ab5c567ac79c0108598801ddeb83 Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com> Date: Tue, 1 Mar 2022 16:35:39 +0000 Subject: [PATCH] feat: split release build and deploy (#3879) * feat: split release build and deploy * fix: only build_release on main * chore: fix build_perf CI * fix: deploy_release checkout * fix: update deploy_release image * fix: deploy_release credentials * fix: add COMMIT_SHA to env Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .circleci/config.yml | 61 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f91c6ab5d1..2bb8221762 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -425,14 +425,12 @@ jobs: COMMIT_SHA="$(git rev-parse --short HEAD)" RUST_VERSION="$(sed -E -ne 's/channel = "(.*)"/\1/p' rust-toolchain.toml)" - BRANCH="$(echo "$CIRCLE_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/_/g')" docker buildx build \ --build-arg RUST_VERSION="$RUST_VERSION" \ --build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \ --progress plain \ --tag quay.io/influxdb/iox:"$COMMIT_SHA" \ - --tag quay.io/influxdb/iox:"$BRANCH" \ . docker buildx build \ --build-arg FEATURES="" \ @@ -441,7 +439,6 @@ jobs: --build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \ --progress plain \ --tag quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" \ - --tag quay.io/influxdb/iox_data_generator:"$BRANCH" \ . docker buildx build \ --build-arg FEATURES="" \ @@ -450,24 +447,52 @@ jobs: --build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \ --progress plain \ --tag quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA" \ - --tag quay.io/influxdb/iox_gitops_adapter:"$BRANCH" \ . docker run -it --rm quay.io/influxdb/iox:$COMMIT_SHA debug print-cpu - docker push --all-tags quay.io/influxdb/iox - docker push --all-tags quay.io/influxdb/iox_data_generator - docker push --all-tags quay.io/influxdb/iox_gitops_adapter - - echo "export COMMIT_SHA=${COMMIT_SHA}" >> $BASH_ENV + docker push quay.io/influxdb/iox:"$COMMIT_SHA" + docker push quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" + docker push quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA" # linking might take a while and doesn't produce CLI output - no_output_timeout: 20m + no_output_timeout: 30m + - cache_save + + deploy_release: + docker: + - image: cimg/base:2021.04 + steps: + - setup_remote_docker: + version: 19.03.13 + docker_layer_caching: true + - checkout + - run: | + echo "$QUAY_INFLUXDB_IOX_PASS" | docker login quay.io --username $QUAY_INFLUXDB_IOX_USER --password-stdin + - run: + name: Update docker branch tags + command: | + COMMIT_SHA="$(git rev-parse --short HEAD)" + BRANCH="$(echo "$CIRCLE_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/_/g')" + + docker pull quay.io/influxdb/iox:"$COMMIT_SHA" + docker pull quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" + docker pull quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA" + + docker tag quay.io/influxdb/iox:"$COMMIT_SHA" quay.io/influxdb/iox:"$BRANCH" + docker tag quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" quay.io/influxdb/iox_data_generator:"$BRANCH" + docker tag quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA" quay.io/influxdb/iox_gitops_adapter:"$BRANCH" + + docker push quay.io/influxdb/iox:"$BRANCH" + docker push quay.io/influxdb/iox_data_generator:"$BRANCH" + docker push quay.io/influxdb/iox_gitops_adapter:"$BRANCH" + + echo "export COMMIT_SHA=${COMMIT_SHA}" >> $BASH_ENV - run: name: Deploy tags command: | echo "$QUAY_PASS" | docker login quay.io --username $QUAY_USER --password-stdin ./.circleci/get-deploy-tags.sh "${COMMIT_SHA}" - - cache_save + # Prepare the CI image used for other tasks. # @@ -512,7 +537,9 @@ workflows: # CI for all pull requests. ci: when: - not: << pipeline.parameters.ci_image >> + and: + - not: << pipeline.parameters.ci_image >> + - not: << pipeline.parameters.build_perf >> jobs: - fmt - lint @@ -529,7 +556,11 @@ workflows: filters: branches: only: main - requires: # Only do a release build if all tests have passed + - deploy_release: + filters: + branches: + only: main + requires: # Only deploy if all tests have passed - fmt - lint - cargo_audit @@ -539,6 +570,7 @@ workflows: - test_heappy - test_perf - build_dev + - build_release - doc # Manual build of CI image @@ -563,6 +595,9 @@ workflows: when: << pipeline.parameters.build_perf >> jobs: - build_release + - deploy_release: + requires: + - build_release # Nightly rebuild of the build container ci_image_nightly: