forked from pgjdbc/pgjdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
271 lines (257 loc) · 10.2 KB
/
main.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
name: CI
on:
push:
branches:
- '*'
paths-ignore:
- 'docs/**'
- '**/*.md'
- 'appveyor.xml'
- '.travis.yml'
- '.travis/**'
pull_request:
branches:
- '**'
paths-ignore:
- 'docs/**'
- '**/*.md'
- 'appveyor.xml'
- '.travis.yml'
- '.travis/**'
permissions:
contents: read
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
# GitHub Actions does not support Docker, PostgreSQL server on Windows, macOS :(
concurrency:
# On master/release, we don't want any jobs cancelled so the sha is used to name the group
# On PR branches, we cancel the job if new commits are pushed
# More info: https://stackoverflow.com/a/68422069/253468
group: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release' ) && format('ci-main-{0}', github.sha) || format('ci-main-{0}', github.ref) }}
cancel-in-progress: true
jobs:
code-style:
name: 'Code style'
runs-on: ubuntu-latest
env:
ACTIONS_STEP_DEBUG: true
ACTIONS_RUNNER_DEBUG: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: 'Set up JDK 8'
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
- uses: burrunan/gradle-cache-action@v1
name: Verify code style
env:
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
with:
job-id: jdk17
arguments: styleCheck jandex
linux-checkerframework:
name: 'CheckerFramework'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
- uses: burrunan/gradle-cache-action@v1
name: Run CheckerFramework
env:
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
with:
read-only: ${{ matrix.os == 'self-hosted' }}
job-id: checker-jdk17
arguments: --scan --no-parallel --no-daemon -PenableCheckerframework classes
source-distribution-check:
name: 'Source distribution (JDK 17)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: Start PostgreSQL
working-directory: docker/postgres-server
run: docker-compose up -d && docker-compose logs
- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
- uses: burrunan/gradle-cache-action@v1
name: Prepare source distribution
env:
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
with:
job-id: source-release-jdk17
arguments: --scan --no-parallel --no-daemon sourceDistribution -Ppgjdbc.version=1.0 -Prelease
- name: Verify source distribution
working-directory: pgjdbc/build/distributions
run: |
tar xzf postgresql-1.0-jdbc-src.tar.gz
cd postgresql-1.0-jdbc-src
mvn --batch-mode --fail-at-end --show-version verify
- name: Attach heap dump if any
if: ${{ failure() && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: pgjdbc-heapdump-source-distribution
path: pgjdbc/build/distributions/postgresql-1.0-jdbc-src/target/surefire-reports/*.hprof
matrix_prep:
name: Matrix Preparation
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
env:
MATRIX_JOBS: 5
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- id: set-matrix
run: |
node .github/workflows/matrix.js
build-test:
name: '${{ matrix.name }}'
runs-on: ${{ matrix.os }}
needs: matrix_prep
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
env:
ACTIONS_STEP_DEBUG: true
ACTIONS_RUNNER_DEBUG: true
TZ: ${{ matrix.tz }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: Start PostgreSQL PGV=${{ matrix.pg_version }} TZ=${{ matrix.server_tz }} XA=${{ matrix.xa }} SSL=${{ matrix.ssl }} SCRAM=${{ matrix.scram }} CREATE_REPLICAS=${{ matrix.replication }}
working-directory: docker/postgres-server
env:
PGV: ${{ matrix.pg_version }}
TZ: ${{ matrix.server_tz }}
XA: ${{ matrix.xa }}
SSL: ${{ matrix.ssl }}
SCRAM: ${{ matrix.scram }}
CREATE_REPLICAS: ${{ matrix.replication }}
# The below run command is long, however, it is intentional, and it makes the output nicer in GitHub UI
run: |
echo 'Starting PostgreSQL via docker-compose down; PGV=${{ matrix.pg_version }} TZ=${{ matrix.server_tz }} XA=${{ matrix.xa }} SSL=${{ matrix.ssl }} SCRAM=${{ matrix.scram }} CREATE_REPLICAS=${{ matrix.replication }} docker-compose up'
docker-compose down -v --rmi local || true
sed -i -r '/- (543[3-4]):\1/d' docker-compose.yml
docker-compose up -d
docker-compose logs
- name: Set up Java 17 and ${{ matrix.non_ea_java_version }}, ${{ matrix.java_distribution }}, ${{ runner.arch }}
uses: actions/setup-java@v3
with:
# The latest one will be the default, so we use Java 17 for launching Gradle
# oracle-actions/setup-java below requires Java 17, so we must install Java 17 before calling oracle-actions/setup-java
java-version: |
${{ matrix.non_ea_java_version }}
17
distribution: ${{ matrix.java_distribution }}
# Architecture is explicit to workaround https://github.com/actions/setup-java/issues/559
architecture: ${{ runner.arch == 'ARM64' && 'aarch64' || 'x64' }}
- name: Set up Java ${{ matrix.java_version }}, oracle
id: setup_ea_java
if: ${{ matrix.oracle_java_website != '' }}
uses: oracle-actions/setup-java@7a0114d66dbd02646abd345c3395b34c148e6126 # v1.3.2
env:
JAVA_HOME_17_X64: ${{ env.JAVA_HOME_17_AARCH64 || env.JAVA_HOME_17_X64 }}
with:
website: ${{ matrix.oracle_java_website }}
release: ${{ matrix.java_version }}
- name: Set up Java 17 ${{ matrix.java_distribution }} as default
# oracle-actions/setup-java above installs EA java by default, so we need to reinstall Java 17 as the default
if: ${{ matrix.oracle_java_website != '' }}
uses: actions/setup-java@v3
with:
java-version: 17
distribution: ${{ matrix.java_distribution }}
# Architecture is explicit to workaround https://github.com/actions/setup-java/issues/559
architecture: ${{ runner.arch == 'ARM64' && 'aarch64' || 'x64' }}
- name: Prepare local properties
run: |
# See https://github.com/actions/runner/issues/409
cat <<EOF >ssltest.local.properties
enable_ssl_tests=${{ matrix.ssl == 'yes' && 'true' || 'false' }}
EOF
cat <<EOF >build.local.properties
preferQueryMode=${{ matrix.query_mode }}
EOF
- uses: burrunan/gradle-cache-action@v1
name: Test
env:
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
_JAVA_OPTIONS: ${{ matrix.extraJvmArgs }}
with:
read-only: ${{ matrix.os == 'self-hosted' }}
job-id: jdk${{ matrix.java_version }}
arguments: --scan --no-parallel --no-daemon jandex test ${{ matrix.extraGradleArgs }}
properties: |
includeTestTags=${{ matrix.includeTestTags }}
testExtraJvmArgs=${{ matrix.testExtraJvmArgs }}
jdkBuildVersion=17
jdkTestVersion=${{ matrix.java_version == 'EA' && steps.setup_ea_java.outputs.version || matrix.java_version }}
jdkTestVendor=${{ matrix.java_vendor }}
# We provision JDKs with GitHub Actions for caching purposes, so Gradle should rather fail in case JDK is not found
org.gradle.java.installations.auto-download=false
- name: 'Install krb5 for GSS tests'
if: ${{ matrix.gss == 'yes' }}
run: |
sudo apt -y update
sudo apt -y install krb5-kdc krb5-admin-server libkrb5-dev postgresql
- name: 'Update hosts for GSS tests'
if: ${{ matrix.gss == 'yes' }}
run: |
sudo -- sh -c "echo 127.0.0.1 localhost auth-test-localhost.postgresql.example.com > /etc/hosts"
cat /etc/hosts
- uses: burrunan/gradle-cache-action@v1
if: ${{ matrix.deploy_to_maven_local }}
name: Deploy pgjdbc to mavenLocal
with:
read-only: ${{ matrix.os == 'self-hosted' }}
job-id: jdk${{ matrix.java_version }}
arguments: publishToMavenLocal -Ppgjdbc.version=1.0.0-dev-master -PskipJavadoc
- name: Attach heap dump if any
if: ${{ failure() && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: pgjdbc-heapdump
path: pgjdbc/*.hprof
- name: Test GSS
if: ${{ matrix.gss == 'yes' }}
run: |
cd test-gss
./gradlew assemble
./gradlew run
env:
KRB5CCNAME: /home/runner/work/pgjdbc/pgjdbc/test-gss/tmp_check/krb5cc
KRB5_CONFIG: /home/runner/work/pgjdbc/pgjdbc/test-gss/tmp_check/krb5.conf
KRB5_KDC_PROFILE: /home/runner/work/pgjdbc/pgjdbc/test-gss/tmp_check/kdc.conf
- name: Test anorm-sbt
if: ${{ matrix.check_anorm_sbt == 'yes' }}
run: |
# mkdir -p $HOME/.sbt/launchers/0.13.12
# curl -L -o $HOME/.sbt/launchers/0.13.12/sbt-launch.jar http://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.12/sbt-launch.jar
cd test-anorm-sbt
sbt test
- name: Cleanup Docker
if: ${{ always() }}
working-directory: docker/postgres-server
run: |
docker-compose ps
docker-compose down -v --rmi local