-
Notifications
You must be signed in to change notification settings - Fork 80
318 lines (259 loc) · 9.14 KB
/
main.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
315
316
317
318
name: Continuous Delivery
on: push
jobs:
build-and-upload-viewer-resources:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 🔧 Install java
uses: actions/setup-java@v1
with:
java-version: '11.0.7'
cache: 'maven'
- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.10.3.943'
bb: latest
clj-kondo: latest
- name: 🗝 maven cache
uses: actions/cache@v3
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-build-viewer-${{ hashFiles('deps.edn') }}
- name: Build and upload viewer resources
env:
GITHUB_TOKEN: ${{ secrets.CAS_AUTH_TOKEN }}
run: bb build+upload-viewer-resources
clj-kondo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
bb: latest
clj-kondo: latest
- name: 🗝 maven cache
uses: actions/cache@v3
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-lint-${{ hashFiles('bb.edn') }}
- name: Run clj-kondo linter
run: bb lint
test:
runs-on: ${{matrix.sys.os}}
strategy:
matrix:
sys:
- { os: macos-latest, shell: bash }
- { os: ubuntu-latest, shell: bash }
- { os: windows-latest, shell: powershell }
defaults:
run:
shell: ${{matrix.sys.shell}}
steps:
- uses: actions/checkout@v2
- name: 🔧 Install java
uses: actions/setup-java@v1
with:
java-version: '11.0.7'
- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.10.3.943'
bb: latest
- name: 🗝 maven cache
uses: actions/cache@v3
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-test-${{ hashFiles('deps.edn') }}
- name: 🧪 Run tests
run: bb test:clj :kaocha/reporter '[kaocha.report/documentation]'
static-build:
runs-on: ubuntu-latest
needs: [build-and-upload-viewer-resources]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🔧 Install java
uses: actions/setup-java@v1
with:
java-version: '11.0.7'
- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.10.3.943'
bb: latest
- name: 🗝 maven cache
uses: actions/cache@v3
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-build-${{ hashFiles('deps.edn') }}
- name: 🗝 Clerk Cache
uses: actions/cache@v2
with:
path: .clerk
key: ${{ runner.os }}-clerk-cache
- name: 🔐 Google Auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}
- name: 🔧 Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0.3.0
- name: 📓 Build Clerk Book
run: |
cp notebooks/editor.clj editor.clj
clojure -J-Dclojure.main.report=stderr -X:demo:nextjournal/clerk :git/sha '"${{ github.sha }}"' :git/url '"https://github.com/nextjournal/clerk"' :paths '["book.clj" "CHANGELOG.md" "editor.clj"]'
- name: 📠 Copy book to bucket under SHA
run: |
gsutil cp -r public/build gs://nextjournal-snapshots/clerk/book/${{ github.sha }}
- name: 🏗 Build Clerk Static App with default Notebooks
run: clojure -J-Dclojure.main.report=stderr -X:demo:nextjournal/clerk :package :single-file
- name: 📠 Copy static build to bucket under SHA
run: |
gsutil cp -r public/build gs://nextjournal-snapshots/clerk/build/${{ github.sha }}
- name: ✅ Add success status to report with link to snapshot
uses: Sibz/github-status-action@v1
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Continuous Delivery / Static App'
description: 'Ready'
state: 'success'
sha: ${{github.event.pull_request.head.sha || github.sha}}
target_url: https://snapshots.nextjournal.com/clerk/build/${{ github.sha }}
ssr:
name: SSR smoke test build
runs-on: ubuntu-latest
needs: [build-and-upload-viewer-resources]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🔧 Install java
uses: actions/setup-java@v1
with:
java-version: '11.0.7'
- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.10.3.943'
- name: 🗝 maven cache
uses: actions/cache@v3
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-ssr-${{ hashFiles('deps.edn') }}
- name: 🎨 Setup Tailwindcss
run: yarn global add tailwindcss @tailwindcss/typography
- name: 🧶 Yarn Global
run: echo $(yarn global dir)/node_modules
- name: 🧪 Build Rule 30 Notebook with SSR
run: NODE_PATH=$(yarn global dir)/node_modules clojure -J-Dclojure.main.report=stdout -X:demo:nextjournal/clerk :git/sha '"${{ github.sha }}"' :git/url '"https://github.com/nextjournal/clerk"' :index '"notebooks/rule_30.clj"' :paths [] :ssr true :compile-css true :exclude-js true
- name: 🔐 Google Auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}
- name: 🔧 Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0.3.0
- name: 📠 Copy SSR static build to bucket under SHA
run: |
gsutil cp -r public/build gs://nextjournal-snapshots/clerk-ssr/build/${{ github.sha }}
- name: ✅ Add success status to report with link to ssr snapshot
uses: Sibz/github-status-action@v1
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Continuous Delivery / SSR Static App'
description: 'Ready'
state: 'success'
sha: ${{github.event.pull_request.head.sha || github.sha}}
target_url: https://snapshots.nextjournal.com/clerk-ssr/build/${{ github.sha }}
ui-tests:
needs: [static-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
bb: latest
- name: 🗝 maven cache
uses: actions/cache@v3
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-ui-tests-${{ hashFiles('deps.edn') }}
- name: Get installed playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(bb playwright:version)" >> "$GITHUB_ENV"
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-npx-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: yarn install
run: cd ui_tests; yarn install
- name: playwright install
run: bb playwright:install
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Run Playwright tests against static assets
run: |
bb test:static-app :sha ${{ github.sha }} :skip-install true
bb test:static-app :skip-install true :url https://snapshots.nextjournal.com/clerk/book/${{ github.sha }}/book/index.html :index false :selector "span:has-text(\"Book of Clerk\")"
deploy:
needs: [build-and-upload-viewer-resources, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
bb: latest
- name: 🗝 maven cache
uses: actions/cache@v3
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-deploy-${{ hashFiles('deps.edn') }}
- name: Install SSH key and start ssh-agent
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.NEXTJOURNAL_CI_SSH_KEY }}
- name: Publish to clojars
env:
CLOJARS_USERNAME: mkvlr
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD_MKVLR }}
run: |
bb ci:publish
- name: Clerk version
id: clerk-version
run: |
CLERK_VERSION=$(bb clerk-version)
echo "##[set-output name=version;]${CLERK_VERSION}"
- uses: actions/upload-artifact@v4
with:
name: clerk-${{ steps.clerk-version.outputs.version }}.jar
path: target/clerk-${{ steps.clerk-version.outputs.version }}.jar