From 97dff2cc87c66e7f97a28ae43c86ec9d08ac2a7d Mon Sep 17 00:00:00 2001 From: Casey Davenport Date: Tue, 21 Jan 2025 10:15:54 -0800 Subject: [PATCH] Add image publishing semaphore config --- .semaphore/push-images/goldmane.yml | 47 ++++++++++++++++++++ .semaphore/semaphore.yml.d/03-promotions.yml | 4 ++ goldmane/Makefile | 10 ++++- goldmane/pkg/aggregator/aggregator_test.go | 2 +- 4 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 .semaphore/push-images/goldmane.yml diff --git a/.semaphore/push-images/goldmane.yml b/.semaphore/push-images/goldmane.yml new file mode 100644 index 00000000000..9d358bff4eb --- /dev/null +++ b/.semaphore/push-images/goldmane.yml @@ -0,0 +1,47 @@ +version: v1.0 +name: Publish goldmane images +agent: + machine: + type: f1-standard-2 + os_image: ubuntu2204 + +execution_time_limit: + minutes: 60 + +global_job_config: + env_vars: + - name: DEV_REGISTRIES + value: quay.io/calico docker.io/calico + secrets: + - name: docker + - name: quay-robot-calico+semaphoreci + prologue: + commands: + - checkout + # Semaphore is doing shallow clone on a commit without tags. + # unshallow it for GIT_VERSION:=$(shell git describe --tags --dirty --always) + - retry git fetch --unshallow + - echo $DOCKER_TOKEN | docker login --username "$DOCKER_USER" --password-stdin + - echo $QUAY_TOKEN | docker login --username "$QUAY_USER" --password-stdin quay.io + - export BRANCH_NAME=$SEMAPHORE_GIT_BRANCH + +blocks: + - name: Publish goldmane images + dependencies: [] + skip: + when: "branch !~ '.+'" + task: + jobs: + - name: Linux multi-arch + commands: + - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C goldmane cd CONFIRM=true; fi + - name: Publish goldmane multi-arch manifests + dependencies: + - Publish goldmane images + skip: + when: "branch !~ '.+'" + task: + jobs: + - name: Linux multi-arch manifests + commands: + - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C goldmane push-manifests-with-tag CONFIRM=true; fi diff --git a/.semaphore/semaphore.yml.d/03-promotions.yml b/.semaphore/semaphore.yml.d/03-promotions.yml index d5f3343dbea..dc902d1aeaa 100644 --- a/.semaphore/semaphore.yml.d/03-promotions.yml +++ b/.semaphore/semaphore.yml.d/03-promotions.yml @@ -51,6 +51,10 @@ promotions: pipeline_file: push-images/typha.yml auto_promote: when: "branch =~ 'master|release-'" + - name: Push Goldmane images + pipeline_file: push-images/goldmane.yml + auto_promote: + when: "branch =~ 'master|release-'" - name: Publish openstack packages pipeline_file: push-images/packaging.yaml auto_promote: diff --git a/goldmane/Makefile b/goldmane/Makefile index f4efef0dde2..734c869d712 100644 --- a/goldmane/Makefile +++ b/goldmane/Makefile @@ -10,6 +10,9 @@ IMAGE_BUILD_MARKER = goldmane_container-$(ARCH).created ############################################################################### include ../lib.Makefile +# Configure variables used by ci/cd common targets from lib.Makefile. +BUILD_IMAGES=goldmane + .PHONY: image build image: $(IMAGE_BUILD_MARKER) build: bin/goldmane-$(ARCH) @@ -24,8 +27,8 @@ sub-image-%: # Build goldmane image. calico/goldmane: $(IMAGE_BUILD_MARKER) $(IMAGE_BUILD_MARKER): bin/goldmane-$(ARCH) - $(DOCKER_BUILD) --build-arg TARGETARCH=$(ARCH) -t calico/goldmane:latest-$(ARCH) -f docker/Dockerfile . - $(MAKE) retag-build-images-with-registries BUILD_IMAGES=calico/goldmane VALIDARCHES=$(ARCH) IMAGETAG=latest + $(DOCKER_BUILD) --build-arg TARGETARCH=$(ARCH) -t goldmane:latest-$(ARCH) -f docker/Dockerfile . + $(MAKE) retag-build-images-with-registries BUILD_IMAGES=$(BUILD_IMAGES) VALIDARCHES=$(ARCH) IMAGETAG=latest touch $@ bin/goldmane-$(ARCH): $(shell find . -name '*.go') @@ -55,6 +58,9 @@ ut: ############################################################################### # Release ############################################################################### +## Deploys images to registry +cd: image-all cd-common + release-build: .release-$(VERSION).created .release-$(VERSION).created: $(MAKE) clean image-all RELEASE=true diff --git a/goldmane/pkg/aggregator/aggregator_test.go b/goldmane/pkg/aggregator/aggregator_test.go index ef8d1fa448a..f5964e761a9 100644 --- a/goldmane/pkg/aggregator/aggregator_test.go +++ b/goldmane/pkg/aggregator/aggregator_test.go @@ -20,13 +20,13 @@ import ( "time" "github.com/stretchr/testify/require" + googleproto "google.golang.org/protobuf/proto" "github.com/projectcalico/calico/goldmane/pkg/aggregator" "github.com/projectcalico/calico/goldmane/pkg/internal/types" "github.com/projectcalico/calico/goldmane/pkg/internal/utils" "github.com/projectcalico/calico/goldmane/proto" "github.com/projectcalico/calico/libcalico-go/lib/logutils" - googleproto "google.golang.org/protobuf/proto" ) var (