Skip to content

Commit 878622e

Browse files
authored
sps enablement for master (#1080)
1 parent 5fd3652 commit 878622e

File tree

6 files changed

+162
-10
lines changed

6 files changed

+162
-10
lines changed

.pipeline-config-ci.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: '2'
2+
3+
# CI Pipeline: code-checks, code-build, deploy-checks, deploy-release
4+
tasks:
5+
code-checks:
6+
# code-checks includes five configurable steps: setup, detect-secrets, compliance-checks, peer-review, static-scan
7+
include:
8+
- dind
9+
steps:
10+
- name: checks-setup
11+
when: 'false'
12+
- name: detect-secrets
13+
when: 'false'
14+
- name: compliance-checks
15+
when: 'false'
16+
- name: peer-review
17+
when: 'false'
18+
- name: static-scan
19+
when: 'false'
20+
21+
code-build:
22+
runtimeClassName: medium
23+
displayName: Build amd64, ppc64le and s390x images
24+
include:
25+
- dind
26+
# code-build includes five configurable steps: setup, unit-test, build-artifact, sign-artifact, scan-artifact
27+
steps:
28+
- name: setup
29+
when: 'false'
30+
- name: unit-test
31+
when: 'false'
32+
- name: build-artifact
33+
include:
34+
- docker-socket
35+
- dind
36+
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.66
37+
script: |
38+
#!/usr/bin/env bash
39+
if [[ "$PIPELINE_DEBUG" == 1 ]]; then
40+
trap env EXIT
41+
env
42+
set -x
43+
fi
44+
cd "$WORKSPACE/$(load_repo app-repo path)"
45+
export ARCH="amd64"
46+
export GIT_BRANCH="$(get_env git-branch)"
47+
export GIT_COMMIT="$(get_env git-commit)"
48+
export BUILD_TAG="$(cat internal/version/version.go | tr -d '\n')"
49+
source build_scripts/setup_env.sh
50+
source build_scripts/build_image.sh
51+
- name: sign-artifact
52+
when: 'false'
53+
- name: scan-artifact
54+
when: 'false'
55+
56+
deploy-checks:
57+
include:
58+
- dind
59+
# deploy-checks includes three configurable steps: deploy, dynamic-scan, acceptance-test
60+
steps:
61+
- name: deploy
62+
when: 'false'
63+
- name: dynamic-scan
64+
when: 'false'
65+
- name: acceptance-test
66+
when: 'false'
67+
68+
deploy-release:
69+
# deploy-release includes one configurable step: run-stage
70+
steps:
71+
- name: run-stage
72+
when: 'false'
73+
74+
finally:
75+
code-ci-finish:
76+
steps:
77+
- name: run-stage
78+
when: 'false'

.pipeline-config-pr.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '2'
2+
3+
# PR Pipeline: pr-code-checks, code-pr-finish
4+
tasks:
5+
pr-code-checks:
6+
runtimeClassName: medium
7+
displayName: Build amd64, ppc64le and s390x images
8+
include:
9+
- dind
10+
steps:
11+
- name: checks-setup
12+
when: 'false'
13+
- name: detect-secrets
14+
when: 'false'
15+
- name: unit-test
16+
include:
17+
- docker-socket
18+
- dind
19+
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.66
20+
script: |
21+
#!/usr/bin/env bash
22+
if [[ "$PIPELINE_DEBUG" == 1 ]]; then
23+
trap env EXIT
24+
env
25+
set -x
26+
fi
27+
cd "$WORKSPACE/$(load_repo app-repo path)"
28+
export ARCH="amd64"
29+
export GIT_BRANCH="$(get_env git-branch)"
30+
export GIT_COMMIT="$(get_env git-commit)"
31+
export BUILD_TAG="${GIT_COMMIT:0:7}"
32+
source build_scripts/setup_env.sh
33+
source build_scripts/build_image.sh
34+
- name: compliance-checks
35+
when: 'false'
36+
37+
finally:
38+
code-pr-finish:
39+
steps:
40+
- name: run-stage
41+
when: 'false'

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
FROM docker-na-public.artifactory.swg-devops.com/hyc-cloud-private-edge-docker-local/build-images/ubi9-minimal:latest
1616

1717
ARG VCS_REF
18-
ARG VCS_URL
1918
ARG IMG_VERSION
2019
ARG IMG_RELEASE
2120

2221
LABEL org.label-schema.vendor="IBM" \
2322
org.label-schema.name="ibm-iam-operator" \
2423
org.label-schema.description="IBM IAM Operator" \
2524
org.label-schema.vcs-ref=$VCS_REF \
26-
org.label-schema.vcs-url=$VCS_URL \
2725
org.label-schema.license="Licensed Materials - Property of IBM" \
2826
org.label-schema.schema-version="1.0" \
2927
name="ibm-iam-operator" \

Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ DATA_NS ?= $(CONTROL_NS)
2626
WATCH_NS ?= $(DATA_NS)
2727

2828
GIT_COMMIT_ID=$(shell git rev-parse --short HEAD)
29-
GIT_REMOTE_URL=$(shell git config --get remote.origin.url)
30-
IMAGE_BUILD_OPTS=--build-arg "VCS_REF=$(GIT_COMMIT_ID)" --build-arg "VCS_URL=$(GIT_REMOTE_URL)" --build-arg "IMG_VERSION=$(VERSION)" --build-arg "IMG_RELEASE=$(shell date +%s)"
29+
IMAGE_BUILD_OPTS=--build-arg "VCS_REF=$(GIT_COMMIT_ID)" --build-arg "IMG_VERSION=$(VERSION)" --build-arg "IMG_RELEASE=$(shell date +%s)"
3130

3231
# Image URL to use all building/pushing image targets;
3332
# Use your own docker registry and image name for dev/test by overridding the IMG and REGISTRY environment variable.
@@ -37,9 +36,6 @@ CONTAINER_CLI ?= docker
3736

3837
MARKDOWN_LINT_WHITELIST=https://quay.io/cnr
3938

40-
ifeq ($(BUILD_LOCALLY),0)
41-
export CONFIG_DOCKER_TARGET = config-docker
42-
endif
4339

4440
TESTARGS_DEFAULT := "-v"
4541
export TESTARGS ?= $(TESTARGS_DEFAULT)
@@ -414,7 +410,7 @@ bundle-render: ## Render the bundle contents into the local FBC index.
414410
./hack/bundle-render $(IMG).v$(BUNDLE_VERSION) $(BUNDLE_IMG)
415411

416412
TARGET_ARCH=$(LOCAL_ARCH)
417-
build-image: $(GO) $(CONFIG_DOCKER_TARGET) licenses-dir ## Build the Operator manager image
413+
build-image: $(GO) licenses-dir ## Build the Operator manager image
418414
@echo "Building manager binary for linux/$(TARGET_ARCH)"
419415
@CGO_ENABLED=0 GOOS=linux GOARCH=$(TARGET_ARCH) $(GO) build -a -o build/_output/bin/manager cmd/main.go
420416
@echo "Building manager image for linux/$(TARGET_ARCH)"
@@ -437,11 +433,13 @@ build-image-ppc64le: build-image
437433
build-image-s390x: TARGET_ARCH=s390x
438434
build-image-s390x: build-image
439435

440-
images: $(CONFIG_DOCKER_TARGET) ## Build the multi-arch manifest.
436+
images:
441437
@${MAKE} build-image-amd64
442438
@${MAKE} build-image-ppc64le
443439
@${MAKE} build-image-s390x
444-
@DOCKER_BUILDKIT=1 MAX_PULLING_RETRY=20 RETRY_INTERVAL=30 common/scripts/multiarch_image.sh $(REGISTRY) $(IMG) $(GIT_COMMIT_ID) $(VERSION)
440+
@if [ "$(SPS_EVENT_TYPE)" = "push" ]; then \
441+
DOCKER_BUILDKIT=1 MAX_PULLING_RETRY=20 RETRY_INTERVAL=30 common/scripts/multiarch_image.sh $(REGISTRY) $(IMG) $(GIT_COMMIT_ID) $(VERSION); \
442+
fi
445443

446444
##@ Deployment
447445

build_scripts/build_image.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export BUILD_LOCALLY=0
2+
3+
echo "***************** Install go *****************"
4+
5+
GO_VERSION="1.24.5"
6+
curl -sLO "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
7+
sudo rm -rf /usr/local/go
8+
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
9+
rm "go${GO_VERSION}.linux-amd64.tar.gz"
10+
11+
grep -q '/usr/local/go/bin' ~/.bashrc || echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
12+
source ~/.bashrc
13+
go version
14+
15+
echo "**************** Building images ****************"
16+
17+
make images

build_scripts/setup_env.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Set up Needed Variables
2+
export ARTIFACTORY_USERNAME="$(get_env ARTIFACTORY_USERNAME)"
3+
export ARTIFACTORY_TOKEN="$(get_env ARTIFACTORY_TOKEN)"
4+
export DOCKER_REGISTRY="$(get_env DOCKER_REGISTRY)"
5+
export DOCKER_USER="$(get_env DOCKER_USER)"
6+
export DOCKER_PASS="$(get_env DOCKER_PASS)"
7+
export GITHUB_TOKEN="$(get_env GITHUB_TOKEN)"
8+
export GITHUB_USER="$(get_env GITHUB_USER)"
9+
export SPS_EVENT_TYPE="$(get_env SPS_EVENT_TYPE)"
10+
11+
# Configure Environment
12+
echo -e "machine github.ibm.com\n login $GITHUB_TOKEN" >> ~/.netrc
13+
chmod 600 ~/.netrc
14+
git config --global --add safe.directory $WORKSPACE/$(load_repo app-repo path)
15+
# Output Paremeters
16+
echo "Current branch : $GIT_BRANCH"
17+
echo "Building commit $GIT_COMMIT"
18+
19+
# Login to root artifactory (to cover both base images and build image)
20+
docker login docker-na-public.artifactory.swg-devops.com -u ARTIFACTORY_USERNAME -p ARTIFACTORY_TOKEN

0 commit comments

Comments
 (0)