-
Notifications
You must be signed in to change notification settings - Fork 236
275 lines (262 loc) · 8.35 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
name: CI
on: [push, pull_request]
permissions: read-all
jobs:
linter-backend:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.48.0
args: --timeout 5m
linter-openapi:
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Lint OpenAPI specs
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: true
VALIDATE_OPENAPI: true
FILTER_REGEX_INCLUDE: docs/api/openapi.yaml
linter-artifacthub:
runs-on: ubuntu-20.04
container:
image: artifacthub/ah
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run ah lint
working-directory: ./charts/artifact-hub
run: ah lint
linter-clomonitor:
runs-on: ubuntu-20.04
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
container:
image: public.ecr.aws/clomonitor/linter:latest
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run CloMonitor linter
run: clomonitor-linter --path . --url https://github.com/artifacthub/hub
tests-database:
runs-on: ubuntu-20.04
container:
image: artifacthub/db-tests
services:
postgres:
image: artifacthub/postgres
env:
POSTGRES_USER: tests
POSTGRES_PASSWORD: tests
POSTGRES_DB: tests
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Apply database migrations
working-directory: ./database/migrations
run: TERN_CONF=../../../.github/workflows/tern.conf PGPORT=${{ job.services.postgres.ports[5432] }} ./migrate.sh
- name: Install pgtap database extension
run: PGPASSWORD=tests psql -h postgres -p ${{ job.services.postgres.ports[5432] }} -U tests tests -c 'create extension pgtap;'
- name: Run database tests
working-directory: ./database/tests
run: PGPASSWORD=tests pg_prove --host postgres --dbname tests --username tests --verbose schema/*.sql functions/*/*.sql
tests-backend:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run backend tests
run: go test -cover -race -v -mod=readonly ./...
tests-frontend:
runs-on: ubuntu-20.04
env:
NODE_OPTIONS: --max_old_space_size=4096
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: ./web/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
working-directory: ./web
run: yarn install
- name: Run prettier
working-directory: ./web
run: yarn format:diff
- name: Run eslint
working-directory: ./web
run: yarn lint
- name: Run frontend tests
working-directory: ./web
run: yarn test --watchAll=false --passWithNoTests --verbose --maxWorkers=4
tests-widget:
runs-on: ubuntu-20.04
env:
NODE_OPTIONS: --max_old_space_size=4096
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: ./widget/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
working-directory: ./widget
run: yarn install
- name: Run prettier
working-directory: ./widget
run: yarn format:diff
- name: Run eslint
working-directory: ./widget
run: yarn lint
- name: Run widget tests
working-directory: ./widget
run: yarn test --watchAll=false --passWithNoTests --verbose --maxWorkers=4
build-backend:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build hub
working-directory: ./cmd/hub
run: go build -v
- name: Build scanner
working-directory: ./cmd/scanner
run: go build -v
- name: Build tracker
working-directory: ./cmd/tracker
run: go build -v
build-frontend:
runs-on: ubuntu-20.04
env:
NODE_OPTIONS: --max_old_space_size=4096
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: ./web/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
working-directory: ./web
run: yarn install
- name: Build frontend
working-directory: ./web
run: yarn build
build-widget:
runs-on: ubuntu-20.04
env:
NODE_OPTIONS: --max_old_space_size=4096
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: ./widget/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
working-directory: ./widget
run: yarn install
- name: Build widget
working-directory: ./widget
run: yarn build
build-docker-images:
if: github.ref == 'refs/heads/master'
needs:
- linter-backend
- linter-openapi
- linter-artifacthub
- tests-database
- tests-backend
- tests-frontend
- tests-widget
- build-backend
- build-frontend
- build-widget
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag and push hub image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build -f cmd/hub/Dockerfile -t $ECR_REGISTRY/hub:$GITHUB_SHA .
docker push $ECR_REGISTRY/hub:$GITHUB_SHA
- name: Build, tag and push db-migrator image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build -f database/migrations/Dockerfile -t $ECR_REGISTRY/db-migrator:$GITHUB_SHA .
docker push $ECR_REGISTRY/db-migrator:$GITHUB_SHA
- name: Build, tag and push scanner image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build -f cmd/scanner/Dockerfile -t $ECR_REGISTRY/scanner:$GITHUB_SHA .
docker push $ECR_REGISTRY/scanner:$GITHUB_SHA
- name: Build, tag and push tracker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build -f cmd/tracker/Dockerfile -t $ECR_REGISTRY/tracker:$GITHUB_SHA .
docker push $ECR_REGISTRY/tracker:$GITHUB_SHA