@@ -15,19 +15,117 @@ concurrency:
15
15
group : ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
16
16
cancel-in-progress : true
17
17
18
- env :
19
- DOCKER_IMAGE : hirosystems/${{ github.event.repository.name }}
20
-
21
18
jobs :
19
+ api-lint :
20
+ strategy :
21
+ fail-fast : false
22
+ matrix :
23
+ suite : [ordinals]
24
+ runs-on : ubuntu-latest
25
+ defaults :
26
+ run :
27
+ working-directory : ./api/${{ matrix.suite }}
28
+ steps :
29
+ - uses : actions/checkout@v4
30
+
31
+ - name : Use Node.js
32
+ uses : actions/setup-node@v4
33
+ with :
34
+ node-version-file : ' api/${{ matrix.suite }}/.nvmrc'
35
+
36
+ - name : Cache node modules
37
+ uses : actions/cache@v4
38
+ env :
39
+ cache-name : cache-node-modules
40
+ with :
41
+ path : |
42
+ ~/.npm
43
+ **/node_modules
44
+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
45
+ restore-keys : |
46
+ ${{ runner.os }}-build-${{ env.cache-name }}-
47
+ ${{ runner.os }}-build-
48
+ ${{ runner.os }}-
49
+
50
+ - name : Install deps
51
+ run : npm ci --audit=false
52
+
53
+ - name : Lint ESLint
54
+ run : npm run lint:eslint
55
+
56
+ - name : Lint Prettier
57
+ run : npm run lint:prettier
58
+
59
+ - name : Lint Unused Exports
60
+ run : npm run lint:unused-exports
61
+
62
+ api-test :
63
+ strategy :
64
+ fail-fast : false
65
+ matrix :
66
+ suite : [ordinals]
67
+ defaults :
68
+ run :
69
+ working-directory : ./api/${{ matrix.suite }}
70
+ runs-on : ubuntu-latest
71
+ steps :
72
+ - uses : actions/checkout@v4
73
+ with :
74
+ fetch-depth : 0
75
+
76
+ - name : Use Node.js
77
+ uses : actions/setup-node@v4
78
+ with :
79
+ node-version-file : ' api/${{ matrix.suite }}/.nvmrc'
80
+
81
+ - name : Cache node modules
82
+ uses : actions/cache@v4
83
+ env :
84
+ cache-name : cache-node-modules
85
+ with :
86
+ path : |
87
+ ~/.npm
88
+ **/node_modules
89
+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
90
+ restore-keys : |
91
+ ${{ runner.os }}-build-${{ env.cache-name }}-
92
+ ${{ runner.os }}-build-
93
+ ${{ runner.os }}-
94
+
95
+ - name : Install deps
96
+ run : npm ci --audit=false
97
+
98
+ - name : Setup integration environment
99
+ run : |
100
+ sudo ufw disable
101
+ npm run testenv:run -- -d
102
+ npm run testenv:logs -- --no-color &> docker-compose-logs.txt &
103
+
104
+ - name : Run tests
105
+ run : npm run test -- --coverage
106
+
107
+ - name : Upload coverage to Codecov
108
+ uses : codecov/codecov-action@v4
109
+ with :
110
+ token : ${{ secrets.CODECOV_TOKEN }}
111
+
112
+ - name : Print integration environment logs
113
+ run : cat docker-compose-logs.txt
114
+ if : failure()
115
+
116
+ - name : Teardown integration environment
117
+ run : npm run testenv:stop
118
+ if : always()
119
+
22
120
test :
23
121
strategy :
24
122
fail-fast : false
25
123
matrix :
26
- suite : [cli, core]
124
+ suite : [ordhook- cli, ordhook- core]
27
125
runs-on : ubuntu-latest
28
126
defaults :
29
127
run :
30
- working-directory : ./components/ordhook- ${{ matrix.suite }}
128
+ working-directory : ./components/${{ matrix.suite }}
31
129
steps :
32
130
- uses : actions/checkout@v4
33
131
with :
@@ -73,11 +171,11 @@ jobs:
73
171
run : docker compose -f ../../dockerfiles/docker-compose.dev.postgres.yml down -v -t 0
74
172
if : always()
75
173
76
- build-publish :
174
+ semantic-release :
77
175
runs-on : ubuntu-latest
78
- needs : test
176
+ needs : [api-lint, api- test, test]
79
177
outputs :
80
- docker_image_digest : ${{ steps.docker_push .outputs.digest }}
178
+ new_release_version : ${{ steps.semantic .outputs.new_release_version }}
81
179
new_release_published : ${{ steps.semantic.outputs.new_release_published }}
82
180
steps :
83
181
- uses : actions/checkout@v4
@@ -92,19 +190,31 @@ jobs:
92
190
env :
93
191
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
94
192
SEMANTIC_RELEASE_PACKAGE : ${{ github.event.repository.name }}
193
+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_CRATES_IO_API_KEY }}
95
194
with :
96
195
semantic_version : 19
97
196
extra_plugins : |
98
197
@semantic-release/changelog@6.0.3
99
198
@semantic-release/git@10.0.1
199
+ @semantic-release/exec@6.0.3
100
200
conventional-changelog-conventionalcommits@6.1.0
101
201
202
+ build-publish :
203
+ runs-on : ubuntu-latest
204
+ needs : semantic-release
205
+ outputs :
206
+ docker_image_digest : ${{ steps.docker_push.outputs.digest }}
207
+ steps :
208
+ - uses : actions/checkout@v4
209
+ with :
210
+ persist-credentials : false
211
+
102
212
- name : Checkout tag
103
- if : steps .semantic.outputs.new_release_version != ''
213
+ if : needs .semantic-release .outputs.new_release_version != ''
104
214
uses : actions/checkout@v4
105
215
with :
106
216
persist-credentials : false
107
- ref : v${{ steps .semantic.outputs.new_release_version }}
217
+ ref : v${{ needs .semantic-release .outputs.new_release_version }}
108
218
109
219
- name : Set up Docker Buildx
110
220
uses : docker/setup-buildx-action@v3
@@ -114,12 +224,12 @@ jobs:
114
224
uses : docker/metadata-action@v5
115
225
with :
116
226
images : |
117
- ${{ env.DOCKER_IMAGE }}
227
+ hirosystems/ordhook
118
228
tags : |
119
229
type=ref,event=branch
120
230
type=ref,event=pr
121
- type=semver,pattern={{version}},value=${{ steps .semantic.outputs.new_release_version }},enable=${{ steps .semantic.outputs.new_release_version != '' }}
122
- type=semver,pattern={{major}}.{{minor}},value=${{ steps .semantic.outputs.new_release_version }},enable=${{ steps .semantic.outputs.new_release_version != '' }}
231
+ type=semver,pattern={{version}},value=${{ needs .semantic-release .outputs.new_release_version }},enable=${{ needs .semantic-release .outputs.new_release_version != '' }}
232
+ type=semver,pattern={{major}}.{{minor}},value=${{ needs .semantic-release .outputs.new_release_version }},enable=${{ needs .semantic-release .outputs.new_release_version != '' }}
123
233
type=raw,value=latest,enable={{is_default_branch}}
124
234
125
235
- name : Log in to DockerHub
@@ -141,7 +251,59 @@ jobs:
141
251
cache-from : type=gha
142
252
cache-to : type=gha,mode=max
143
253
# Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks)
144
- push : ${{ (github.ref != 'refs/heads/main' || steps.semantic.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
254
+ push : ${{ (github.ref != 'refs/heads/main' || needs.semantic-release.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
255
+
256
+ api-build-publish :
257
+ strategy :
258
+ fail-fast : false
259
+ matrix :
260
+ suite : [ordinals]
261
+ runs-on : ubuntu-latest
262
+ needs : semantic-release
263
+ steps :
264
+ - uses : actions/checkout@v4
265
+ with :
266
+ token : ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
267
+ fetch-depth : 0
268
+ persist-credentials : false
269
+
270
+ - name : Checkout tag
271
+ if : needs.semantic-release.outputs.new_release_version != ''
272
+ uses : actions/checkout@v4
273
+ with :
274
+ persist-credentials : false
275
+ ref : v${{ needs.semantic-release.outputs.new_release_version }}
276
+
277
+ - name : Set up Docker Buildx
278
+ uses : docker/setup-buildx-action@v3
279
+
280
+ - name : Docker Meta
281
+ id : meta
282
+ uses : docker/metadata-action@v5
283
+ with :
284
+ images : |
285
+ hirosystems/${{ matrix.suite }}
286
+ tags : |
287
+ type=ref,event=branch
288
+ type=ref,event=pr
289
+ type=semver,pattern={{version}},value=${{ needs.semantic-release.outputs.new_release_version }},enable=${{ needs.semantic-release.outputs.new_release_version != '' }}
290
+ type=semver,pattern={{major}}.{{minor}},value=${{ needs.semantic-release.outputs.new_release_version }},enable=${{ needs.semantic-release.outputs.new_release_version != '' }}
291
+
292
+ - name : Login to DockerHub
293
+ uses : docker/login-action@v3
294
+ with :
295
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
296
+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
297
+
298
+ - name : Build/Tag/Push Image
299
+ uses : docker/build-push-action@v5
300
+ with :
301
+ context : ./api/${{ matrix.suite }}
302
+ file : ./api/${{ matrix.suite }}/Dockerfile
303
+ tags : ${{ steps.meta.outputs.tags }}
304
+ labels : ${{ steps.meta.outputs.labels }}
305
+ # Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks)
306
+ push : ${{ (github.ref != 'refs/heads/master' || needs.semantic-release.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
145
307
146
308
deploy-dev :
147
309
runs-on : ubuntu-latest
0 commit comments