-
Notifications
You must be signed in to change notification settings - Fork 5
243 lines (197 loc) · 8.01 KB
/
Copy pathci.yml
File metadata and controls
243 lines (197 loc) · 8.01 KB
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Flink SQL Runner CI
on:
release:
types: [ created ]
push:
branches:
- main
- release-*
pull_request:
branches:
- main
- release-*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
cache-dependencies:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: read
outputs:
project-version: ${{ steps.version.outputs.project_version }}
flink-version-label: ${{ steps.version.outputs.flink_version_label }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK
uses: ./.github/actions/setup-jdk
- name: Download dependencies
run: |
mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.9.0:go-offline de.qaware.maven:go-offline-maven-plugin:1.2.8:resolve-dependencies
mvn -B -f flink-sql-runner/pom.xml org.apache.maven.plugins:maven-resources-plugin:3.3.1:resources
- name: Get project version
id: version
run: |
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "created" ]]; then
echo "project_version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "project_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
fi
echo "flink_version_label=$(mvn help:evaluate -Dexpression=flink.version.label -q -DforceStdout)" >> $GITHUB_OUTPUT
unit-test:
runs-on: ubuntu-latest
needs: cache-dependencies
timeout-minutes: 20
permissions:
contents: read
packages: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK
uses: ./.github/actions/setup-jdk
- name: Run unit tests
run: mvn -B test
integration-test:
runs-on: ubuntu-latest
needs: cache-dependencies
timeout-minutes: 30
permissions:
contents: read
packages: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK
uses: ./.github/actions/setup-jdk
- name: Run integration tests
run: mvn -B install -Dtest=skip
maven-deploy:
runs-on: ubuntu-latest
needs: [ unit-test, integration-test, cache-dependencies ]
if: |
(github.event_name == 'release' && github.event.action == 'created') ||
(github.event_name == 'push' && github.ref_name == 'main')
timeout-minutes: 20
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK
uses: ./.github/actions/setup-jdk
- name: Import GPG Key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
echo "default-key $(gpg --list-keys --with-colons | grep pub | cut -d':' -f5)" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
- name: Setup Maven settings
uses: ./.github/actions/setup-maven-settings
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-actor: ${{ github.actor }}
additional-servers: ${{ secrets.MAVEN_SETTINGS_SERVER_CENTRAL }}
- name: Update version
if: github.event_name == 'release' && github.event.action == 'created'
run: |
mvn -B versions:set -DnewVersion=${{ needs.cache-dependencies.outputs.project-version }}
- name: Deploy to Maven Central
if: github.event_name == 'release'
run: mvn -B clean deploy -Pci,release -DskipTests
- name: Deploy to GitHub Packages
if: github.ref_name == 'main'
run: mvn -B clean deploy -Pci -DskipTests
build-and-push-docker-image:
runs-on: ubuntu-latest
needs: [ unit-test, integration-test, cache-dependencies ]
timeout-minutes: 30
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK
uses: ./.github/actions/setup-jdk
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Maven settings
uses: ./.github/actions/setup-maven-settings
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-actor: ${{ github.actor }}
- name: Pull base Docker image
run: |
mvn -B -f flink-sql-runner/pom.xml org.apache.maven.plugins:maven-resources-plugin:3.3.1:resources
grep '^FROM' flink-sql-runner/target/Dockerfile | awk '{print $2}' | xargs -n1 docker pull
- name: Update version
if: github.event_name == 'release' && github.event.action == 'created'
run: |
mvn -B versions:set -DnewVersion=${{ needs.cache-dependencies.outputs.project-version }}
- name: Build uber jar
run: mvn -B clean install -DskipTests
- name: Define Docker image tag
id: vars
run: |
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "created" ]]; then
echo "image_tag=datasqrl/flink-sql-runner:${{ needs.cache-dependencies.outputs.project-version }}-${{ needs.cache-dependencies.outputs.flink-version-label }}" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "push" ]]; then
echo "image_tag=ghcr.io/datasqrl/flink-sql-runner:${{ needs.cache-dependencies.outputs.project-version }}" >> $GITHUB_OUTPUT
else
echo "image_tag=ghcr.io/datasqrl/flink-sql-runner:pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
fi
- name: Log in to container registry
uses: docker/login-action@v3
with:
registry: ${{ (github.event_name == 'release' && github.event.action == 'created') && 'docker.io' || 'ghcr.io' }}
username: ${{ (github.event_name == 'release' && github.event.action == 'created') && secrets.DOCKER_USERNAME || github.actor }}
password: ${{ (github.event_name == 'release' && github.event.action == 'created') && secrets.DOCKER_PASSWORD || secrets.GITHUB_TOKEN }}
- name: Build and push Docker image (linux/amd64 + linux/arm64)
uses: docker/build-push-action@v5
with:
context: ./flink-sql-runner/target
file: ./flink-sql-runner/target/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.vars.outputs.image_tag }}
- name: Rename jar file
if: github.event_name == 'release' && github.event.action == 'created'
run: |
mv flink-sql-runner/target/flink-sql-runner.uber.jar flink-sql-runner/target/flink-sql-runner-${{ needs.cache-dependencies.outputs.project-version }}-${{ needs.cache-dependencies.outputs.flink-version-label }}.jar
- name: Upload to GitHub Release
if: github.event_name == 'release' && github.event.action == 'created'
uses: softprops/action-gh-release@v1
with:
files: flink-sql-runner/target/flink-sql-runner-${{ needs.cache-dependencies.outputs.project-version }}-${{ needs.cache-dependencies.outputs.flink-version-label }}.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [ unit-test, integration-test ]
if: always()
steps:
- name: Check test results
run: |
echo "Checking results of upstream jobs..."
FAILED_JOBS=""
NEEDS_JSON='${{ toJSON(needs) }}'
for job in $(echo "$NEEDS_JSON" | jq -r 'keys[]'); do
result=$(echo "$NEEDS_JSON" | jq -r ".[\"$job\"].result")
echo " $job: $result"
if [[ "$result" != "success" ]]; then
FAILED_JOBS="$FAILED_JOBS $job"
fi
done
if [[ -n "$FAILED_JOBS" ]]; then
echo "One or more jobs did not succeed:$FAILED_JOBS"
exit 1
fi