-
Notifications
You must be signed in to change notification settings - Fork 23
314 lines (284 loc) · 10.3 KB
/
ci.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: CI
on:
workflow_dispatch:
push:
branches: [ main ]
release:
types: [ published ]
pull_request:
branches: [ main ]
env:
REGISTRY_URL: ghcr.io
REGISTRY_USER: ${{ github.actor }}
IMAGE_BASE_NAME: ${{ github.repository_owner }}
jobs:
build-connector-image-ce:
name: Build CE Connector Image
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Set up JDK 17"
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: "Gradle: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v3
- name: "Gradle: Test & Build"
uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c
with:
build-root-directory: connector
arguments: build -x test ${{ env.GRADLE_ARGS }}
env:
USERNAME: ${{ env.REGISTRY_USER }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Docker Image: edc-ce"
uses: ./.github/actions/build-connector-image
with:
registry-url: ${{ env.REGISTRY_URL }}
registry-user: ${{ env.REGISTRY_USER }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
image-base-name: ${{ env.IMAGE_BASE_NAME }}
image-name: "edc-ce"
image-title: "sovity Community Edition EDC Connector"
image-description: "Eclipse EDC Connector built by sovity. This image supports multiple data spaces and contains multiple kinds of deployments: Standalone Control Plane, Standalone Dataplane, Combined Control and Dataplane"
connector-dir: "connector/ce/docker-image-ce"
build-connector-ui-image-ce:
name: Build CE Connector UI Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Set up JDK 17"
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: "Gradle: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v3
- name: "Set up Node 20"
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
cache-dependency-path: 'connector-ui/package-lock.json'
- name: "Install Dependencies"
working-directory: connector-ui
run: |
npm ci
- name: "Build Angular Project"
working-directory: connector-ui
run: |
npm run build-prod
env:
USERNAME: ${{ env.REGISTRY_USER }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Store the build date and version
id: build_info
run: |
echo "EDC_UI_BUILD_VERSION_ARG=$(git describe --tags ${CI_PR_SHA})" >> "$GITHUB_OUTPUT"
echo "EDC_UI_BUILD_DATE_ARG=$(date --utc +%FT%TZ)" >> "$GITHUB_OUTPUT"
- name: Log in to the Container registry (push-only)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ env.REGISTRY_USER }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_URL }}/${{ env.IMAGE_BASE_NAME }}/edc-ce-ui
labels: |
org.opencontainers.image.title=sovity EDC CE UI
org.opencontainers.image.description=UI for the sovity EDC CE Connector
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=release,enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build EDC-UI image
uses: docker/build-push-action@v4
with:
file: connector-ui/docker/Dockerfile
context: connector-ui
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"EDC_UI_BUILD_VERSION_ARG=${{ steps.build_info.outputs.EDC_UI_BUILD_VERSION_ARG }}"
"EDC_UI_BUILD_DATE_ARG=${{ steps.build_info.outputs.EDC_UI_BUILD_DATE_ARG }}"
run-connector-tests-ce:
name: Run CE Gradle Tests
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: "Set up JDK 17"
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: "Gradle: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v3
- name: "Gradle: Test"
uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c
with:
build-root-directory: connector
arguments: test -x :ce:docker-image-ce:assemble
env:
USERNAME: ${{ env.REGISTRY_USER }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run-ui-karma-tests:
name: Run UI Karma Tests
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Set up JDK 17"
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: "Gradle: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v3
- name: "Set up Node 20"
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
cache-dependency-path: 'connector-ui/package-lock.json'
- name: "Install Dependencies"
working-directory: connector-ui
run: |
npm ci
- name: "Run Karma Tests"
working-directory: connector-ui
run: |
npm run test-ci
env:
USERNAME: ${{ env.REGISTRY_USER }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-client-library-typescript:
name: TS API Client Library
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- uses: actions/checkout@v3
- name: "Set up JDK 17"
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: "Set up Node 16"
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: connector/ce/libs/api-clients/typescript-client/package.json
- name: "Gradle: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
- name: "Gradle: Generate TS Code"
uses: gradle/gradle-build-action@v2.10.0
with:
build-root-directory: connector
arguments: :ce:libs:api-clients:typescript-client:build -x test
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "NPM: Dist Tag & Version"
working-directory: ./connector/ce/libs/api-clients/typescript-client
run: |
if [[ "$GITHUB_REF" == "refs/tags/v"* ]]; then
# Full Release
VERSION="${GITHUB_REF#refs/tags/v}"
DIST_TAG=latest
else
VERSION="0.$(date '+%Y%m%d.%H%M%S')-main-$CI_SHA_SHORT"
DIST_TAG=main
fi
npm version $VERSION
echo "DIST_TAG=$DIST_TAG" >> $GITHUB_ENV
- name: "NPM: Build"
working-directory: connector/ce/libs/api-clients/typescript-client
run: npm ci && npm run build
- name: "NPM: Publish (Main & Releases Only)"
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
working-directory: connector/ce/libs/api-clients/typescript-client
run: |
npm set //registry.npmjs.org/:_authToken $NODE_AUTH_TOKEN
npm set //registry.npmjs.org/:username $NODE_USER
npm publish --access public --tag "${{ env.DIST_TAG }}"
env:
NODE_USER: richardtreier-sovity
NODE_AUTH_TOKEN: ${{ secrets.SOVITY_EDC_CLIENT_NPM_AUTH }}
check-migration-script-names:
name: "Check Migration Script Names"
env:
MIGRATIONS_DIR_CE: connector/ce/utils/db-schema-ce/src/main/resources/db/migration-ce
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate CE Migration Scripts
run: |
function check_migrations_dir () {
MIGRATIONS_DIR=$1
PATTERN=$2
FILES=$(ls -A "$MIGRATIONS_DIR")
if [[ ! (-d "$1" && -n $FILES) ]]; then
echo "Error: Directory either doesn't exist or is empty" >&2
exit 1
fi
echo "Checking $MIGRATIONS_DIR"
for filename in $FILES ; do
if [[ ! "$filename" =~ $PATTERN ]]; then
echo "Error: Invalid migration script name: ${filename##*/}"
echo "Expected format: $PATTERN"
exit 1
fi
echo "✓ ${filename}"
done
echo "✓ All migration scripts follow $PATTERN"
}
MIGRATION_DIR_CE='connector/ce/utils/db-schema-ce/src/main/resources/db/migration-ce'
PATTERN_CE='^V([0-9]+\.[0-9]+\.[0-9]+)__Release_\1_CE\.sql$'
if [[ ! "${{ github.ref }}" =~ '^refs/tags/v' ]] && [[ ! "${{ github.event.pull_request.head.ref }}" == "next" ]]; then
PATTERN_CE+='|^V99__Unreleased_CE.sql$'
fi
echo "Checking CE Migrations"
check_migrations_dir "$MIGRATION_DIR_CE" "$PATTERN_CE"
ci_status:
if: always()
name: CI Status
needs:
- build-connector-image-ce
- build-connector-ui-image-ce
- run-connector-tests-ce
- run-ui-karma-tests
- build-client-library-typescript
- check-migration-script-names
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}