-
Notifications
You must be signed in to change notification settings - Fork 3
205 lines (176 loc) · 6.55 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
name: LAPIS-SILO
on:
push:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_DEPENDENCY_IMAGE_NAME: ghcr.io/genspectrum/lapis-silo-dependencies
DOCKER_IMAGE_NAME: ghcr.io/genspectrum/lapis-silo
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
strategy:
matrix:
path:
- check: 'src'
- check: 'include'
exclude: '(PerfEvent.hpp)'
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check
uses: jidicula/[email protected]
with:
clang-format-version: '17'
check-path: ${{ matrix.path['check'] }}
exclude-regex: ${{ matrix.path['exclude'] }}
dependencyImage:
name: Build Docker Image Dependencies
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- name: Generate dependency files hash
id: files-hash
run: |
DIR_HASH=$(echo -n ${{ hashFiles('conanfile.py', 'conanprofile.docker', '.github/workflows/ci.yml', './Dockerfile_dependencies') }})
echo "DIR_HASH=$DIR_HASH" >> $GITHUB_ENV
- name: Docker metadata
id: dockerMetadata
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=${{ env.DIR_HASH }}
type=sha,format=long,prefix=commit-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check if image exists
id: check-image
run: |
EXISTS=$(docker manifest inspect ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }} > /dev/null 2>&1 && echo "true" || echo "false")
echo "CACHE_HIT=$EXISTS" >> $GITHUB_ENV
- name: Set up Docker Buildx
if: env.CACHE_HIT == 'false'
uses: docker/setup-buildx-action@v3
- name: Build and push image if input files changed
if: env.CACHE_HIT == 'false'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile_dependencies
push: true
tags: ${{ steps.dockerMetadata.outputs.tags }}
cache-from: type=gha,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }}
cache-to: type=gha,mode=min,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }}
platforms: linux/amd64,linux/arm64
- name: Retag and push existing image if cache hit
if: env.CACHE_HIT == 'true'
run: |
TAGS=(${{ steps.dockerMetadata.outputs.tags }})
for TAG in "${TAGS[@]}"; do
docker buildx imagetools create --tag $TAG ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }}
done
dockerImageUnitTests:
name: Build Docker Image and Run Unit Tests
runs-on: ubuntu-latest
needs: dependencyImage
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- name: Generate dependency files hash
id: files-hash
run: |
DIR_HASH=$(echo -n ${{ hashFiles('conanfile.py', 'conanprofile.docker', '.github/workflows/ci.yml', './Dockerfile_dependencies') }})
echo "DIR_HASH=$DIR_HASH" >> $GITHUB_ENV
- name: Docker metadata
id: dockerMetadata
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=sha,format=long,prefix=commit-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build unit test image
uses: docker/build-push-action@v6
with:
context: .
target: builder
tags: builder
load: true
cache-from: type=gha,ref=${{ github.ref_name }}-image-cache
cache-to: type=gha,mode=min,ref=${{ github.ref_name }}-image-cache
build-args: |
DEPENDENCY_IMAGE=ghcr.io/genspectrum/lapis-silo-dependencies:${{ env.DIR_HASH }}
- name: Run tests
uses: addnab/docker-run-action@v3
with:
image: builder
run: ./silo_test
- name: Build and push production image
if: ${{ github.event_name == 'push' }}
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: ${{ github.ref == 'refs/heads/main' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
tags: ${{ steps.dockerMetadata.outputs.tags }}
build-args: |
DEPENDENCY_IMAGE=ghcr.io/genspectrum/lapis-silo-dependencies:${{ env.DIR_HASH }}
endToEndTests:
name: Run End To End Tests
needs: dockerImageUnitTests
runs-on: ubuntu-latest
strategy:
matrix:
preprocessing-docker-compose: [
docker-compose-for-tests-preprocessing-from-ndjson.yml
]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: 18.x
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: npm install
run: cd endToEndTests && npm ci
- name: Check Format
run: cd endToEndTests && npm run check-format
- name: Docker Metadata
id: dockerMetadata
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
tags: type=ref,event=branch
- name: Start Docker Container and preprocess data
run: docker compose -f ${{ matrix.preprocessing-docker-compose }} up
env:
SILO_IMAGE: ${{ steps.dockerMetadata.outputs.tags }}
- name: Start Docker Container and run api
run: docker compose -f docker-compose-for-tests-api.yml up -d --wait
env:
SILO_IMAGE: ${{ steps.dockerMetadata.outputs.tags }}
- name: Run Tests
run: cd endToEndTests && SILO_URL=localhost:8080 npm run test