-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.downstream
187 lines (147 loc) · 8.68 KB
/
Makefile.downstream
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#
# Copyright Broker QE authors.
# License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
#
ROOT_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# --update-snapshots in mvn below is used to ensure always the latest dependencies version are used
# as an example, artemiscloud-crd generated by us for the downstream build may needs to be rebuild
# multiple times without version number change and our CI job may need to be executed in multiple
# times in a short period causing maven to skip the download of the new dependencies.
MVN_DEFAULT_CMD = echo "MAVEN_OPTS: ${MAVEN_OPTS}" ; echo "MAVEN_ARGS: ${MAVEN_ARGS}" ; mvn --no-transfer-progress --batch-mode --update-snapshots -s ${ROOT_DIR}/settings.xml ${MVN_ADDITIONAL_PARAMS}
MVN_TEST_CMD = ${MVN_DEFAULT_CMD} failsafe:integration-test
MVN_ADDITIONAL_PARAMS ?=
WGET_CMD = wget -nv -c
ARTEMIS_VERSION ?= 7.12.3
RELEASE_TYPE ?= candidate
OPERATOR_ROOT_DIR = ${ROOT_DIR}/operator-suite
STANDALONE_ROOT_DIR = ${ROOT_DIR}/standalone-suite
STANDALONE_ARTEMIS_DIR = ${STANDALONE_ROOT_DIR}/artemis
STANDALONE_ARTEMIS_INSTALL_DIR = ${STANDALONE_ARTEMIS_DIR}/artemis_install
STANDALONE_ARTEMIS_DEFAULT_CFG_DIR = ${STANDALONE_ARTEMIS_DIR}/artemis_default_cfg
STANDALONE_INSTANCE_NAME = artemis-instance
STANDALONE_USER = admin
STANDALONE_PASSWORD = admin
STANDALONE_CONTAINER_ARTEMIS_INSTANCE_DIR = /var/lib/artemis-instance
STANDALONE_CONTAINER_ARTEMIS_INSTANCE_ETC_DIR = ${STANDALONE_CONTAINER_ARTEMIS_INSTANCE_DIR}/etc
COMMIT_ID = $(shell git rev-parse HEAD 2>/dev/null || true)
ifdef TESTS
$(eval MVN_TESTS_PARAM := -Dit.test="${TESTS}")
endif
ifdef TEST_GROUPS
$(eval MVN_GROUPS_PARAM := -Dgroups="${TEST_GROUPS}")
endif
clean: clean_maven standalone_clean operator_clean
- rm -f ${ROOT_DIR}/{settings.xml,version_map.yaml,common.yaml}
clean_maven:
mvn --no-transfer-progress versions:revert clean
build: standalone_prepare operator_prepare build_maven
build_maven:
${MVN_DEFAULT_CMD} versions:update-property -DallowDowngrade=true -Dproperty=artemiscloud-crd.version -DnewVersion=[${OPERATOR_CR_VERSION}]
${MVN_DEFAULT_CMD} -DskipTests install
checkstyle: get_settings_xml_file
${MVN_DEFAULT_CMD} checkstyle:check
get_settings_xml_file:
${WGET_CMD} --no-check-certificate "https://gitlab.cee.redhat.com/amq-broker/amq-broker-ci/-/raw/main/resources/claire/claire-settings.xml" -O "${ROOT_DIR}/settings.xml"
get_metadata_files:
${WGET_CMD} --no-check-certificate "https://gitlab.cee.redhat.com/amq-broker/amq-broker-metadata/-/raw/main/broker_properties/amq_broker/version_map.yaml" -O "${ROOT_DIR}/version_map.yaml"
${WGET_CMD} --no-check-certificate "https://gitlab.cee.redhat.com/amq-broker/amq-broker-metadata/-/raw/main/broker_properties/amq_broker/common.yaml" -O "${ROOT_DIR}/common.yaml"
display_mvn_property_updates: get_settings_xml_file
${MVN_DEFAULT_CMD} versions:display-property-updates
### Standalone targets
standalone_clean:
- rm -rf ${STANDALONE_ARTEMIS_DIR}
standalone_prepare_urls:
$(eval CR_VERSION := $(shell yq '."${ARTEMIS_VERSION}".standalone.${RELEASE_TYPE}' "${ROOT_DIR}/version_map.yaml"))
ifndef ARTEMIS_INSTALL_ZIP
$(eval BROKER_CANDIDATE_URL := $(shell yq '.candidatesBaseUrl' "${ROOT_DIR}/common.yaml"))
$(eval ARTEMIS_INSTALL_ZIP := ${BROKER_CANDIDATE_URL}/amq-broker-${CR_VERSION}/amq-broker-${CR_VERSION}-bin.zip)
endif
standalone_prepare: get_settings_xml_file get_metadata_files standalone_prepare_urls standalone_prepare_dirs standalone_download_zip standalone_generate_artemis_default_cfg
standalone_build_java:
${MVN_DEFAULT_CMD} --projects :standalone-suite --also-make -DskipTests install
standalone_build: standalone_prepare standalone_build_java
standalone_test_smoke:
${MVN_TEST_CMD} --projects :standalone-suite -Dgroups="smoke"
standalone_test:
${MVN_TEST_CMD} --projects :standalone-suite ${MVN_TESTS_PARAM} ${MVN_GROUPS_PARAM}
standalone_prepare_dirs:
mkdir -p ${STANDALONE_ARTEMIS_INSTALL_DIR}
standalone_download_zip:
${WGET_CMD} ${ARTEMIS_INSTALL_ZIP} -P /tmp/
$(eval ARTEMIS_FILE := /tmp/$(shell basename ${ARTEMIS_INSTALL_ZIP}))
cp -f ${ARTEMIS_FILE} ${STANDALONE_ARTEMIS_DIR}/artemis.zip
rm -rf ${STANDALONE_ARTEMIS_INSTALL_DIR}/*
unzip -q -o ${STANDALONE_ARTEMIS_DIR}/artemis.zip -d ${STANDALONE_ARTEMIS_INSTALL_DIR}
mv ${STANDALONE_ARTEMIS_INSTALL_DIR}/*/* ${STANDALONE_ARTEMIS_INSTALL_DIR}
rm -rf ${STANDALONE_ARTEMIS_INSTALL_DIR}/examples
find ${STANDALONE_ARTEMIS_INSTALL_DIR} -maxdepth 1 -type d -name apache-artemis-* -exec rmdir \{\} \;
standalone_generate_artemis_default_cfg:
# create default instance
${STANDALONE_ARTEMIS_INSTALL_DIR}/bin/artemis create --force --name ${STANDALONE_INSTANCE_NAME} \
--user ${STANDALONE_USER} --password ${STANDALONE_PASSWORD} \
--require-login ${STANDALONE_ARTEMIS_DEFAULT_CFG_DIR}
# update artemis command with correct container instance path
sed -i.bak -re "s#^(ARTEMIS_INSTANCE_ETC=)(.*)#\1'${STANDALONE_CONTAINER_ARTEMIS_INSTANCE_ETC_DIR}'#" \
${STANDALONE_ARTEMIS_DEFAULT_CFG_DIR}/bin/artemis
### Operator targets
operator_clean:
- rm -rf ${OPERATOR_ROOT_DIR}/artemis
operator_prepare_dirs:
mkdir -p ${OPERATOR_ROOT_DIR}/artemis
operator_prepare_urls:
$(eval OPERATOR_CR_VERSION := $(shell \
yq '."dev.latest"' version_map.yaml | grep ${ARTEMIS_VERSION} > /dev/null && echo main \
|| yq .\"${ARTEMIS_VERSION}\".operator.${RELEASE_TYPE} version_map.yaml | grep ${ARTEMIS_VERSION} \
|| yq .\"${ARTEMIS_VERSION}\".upstream_operator version_map.yaml; \
))
operator_prepare: get_settings_xml_file get_metadata_files operator_prepare_urls operator_prepare_dirs
operator_build_java:
${MVN_DEFAULT_CMD} versions:update-property -DallowDowngrade=true -Dproperty=artemiscloud-crd.version -DnewVersion=[${OPERATOR_CR_VERSION}]
${MVN_DEFAULT_CMD} --projects :operator-suite -DskipTests --also-make install
operator_build: operator_prepare operator_build_java
operator_get_dependencies: operator_prepare
${MVN_DEFAULT_CMD} versions:update-property -DallowDowngrade=true -Dproperty=artemiscloud-crd.version -DnewVersion=[${OPERATOR_CR_VERSION}]
${MVN_DEFAULT_CMD} --projects :claire,:operator-suite,:common dependency:go-offline dependency:resolve-plugins
operator_test_smoke:
${MVN_TEST_CMD} --projects :operator-suite -Dgroups="smoke"
operator_copy_test_results:
- cp -axv ${ROOT_DIR}/operator-suite/target/failsafe-reports/* ${ROOT_DIR}/test-results/operator-suite/
operator_test:
${MVN_TEST_CMD} --projects :operator-suite ${MVN_TESTS_PARAM} ${MVN_GROUPS_PARAM}
### Common targets
common_build: get_settings_xml_file get_metadata_files common_build_java
common_build_java:
${MVN_DEFAULT_CMD} --projects common -DskipTests -Dcheckstyle.skip install
### Container image targets
container_prepare:
$(eval OPR_VERSION := amq-broker-$(shell echo "${OPERATOR_CR_VERSION}" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+\.[A-Za-z0-9]+\.[0-9]+).*/\1/'))
$(eval VERSION_MM := amq-broker-$(shell echo "${OPERATOR_CR_VERSION}" | sed -E 's/([0-9]+\.[0-9]+).*/\1/'))
$(eval VERSION_MMM := amq-broker-$(shell echo "${OPERATOR_CR_VERSION}" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/'))
container_build: clean operator_prepare container_prepare
echo "Preparing host for multi arch build"
sudo podman run --privileged --rm quay.io/rhmessagingqe/binfmt:latest --install all
echo "Building container"
podman manifest rm quay.io/rhmessagingqe/claire:${OPR_VERSION} 2> /dev/null || true
podman build \
--file operator-suite/container/Containerfile \
--manifest quay.io/rhmessagingqe/claire:${OPR_VERSION} \
--platform linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \
--jobs 42 \
--build-arg makeParams="-f Makefile.downstream" \
--build-arg commitId=${COMMIT_ID} \
.
container_push: operator_prepare container_prepare
podman push quay.io/rhmessagingqe/claire:${OPR_VERSION}
podman tag \
quay.io/rhmessagingqe/claire:${OPR_VERSION} \
quay.io/rhmessagingqe/claire:${VERSION_MMM}
podman push quay.io/rhmessagingqe/claire:${VERSION_MMM}
podman tag \
quay.io/rhmessagingqe/claire:${OPR_VERSION} \
quay.io/rhmessagingqe/claire:${VERSION_MM}
podman push quay.io/rhmessagingqe/claire:${VERSION_MM}
podman tag \
quay.io/rhmessagingqe/claire:${OPR_VERSION} \
quay.io/rhmessagingqe/claire:amq-broker-lpt
podman push quay.io/rhmessagingqe/claire:amq-broker-lpt
.PHONY: clean