-
Notifications
You must be signed in to change notification settings - Fork 24
198 lines (192 loc) · 7.47 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
name: build
on:
push:
branches:
- main
paths-ignore:
- '.all-contributorsrc'
- '.github/workflows/publish_docs.yml'
- 'README.adoc'
- 'CHANGELOG.md'
- 'bin/generate-site.sh'
- 'docs/antora.yml'
- 'etc/index.tpl'
pull_request:
paths-ignore:
- '.all-contributorsrc'
- '.github/workflows/publish_docs.yml'
- 'README.adoc'
- 'CHANGELOG.md'
- 'bin/generate-site.sh'
- 'docs/antora.yml'
- 'etc/index.tpl'
jobs:
build:
runs-on: ubuntu-latest
env:
TC_CLOUD_TOKEN: ${{ secrets.TC_CLOUD_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Ensure read permissions
run: chmod 640 neo4j-migrations-examples/neo4j-migrations-cluster-tests/src/test/resources/cc/neo4j.conf
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
- name: Prepare TC env
run: echo "testcontainers.reuse.enable=true" > ~/.testcontainers.properties
- name: Enable Sonar for local PRs not from Dependabot
if: ${{ github.event.sender.login != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
run: echo "USE_SONAR=sonar" >> $GITHUB_ENV
- name: Disable Sonar for foreign PRs or from Dependabot
if: ${{ github.event.sender.login == 'dependabot[bot]' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
run: echo "USE_SONAR=-sonar" >> $GITHUB_ENV
- name: Prepare testcontainers.cloud agent
if: env.TC_CLOUD_TOKEN != ''
run: |
curl -L -o agent https://app.testcontainers.cloud/download/testcontainers-cloud-agent_linux_x86-64
chmod +x agent
./agent &
./agent wait
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}-${{ github.sha }}
- name: Download dependencies upfront
run: ./mvnw -Dfast --no-transfer-progress clean package dependency:go-offline
- name: Clean and verify
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./mvnw -Dmigrations.test-only-latest-neo4j=true --no-transfer-progress clean install -P$USE_SONAR
- name: Upload assembly
uses: actions/upload-artifact@v4
with:
name: assembly
path: neo4j-migrations-cli/target/assembly
ensure_windows_files:
if: ${{ github.event.sender.login != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
name: Ensure file locations working on windows
runs-on: windows-latest
needs: build
steps:
- name: 'Prepare git'
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
- name: 'Restore Maven packages'
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-m2
- name: 'Ensure Maven-Plugin can deal with windows paths'
run: ./mvnw -DskipCoreTests --no-transfer-progress test -pl neo4j-migrations-maven-plugin -am
- name: 'Set up JBang'
run: choco install jbang
- name: 'Start Neo4j in Background'
env:
EXTERNAL_TEST_DB_URL: ${{ secrets.EXTERNAL_TEST_DB_URL }}
if: "${{ env.EXTERNAL_TEST_DB_URL == 'bolt://localhost:7687' }}"
run: cmd /c "START /b jbang bin/start_neo4j.java"
- name: Download assembly
uses: actions/download-artifact@v4
with:
name: assembly
path: assembly
- name: 'Check availability'
id: check-availability
env:
EXTERNAL_TEST_DB_URL: ${{ secrets.EXTERNAL_TEST_DB_URL }}
EXTERNAL_TEST_DB_PWD: ${{ secrets.EXTERNAL_TEST_DB_PWD }}
run: jbang bin/check_availability.java EXTERNAL_TEST_DB_URL EXTERNAL_TEST_DB_PWD 20
continue-on-error: true
- name: 'External DB not available'
if: steps.check-availability.outcome == 'failure'
run: echo "External DB not available, skipping Windows tests."
- name: 'Ensure CLI can deal with windows paths'
if: steps.check-availability.outcome == 'success'
env:
EXTERNAL_TEST_DB_URL: ${{ secrets.EXTERNAL_TEST_DB_URL }}
EXTERNAL_TEST_DB_PWD: ${{ secrets.EXTERNAL_TEST_DB_PWD }}
run: assembly/bin/neo4j-migrations.bat -a %EXTERNAL_TEST_DB_URL% --password:env EXTERNAL_TEST_DB_PWD --location file:///$pwd/neo4j-migrations-test-resources/src/main/resources/some/changeset info
ensure_jdk_compat:
name: Ensure compatibility with minimum required Java version
runs-on: ubuntu-latest
services:
neo4j:
image: neo4j:4.4
env:
NEO4J_AUTH: neo4j/secret
options: --health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/tcp/127.0.0.1/7687'" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 7687:7687
needs: build
steps:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
- name: Download assembly
uses: actions/download-artifact@v4
with:
name: assembly
path: assembly
- name: Make executable again
run: chmod +x assembly/bin/neo4j-migrations
- name: Print info
run: assembly/bin/neo4j-migrations -a bolt://localhost:7687 -p secret info
test_cli_native:
name: Test CLI native binary
runs-on: ubuntu-latest
needs: ensure_jdk_compat
steps:
- uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm-community'
java-version: 23
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Restore Maven cache
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-m2
- name: Clean and build
run: ./mvnw --no-transfer-progress -Dnative -DskipTests -pl eu.michael-simons.neo4j:neo4j-migrations-cli clean package
- name: Run binary
uses: jbangdev/[email protected]
with:
script: bin/test_native_cli.java
test_quarkus_native:
name: Test Quarkus extension in native image
runs-on: ubuntu-latest
needs: ensure_jdk_compat
steps:
- uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm-community'
java-version: 21
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Restore Maven cache
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-m2
- name: Clean and verify
run: ./mvnw --no-transfer-progress -Dnative -pl :neo4j-migrations-quarkus-integration-tests clean verify