-
Notifications
You must be signed in to change notification settings - Fork 82
217 lines (183 loc) · 8.32 KB
/
build-pr.yml
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Build PR
on:
workflow_dispatch:
pull_request:
env:
test_container_name_oss: hazelcast-oss-test
test_container_name_ee: hazelcast-ee-test
docker_log_file_oss: docker-hazelcast-oss-test.log
docker_log_file_ee: docker-hazelcast-ee-test.log
jobs:
prepare:
runs-on: ubuntu-latest
name: Prepare environment
outputs:
HZ_VERSION_OSS: ${{ steps.get_oss_vars.outputs.HZ_VERSION_OSS }}
HZ_VERSION_EE: ${{ steps.get_ee_vars.outputs.HZ_VERSION_EE }}
LAST_RELEASED_HZ_VERSION_OSS: ${{ steps.get_oss_vars.outputs.LAST_RELEASED_HZ_VERSION_OSS }}
HAZELCAST_EE_ZIP_URL: ${{ steps.get_ee_vars.outputs.HAZELCAST_EE_ZIP_URL }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Forbid .github/release_type file
run: |
if [ -f ".github/release_type" ]; then
echo "Error: .github/release_type file is not allowed in the PRs. It's used only during release creation"
exit 1
fi
- name: Test scripts
run: |
.github/scripts/test_scripts.sh
- name: Setup OSS variables
id: get_oss_vars
run: |
HZ_VERSION_OSS=$(awk -F '=' '/^ARG HZ_VERSION=/ {print $2}' hazelcast-oss/Dockerfile)
echo "HZ_VERSION_OSS=$HZ_VERSION_OSS" >> $GITHUB_OUTPUT
source hazelcast-oss/maven.functions.sh
LAST_RELEASED_HZ_VERSION_OSS="$(get_latest_version com.hazelcast hazelcast-distribution https://repo1.maven.org/maven2)";
echo "LAST_RELEASED_HZ_VERSION_OSS=$LAST_RELEASED_HZ_VERSION_OSS" >> $GITHUB_OUTPUT
- name: Setup EE variables
id: get_ee_vars
run: |
HZ_VERSION_EE=$(awk -F '=' '/^ARG HZ_VERSION=/ {print $2}' hazelcast-enterprise/Dockerfile)
. .github/scripts/ee-build.functions.sh
echo "HZ_VERSION_EE=$HZ_VERSION_EE" >> $GITHUB_OUTPUT
echo "HAZELCAST_EE_ZIP_URL=$(get_hz_dist_zip "" ${HZ_VERSION_EE})" >> $GITHUB_OUTPUT
build-pr:
runs-on: ubuntu-latest
name: Build with default JDK
needs: [ prepare ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Build OSS image
run: |
DOCKER_PATH=hazelcast-oss
HZ_VERSION="${{ needs.prepare.outputs.HZ_VERSION_OSS }}"
# duplicated block as GH doesn't support passing sensitive data between jobs
. .github/scripts/oss-build.functions.sh
export HZ_SNAPSHOT_INTERNAL_PASSWORD=${{ secrets.HZ_SNAPSHOT_INTERNAL_PASSWORD }}
export HZ_SNAPSHOT_INTERNAL_USERNAME=${{ secrets.HZ_SNAPSHOT_INTERNAL_USERNAME }}
HAZELCAST_OSS_ZIP_URL=$(get_hz_dist_zip "" "${HZ_VERSION}")
curl --fail --silent --show-error --location "$HAZELCAST_OSS_ZIP_URL" --output $DOCKER_PATH/hazelcast-distribution.zip;
docker buildx build --load \
--build-arg HZ_VERSION=${HZ_VERSION} \
--tag hazelcast-oss:test \
${DOCKER_PATH}
- name: Run smoke test against OSS image
timeout-minutes: 2
run: |
. .github/scripts/docker.functions.sh
.github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ needs.prepare.outputs.HZ_VERSION_OSS }} "$(get_default_jdk hazelcast-oss)"
- name: Build Test EE image
run: |
DOCKER_PATH=hazelcast-enterprise
HZ_VERSION="${{ needs.prepare.outputs.HZ_VERSION_EE }}"
curl --fail --silent --show-error --location "${{ needs.prepare.outputs.HAZELCAST_EE_ZIP_URL }}" --output $DOCKER_PATH/hazelcast-enterprise-distribution.zip;
docker buildx build --load \
--build-arg HZ_VERSION=${HZ_VERSION} \
--tag hazelcast-ee:test \
${DOCKER_PATH}
- name: Run smoke test against EE image
timeout-minutes: 2
run: |
. .github/scripts/docker.functions.sh
export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }}
.github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ needs.prepare.outputs.HZ_VERSION_EE }} "$(get_default_jdk hazelcast-enterprise)"
- name: Get docker logs
if: ${{ always() }}
run: |
docker logs ${{ env.test_container_name_oss }} > ${{ env.docker_log_file_oss }}
docker logs ${{ env.test_container_name_ee }} > ${{ env.docker_log_file_ee }}
- name: Store docker logs as artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: docker-logs-${{ github.job }}
path: |
${{ env.docker_log_file_oss }}
${{ env.docker_log_file_ee }}
jdks:
uses: ./.github/workflows/get-supported-jdks.yaml
build-pr-custom-jdk:
runs-on: ubuntu-latest
needs: [ jdks, prepare ]
name: Build with jdk-${{ matrix.jdk }}
strategy:
fail-fast: false
matrix:
jdk: ${{ fromJSON(needs.jdks.outputs.jdks) }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Build OSS image
run: |
DOCKER_PATH=hazelcast-oss
HZ_VERSION="${{ needs.prepare.outputs.HZ_VERSION_OSS }}"
# duplicated block as GH doesn't support passing sensitive data between jobs
. .github/scripts/oss-build.functions.sh
export HZ_SNAPSHOT_INTERNAL_PASSWORD=${{ secrets.HZ_SNAPSHOT_INTERNAL_PASSWORD }}
export HZ_SNAPSHOT_INTERNAL_USERNAME=${{ secrets.HZ_SNAPSHOT_INTERNAL_USERNAME }}
HAZELCAST_OSS_ZIP_URL=$(get_hz_dist_zip "" "${HZ_VERSION}")
curl --fail --silent --show-error --location "$HAZELCAST_OSS_ZIP_URL" --output $DOCKER_PATH/hazelcast-distribution.zip;
docker buildx build --load \
--build-arg JDK_VERSION=${{ matrix.jdk }} \
--build-arg HZ_VERSION=${HZ_VERSION} \
--tag hazelcast-oss:test \
${DOCKER_PATH}
- name: Run smoke test against OSS image
timeout-minutes: 2
run: |
.github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ needs.prepare.outputs.HZ_VERSION_OSS }} ${{ matrix.jdk }}
- name: Build Test EE image
run: |
DOCKER_PATH=hazelcast-enterprise
HZ_VERSION="${{ needs.prepare.outputs.HZ_VERSION_EE }}"
curl --fail --silent --show-error --location "${{ needs.prepare.outputs.HAZELCAST_EE_ZIP_URL }}" --output $DOCKER_PATH/hazelcast-enterprise-distribution.zip;
docker buildx build --load \
--build-arg JDK_VERSION=${{ matrix.jdk }} \
--build-arg HZ_VERSION=${HZ_VERSION} \
--tag hazelcast-ee:test \
${DOCKER_PATH}
- name: Run smoke test against EE image
timeout-minutes: 2
run: |
export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }}
.github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ needs.prepare.outputs.HZ_VERSION_EE }} ${{ matrix.jdk }}
- name: Get docker logs
if: ${{ always() }}
run: |
docker logs ${{ env.test_container_name_oss }} > ${{ env.docker_log_file_oss }}
docker logs ${{ env.test_container_name_ee }} > ${{ env.docker_log_file_ee }}
- name: Store docker logs as artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: docker-logs-${{ github.job }}-jdk${{ matrix.jdk }}
path: |
${{ env.docker_log_file_oss }}
${{ env.docker_log_file_ee }}
test-push:
name: Test pushing image (dry run)
needs: [ prepare ]
uses: ./.github/workflows/tag_image_push.yml
with:
HZ_VERSION: ${{ needs.prepare.outputs.LAST_RELEASED_HZ_VERSION_OSS }}
RELEASE_VERSION: ${{ needs.prepare.outputs.LAST_RELEASED_HZ_VERSION_OSS }}
RELEASE_TYPE: ALL
DRY_RUN: true
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
HZ_ENTERPRISE_LICENSE: ${{ secrets.HZ_ENTERPRISE_LICENSE }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}