-
Notifications
You must be signed in to change notification settings - Fork 1
249 lines (211 loc) · 6.41 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
name: Build
on:
push:
tags: [ "v*.*.*" ]
branches: [ "main", "incubate" ]
pull_request:
branches: [ "main", "incubate" ]
env:
MAVEN_ARGS: -B -T1C -Dmockserver.logLevel=WARN
jobs:
analyze:
env:
GITHUB_TOKEN: ${{ github.token }}
permissions:
security-events: write
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java
queries: security-and-quality
- name: Build
run: make build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
build-jar:
env:
GITHUB_TOKEN: ${{ github.token }}
runs-on: ubuntu-24.04
strategy:
matrix:
agent:
- clinical-domain-agent
- trust-center-agent
- research-domain-agent
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: 'maven'
- name: Build Dependencies
run: make install-dependencies
- name: Unit Tests
run: mvn ${MAVEN_ARGS} test --projects ${{ matrix.agent }}
- name: Integration Tests
run: mvn ${MAVEN_ARGS} verify --projects ${{ matrix.agent }} -DskipUnitTests
- name: Build Agent
run: mvn ${MAVEN_ARGS} install --projects ${{ matrix.agent }} -DskipTests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Upload Jar
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.agent }}
path: ${{ matrix.agent }}/target/${{ matrix.agent }}.jar
if-no-files-found: error
build-image:
needs: [ build-jar ]
runs-on: ubuntu-24.04
strategy:
matrix:
agent:
- clinical-domain-agent
- trust-center-agent
- research-domain-agent
steps:
- uses: actions/checkout@v4
- name: Download Agent Jar
if: ${{ matrix.agent }}
uses: actions/download-artifact@v4
with:
name: ${{ matrix.agent }}
path: ${{ matrix.agent }}/target
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Save Container Image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.agent }}
tags: ${{ matrix.agent }}:latest
outputs: type=docker,dest=/tmp/${{ matrix.agent }}.tar
- name: Upload Container Image
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.agent }}-image
path: /tmp/${{ matrix.agent }}.tar
if-no-files-found: error
scan-image:
needs: [ build-image ]
runs-on: ubuntu-24.04
strategy:
matrix:
agent:
- clinical-domain-agent
- trust-center-agent
- research-domain-agent
steps:
- name: Download Container Image
uses: actions/download-artifact@v4
with:
name: ${{ matrix.agent }}-image
path: /tmp
- name: Load Container Image
run: docker load --input /tmp/${{ matrix.agent }}.tar
- name: Run Trivy Vulnerability Scanner
uses: aquasecurity/[email protected]
with:
image-ref: ${{ matrix.agent }}:latest
format: sarif
output: trivy-results.sarif
severity: 'CRITICAL,HIGH'
timeout: '15m0s'
- name: Upload Trivy Scan Results to GitHub Security Tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif
e2e-tests:
needs: [ build-image ]
runs-on: ubuntu-24.04
steps:
- name: Download Container Image
uses: actions/download-artifact@v4
with:
pattern: '*-image'
merge-multiple: true
path: /tmp
- name: Login to SMITH Container Registry
uses: docker/login-action@v3
with:
registry: creg.smith.care
username: ${{ secrets.smith_creg_username }}
password: ${{ secrets.smith_creg_password }}
- name: Load Container Image
run: |
echo "clinical-domain-agent trust-center-agent research-domain-agent"
| xargs -n1 docker load --input /tmp/
- name: Start Test Environment
run: docker compose -f .github/test/docker-compose.yaml up -d
- name: Upload Test Data
run: |
.github/scripts/upload-consent.sh patient-1
.github/scripts/upload-patient.sh patient-1
- name: Upload Test Data
run: .github/scripts/start-transfer.sh example
push-image:
if: github.event_name != 'pull_request' || (github.event.pull_request.base.repo.full_name == github.event.pull_request.head.repo.full_name)
needs:
- scan-image
- e2e-tests
runs-on: ubuntu-24.04
permissions:
packages: write
strategy:
matrix:
agent:
- clinical-domain-agent
- trust-center-agent
- research-domain-agent
steps:
- uses: actions/checkout@v4
- name: Download Agent Jar
if: ${{ matrix.agent }}
uses: actions/download-artifact@v4
with:
pattern: ${{ matrix.agent }}*
merge-multiple: true
path: ${{ matrix.agent }}/target
- name: Load Container Image
run: docker load --input /tmp/${{ matrix.agent }}.tar
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Container Image Metadata
id: ghcr-meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/fts-${{ matrix.agent }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and Push Container Image
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6
with:
context: ${{ matrix.agent }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.ghcr-meta.outputs.tags }}
labels: ${{ steps.ghcr-meta.outputs.labels }}