-
Notifications
You must be signed in to change notification settings - Fork 78
132 lines (123 loc) · 5.31 KB
/
cross-maven.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
#
# Copyright Debezium Authors
#
# Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
#
# Cross CI workflow is triggered on a `pull_request` event.
# It builds the Debezium core before building the Debezium Server basing on either the `main` branch or the `pull_request` branch.
# If a `pull_request` with same branch name is present in the Debezium's upstream core repository, then the core build of this `pull_request`
# will be based on `pull_request` branch of user's Debezium core repository.
# Otherwise the core build of this `pull_request` will be based on the `main` branch of Debezium's upstream core repository.
name: Cross Maven CI
on:
pull_request:
branches:
- main
- 1.*
- 2.*
paths-ignore:
- '*.md'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Debezium Server repository
uses: actions/checkout@v4
with:
path: server
- name: Check if pull request branch exists in debezium main repository
id: branch
env:
branch_name: ${{ github.head_ref }}
run: |
curl --silent -X "GET" https://api.github.com/repos/debezium/debezium/pulls | jq '.[] | {branch: .head.ref}' | jq -r '.branch' >> SORTED_PULLS.txt
while IFS=" " read -r BRANCH;
do
if grep -q "$branch_name" <<< "$BRANCH"; then
echo "BRANCH_FOUND=true" >> $GITHUB_OUTPUT
fi
done < SORTED_PULLS.txt
- name: Checkout core repository with pull request branch
if: ${{ steps.branch.outputs.BRANCH_FOUND == 'true' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.user.login }}/debezium
ref: ${{ github.head_ref }}
path: core
- name: Checkout core repository with default base branch
if: ${{ steps.branch.outputs.BRANCH_FOUND != 'true' }}
uses: actions/checkout@v4
with:
repository: debezium/debezium
ref: ${{ github.base_ref }}
path: core
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Maven build core
run: ./server/mvnw clean install -f core/pom.xml -DskipTests -DskipITs -Dformat.formatter.goal=validate -Dformat.imports.goal=check -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
- name: Maven build Debezium Server
run: ./server/mvnw clean install -fae -f server/pom.xml -Passembly -Dformat.formatter.goal=validate -Dformat.imports.goal=check -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -DskipNonCore
- name: Archive Debezium distribution
uses: actions/upload-artifact@v4
with:
name: debezium-dist-artifact
path: ./server/debezium-server-dist/target/debezium-server-dist*.tar.gz
validate-distribution:
name: Verify debezium-server distribution
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sink: [ redis ]
needs: build
steps:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Checkout Debezium Server repository
uses: actions/checkout@v4
with:
path: server
- name: Download Debezium distribution
uses: actions/download-artifact@v4
with:
name: debezium-dist-artifact
- name: Unzip Debezium distribution
run: tar xf debezium-server-dist-*.tar.gz
- name: Validate sink '${{matrix.sink}}'
run: |
# Creating the distribution archives
DISTRIBUTION_FOLDER=./debezium-server
SINK=${{matrix.sink}}
CONFIG_FOLDER=./server/debezium-server-dist/src/test/resources/$SINK
# Start Up dependant services
docker compose -f $CONFIG_FOLDER/docker-compose.yml up -d
# Copy configuration file
cp $CONFIG_FOLDER/application.properties $DISTRIBUTION_FOLDER/config/application.properties
# Run debezium server at background
docker run --name server-$SINK -d -v $DISTRIBUTION_FOLDER:/opt:z -p 8080:8080 --network debezium-backend -w /opt registry.access.redhat.com/ubi8/openjdk-21 ./run.sh
# Verify
timeout 60 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/q/health)" != "200" ]]; do sleep 5; done' || false
- name: Print logs
if: failure()
run: |
echo "Logs from dependant services:"
docker compose -f ./server/debezium-server-dist/src/test/resources/${{matrix.sink}}/docker-compose.yml logs
echo "Logs from Debezium server:"
docker logs server-${{matrix.sink}}
- name: Clean Up
if: always()
run: |
docker rm -f server-${{matrix.sink}}
docker compose -f ./server/debezium-server-dist/src/test/resources/${{matrix.sink}}/docker-compose.yml down