forked from hibernate/hibernate-reactive
-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (265 loc) · 10.4 KB
/
build.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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Hibernate Reactive CI
on:
push:
branches:
- main
tags:
- '2.*'
pull_request:
branches: main
# See https://github.com/hibernate/hibernate-orm/pull/4615 for a description of the behavior we're getting.
concurrency:
# Consider that two builds are in the same concurrency group (cannot run concurrently)
# if they use the same workflow and are about the same branch ("ref") or pull request.
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
# Cancel previous builds in the same concurrency group even if they are in process
# for pull requests or pushes to forks (not the upstream repository).
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-reactive' }}
jobs:
run_examples:
name: Run examples in '${{ matrix.example }}' on ${{ matrix.db }}
runs-on: ubuntu-latest
strategy:
matrix:
example: [ 'session-example', 'native-sql-example' ]
db: [ 'MySQL', 'PostgreSQL' ]
exclude:
# 'native-sql-example' doesn't run on MySQL because it has native queries
- example: 'native-sql-example'
db: 'MySQL'
services:
# Label used to access the service container
mysql:
# Docker Hub image
image: mysql:8.0.32
env:
MYSQL_ROOT_PASSWORD: hreact
MYSQL_DATABASE: hreact
MYSQL_USER: hreact
MYSQL_PASSWORD: hreact
# Set health checks to wait until postgres has started
options: >-
--health-cmd="mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
postgres:
# Docker Hub image
image: postgres:15.2
env:
POSTGRES_DB: hreact
POSTGRES_USER: hreact
POSTGRES_PASSWORD: hreact
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Get year/month for cache key
id: get-date
run: |
echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")"
shell: bash
- name: Cache Gradle downloads
uses: actions/cache@v2
id: cache-gradle
with:
path: |
.gradle/caches
.gradle/jdks
.gradle/wrapper
# refresh cache every month to avoid unlimited growth
key: gradle-examples-${{ matrix.db }}-${{ steps.get-date.outputs.yearmonth }}
- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11
- name: Run examples in '${{ matrix.example }}' on ${{ matrix.db }}
run: ./gradlew :${{ matrix.example }}:runAllExamplesOn${{ matrix.db }}
- name: Upload reports (if build failed)
uses: actions/upload-artifact@v2
if: failure()
with:
name: reports-examples-${{ matrix.db }}
path: './**/build/reports/'
test_dbs:
name: Test with ${{ matrix.db }}
runs-on: ubuntu-latest
strategy:
matrix:
# db: [ 'MariaDB', 'MySQL', 'PostgreSQL', 'DB2', 'CockroachDB', 'MSSQLServer', 'Oracle' ]
db: [ 'MariaDB', 'MySQL', 'PostgreSQL', 'MSSQLServer', 'CockroachDB', 'Db2', 'Oracle' ]
steps:
- uses: actions/checkout@v2
- name: Get year/month for cache key
id: get-date
run: |
echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")"
shell: bash
- name: Cache Gradle downloads
uses: actions/cache@v2
id: cache-gradle
with:
path: |
.gradle/caches
.gradle/jdks
.gradle/wrapper
# refresh cache every month to avoid unlimited growth
key: gradle-db-${{ matrix.db }}-${{ steps.get-date.outputs.yearmonth }}
- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11
- name: Build and Test with ${{ matrix.db }}
run: ./gradlew build -PshowStandardOutput -Pdocker -Pdb=${{ matrix.db }}
- name: Upload reports (if build failed)
uses: actions/upload-artifact@v2
if: failure()
with:
name: reports-db-${{ matrix.db }}
path: './**/build/reports/'
test_jdks:
name: Test with Java ${{ matrix.java.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# To list the available "feature versions" on adoptium.net (ignore "tip_version", it's not relevant):
# https://api.adoptium.net/v3/info/available_releases
# To list the available releases for a given "feature version" on adoptium.net (example for 16):
# https://api.adoptium.net/v3/assets/latest/16/hotspot
# To see the available versions and download links on jdk.java.net:
# https://github.com/oracle-actions/setup-java/blob/main/jdk.java.net-uri.properties
java:
- { name: "11", java_version_numeric: 11 }
- { name: "17", java_version_numeric: 17 }
# We want to enable preview features when testing newer builds of OpenJDK:
# even if we don't use these features, just enabling them can cause side effects
# and it's useful to test that.
- { name: "20", java_version_numeric: 20, jvm_args: '--enable-preview' }
- { name: "21", java_version_numeric: 21, from: 'jdk.java.net', jvm_args: '--enable-preview' }
- { name: "22-ea", java_version_numeric: 22, from: 'jdk.java.net', jvm_args: '--enable-preview' }
- { name: "23-ea", java_version_numeric: 23, from: 'jdk.java.net', jvm_args: '--enable-preview' }
steps:
- uses: actions/checkout@v2
- name: Get year/month for cache key
id: get-date
run: |
echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")"
shell: bash
- name: Cache Gradle downloads
uses: actions/cache@v2
id: cache-gradle
with:
path: |
.gradle/caches
.gradle/jdks
.gradle/wrapper
# refresh cache every month to avoid unlimited growth
key: gradle-java${{ matrix.java }}-${{ steps.get-date.outputs.yearmonth }}
- name: Set up latest JDK ${{ matrix.java.name }} from jdk.java.net
if: matrix.java.from == 'jdk.java.net'
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ${{ matrix.java.java_version_numeric }}
- name: Set up latest JDK ${{ matrix.java.name }} from Adoptium
if: matrix.java.from == '' || matrix.java.from == 'adoptium.net'
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: ${{ matrix.java.java_version_numeric }}
check-latest: true
- name: Export path to JDK ${{ matrix.java.name }}
id: testjdk-exportpath
run: echo "::set-output name=path::${JAVA_HOME}"
# Always use JDK 11 to build the main code: that's what we use for releases.
- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11
check-latest: true
- name: Export path to JDK 11
id: mainjdk-exportpath
run: echo "::set-output name=path::${JAVA_HOME}"
- name: Display exact version of JDK ${{ matrix.java.name }}
run: |
${{ steps.testjdk-exportpath.outputs.path }}/bin/java -version
- name: Build and Test with Java ${{ matrix.java.name }}
run: |
./gradlew build -PshowStandardOutput -Pdocker -Ptest.jdk.version=${{ matrix.java.java_version_numeric }} \
-Porg.gradle.java.installations.paths=${{ steps.mainjdk-exportpath.outputs.path }},${{ steps.testjdk-exportpath.outputs.path }} \
${{ matrix.java.jvm_args && '-Ptest.jdk.launcher.args=' }}${{ matrix.java.jvm_args }}
- name: Upload reports (if build failed)
uses: actions/upload-artifact@v2
if: failure()
with:
name: reports-java${{ matrix.java.name }}
path: './**/build/reports/'
snapshot:
name: Create snapshot
if: github.event_name == 'push' && startsWith( github.ref, 'refs/heads/' )
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11
- name: Create artifacts
run: ./gradlew assemble
- name: Detect the version of Hibernate Reactive
id: detect-version
run: |
sed -E 's/^projectVersion( *= *| +)([^ ]+)/::set-output name=version::\2/g' gradle/version.properties
- name: Publish snapshot to JBoss Nexus
env:
ORG_GRADLE_PROJECT_jbossNexusUser: ${{ secrets.JBOSS_NEXUS_USER }}
ORG_GRADLE_PROJECT_jbossNexusPassword: ${{ secrets.JBOSS_NEXUS_PASSWORD }}
if: endsWith( steps.detect-version.outputs.version, '-SNAPSHOT' ) && env.ORG_GRADLE_PROJECT_jbossNexusUser
run: ./gradlew publishToJBossNexus closeAndReleaseJBossNexusStagingRepository
release:
name: Release
if: github.event_name == 'push' && startsWith( github.ref, 'refs/tags/' )
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set git username and email
run: |
git config --global user.email "[email protected]"
git config --global user.name "hibernate"
- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11
- name: Create artifacts
run: ./gradlew assemble
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.HIBERNATE_ORG_SSH_KEY }}
name: id_rsa_hibernate.org
known_hosts: ${{ secrets.HIBERNATE_ORG_SSH_KNOWN_HOSTS }}
config: |
Host github.com
User hibernate
IdentityFile ~/.ssh/id_rsa_hibernate.org
- name: Publish documentation on Hibernate.org
run: ./gradlew publishDocumentation -PdocPublishBranch=production
- name: Publish artifacts to OSSRH, close repository and release
env:
ORG_GRADLE_PROJECT_sonatypeOssrhUser: ${{ secrets.SONATYPE_OSSRH_USER }}
ORG_GRADLE_PROJECT_sonatypeOssrhPassword: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository