-
-
Notifications
You must be signed in to change notification settings - Fork 72
908 lines (766 loc) Β· 31.9 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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
name: Test, Build, and Publish
on: [push]
concurrency:
# https://stackoverflow.com/a/72408109
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
python-version: "3.11.2"
# To avoid an error like "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory".
# See https://github.com/actions/virtual-environments/issues/70#issuecomment-653886422
# The Linux VM has 7GB RAM (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources),
# so we set the max memory size as 6.5 GiB like https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes
NODE_OPTIONS: "--max-old-space-size=6656"
RUN_ALL_TESTS: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
USE_CONSTRAINTS_FILE: false # https://github.com/streamlit/streamlit/blob/1.23.1/.github/workflows/release.yml#L61-L62
jobs:
changes: # See https://github.com/dorny/paths-filter#examples
runs-on: ubuntu-latest
outputs:
kernel: ${{ steps.filter.outputs.kernel == 'true' || env.RUN_ALL_TESTS == 'true' }}
# stlite-server: ${{ steps.filter.outputs.stlite-server == 'true' || env.RUN_ALL_TESTS == 'true' }}
stlite-server: true # This step does not detect changes in the `streamlit` submodule that is needed to trigger the test-stlite-server job (https://github.com/dorny/paths-filter/issues/143), so skip checking and make it always return true as a workaround.
mountable: ${{ steps.filter.outputs.mountable == 'true' || env.RUN_ALL_TESTS == 'true' }}
sharing-editor: ${{ steps.filter.outputs.sharing-editor == 'true' || env.RUN_ALL_TESTS == 'true' }}
sharing-common: ${{ steps.filter.outputs.sharing-common == 'true' || env.RUN_ALL_TESTS == 'true' }}
desktop: ${{ steps.filter.outputs.desktop == 'true' || env.RUN_ALL_TESTS == 'true' }}
vscode-extension: ${{ steps.filter.outputs.vscode-extension == 'true' || env.RUN_ALL_TESTS == 'true' }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
kernel:
- 'packages/kernel/**/*'
# - '!packages/kernel/py/**/*' # Not supported by paths-filter now: https://github.com/dorny/paths-filter/issues/106
# stlite-server: # We run this job anytime. See above.
# - 'packages/kernel/py/stlite-server/**/*'
# - 'streamlit/**/*'
mountable:
- 'packages/mountable/**/*'
sharing-editor:
- 'packages/sharing-editor/**/*'
sharing-common:
- 'packages/sharing-common/**/*'
desktop:
- 'packages/desktop/**/*'
vscode-extension:
- 'packages/vscode-stlite/**/*'
test-kernel:
needs: changes
if: ${{ needs.changes.outputs.kernel == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/kernel
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Lint
run: |
yarn check:eslint
yarn check:prettier
- run: yarn test
test-stlite-server:
needs: changes
if: ${{ needs.changes.outputs.stlite-server == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project false
- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('requirements*.txt') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
- name: Create virtualenv
run: python -m venv .venv
- name: Install dependencies
shell: bash
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-server
poetry install
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"
- name: Set up Streamlit and build proto
run: |
. .venv/bin/activate
make streamlit-proto
- name: Run linter and code formatter to the test code module
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-server
poetry run black . --check
poetry run isort . --check
poetry run flake8
- name: Run mypy
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-server
poetry run mypy .
- name: Run pytest
shell: bash
run: |
. .venv/bin/activate
cd packages/kernel/py/stlite-server
poetry run python -m pytest -v tests
test-mountable:
needs: changes
if: ${{ needs.changes.outputs.mountable == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/mountable
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Lint
run: |
yarn check:eslint
yarn check:prettier
- run: yarn test
test-sharing-editor:
needs: changes
if: ${{ needs.changes.outputs.sharing-editor == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/sharing-editor
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: make sharing-common
working-directory: .
# - name: Lint
# run: |
# yarn check:eslint
# yarn check:prettier
- run: yarn test
test-sharing-common:
needs: changes
if: ${{ needs.changes.outputs.sharing-common == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/sharing-common
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Lint
run: |
yarn check:eslint
yarn check:prettier
- run: yarn test
test-desktop:
needs: changes
if: ${{ needs.changes.outputs.desktop == 'true' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest] # The desktop package contains OS-dependent file paths manipulations differing between POSIX and Windows.
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: packages/desktop
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Lint
if: ${{ matrix.os == 'ubuntu-latest' }} # The glob pattern passed to ESLint is hardcoded as POSIX, so it does not work on Windows.
run: |
yarn check:eslint
yarn check:prettier
- run: yarn typecheck
- run: yarn test
build-kernel:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [test-kernel, test-stlite-server]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
## Set up Python and Poetry environment
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('requirements*.txt') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
## Set up Node environment
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"
- name: Set up
run: make init
## Build and deploy @stlite/mountable
# PUBLIC_URL here is set as a relative path, which is possible to the trick introduced at https://github.com/whitphx/stlite/pull/143.
- name: Set PUBLIC_URL
run: echo "PUBLIC_URL=." >> $GITHUB_ENV
- name: Build @stlite/kernel
run: make kernel
- name: Package
working-directory: packages/kernel
run: yarn pack
- name: Upload the built tar ball as an artifact
uses: actions/upload-artifact@v3
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
with:
path: packages/kernel/stlite-kernel-v*.tgz
name: stlite-kernel-${{ github.sha }}.tgz
- name: Upload the built tar ball as an artifact (when pushed with a version tag)
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
path: packages/kernel/stlite-kernel-v*.tgz
name: stlite-kernel-${{ github.ref_name }}.tgz
publish-kernel:
if: ${{ !failure() && startsWith(github.ref, 'refs/tags/v') }} # `!failure()` is necessary to avoid skipping this job after successful build: https://github.com/actions/runner/issues/491
needs: [build-kernel]
permissions:
contents: write # Necessary for creating releases: https://github.com/softprops/action-gh-release#permissions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
scope: '@stlite'
- uses: actions/download-artifact@v3
with:
name: stlite-kernel-${{ github.ref_name }}.tgz
path: packages/kernel
- run: yarn publish stlite-kernel-v*.tgz --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: packages/kernel
- name: Create a new release
uses: softprops/action-gh-release@v1
with:
files: packages/kernel/stlite-kernel-v*.tgz
generate_release_notes: true
build-mountable:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [test-kernel, test-stlite-server, test-mountable]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
## Set up Python and Poetry environment
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('requirements*.txt') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
## Set up Node environment
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"
- name: Set up
run: make init
## Build and deploy @stlite/mountable
# PUBLIC_URL here is set as a relative path, which is possible to the trick introduced at https://github.com/whitphx/stlite/pull/143.
- name: Set PUBLIC_URL
run: echo "PUBLIC_URL=." >> $GITHUB_ENV
- name: Build @stlite/mountable
run: make mountable
- name: Package
working-directory: packages/mountable
run: yarn pack
- name: Upload the built tar ball as an artifact
uses: actions/upload-artifact@v3
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
with:
path: packages/mountable/stlite-mountable-v*.tgz
name: stlite-mountable-${{ github.sha }}.tgz
- name: Upload the built tar ball as an artifact (when pushed with a version tag)
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
path: packages/mountable/stlite-mountable-v*.tgz
name: stlite-mountable-${{ github.ref_name }}.tgz
publish-mountable:
if: ${{ !failure() && startsWith(github.ref, 'refs/tags/v') }} # `!failure()` is necessary to avoid skipping this job after successful build: https://github.com/actions/runner/issues/491
needs: [build-mountable]
permissions:
contents: write # Necessary for creating releases: https://github.com/softprops/action-gh-release#permissions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
scope: '@stlite'
- uses: actions/download-artifact@v3
with:
name: stlite-mountable-${{ github.ref_name }}.tgz
path: packages/mountable
- run: yarn publish stlite-mountable-v*.tgz --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: packages/mountable
- name: Create a new release
uses: softprops/action-gh-release@v1
with:
files: packages/mountable/stlite-mountable-v*.tgz
generate_release_notes: true
build-sharing:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [test-kernel, test-stlite-server, test-sharing-common]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
## Set up Python and Poetry environment
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('requirements*.txt') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
## Set up Node environment
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"
- name: Set up
run: make init
## Build and upload @stlite/sharing
- name: Set EDITOR_APP_ORIGIN (preview)
if: github.ref_name != github.event.repository.default_branch
run: echo "REACT_APP_EDITOR_APP_ORIGIN_REGEX=^https://[a-z0-9]+\.stlite-sharing-editor\.pages\.dev$" >> $GITHUB_ENV
- name: Set EDITOR_APP_ORIGIN (main branch)
if: github.ref_name == github.event.repository.default_branch
run: echo "REACT_APP_EDITOR_APP_ORIGIN=https://edit.share.stlite.net" >> $GITHUB_ENV
- name: Build @stlite/sharing
run: make sharing
- name: Upload the built directory as an artifact
uses: actions/upload-artifact@v3
with:
path: packages/sharing/build
name: stlite-sharing
deploy-sharing:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [build-sharing]
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Deploy @stlite/sharing to Cloudflare Pages
outputs:
url: ${{ steps.publish.outputs.url }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: stlite-sharing
path: website
- name: Publish
uses: cloudflare/pages-action@1
id: publish
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: stlite-sharing
directory: website
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
build-sharing-editor:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [test-sharing-editor, test-sharing-common, deploy-sharing]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Set SHARING_APP_URL (preview)
if: github.ref_name != github.event.repository.default_branch
run: echo "REACT_APP_SHARING_APP_URL=${{needs.deploy-sharing.outputs.url}}" >> $GITHUB_ENV
- name: Set SHARING_APP_URL (main branch)
if: github.ref_name == github.event.repository.default_branch
run: echo "REACT_APP_SHARING_APP_URL=https://share.stlite.net/" >> $GITHUB_ENV
- run: make sharing-editor
- name: Upload the built directory as an artifact
uses: actions/upload-artifact@v3
with:
path: packages/sharing-editor/build
name: stlite-sharing-editor
deploy-sharing-editor:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [build-sharing-editor]
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Deploy @stlite/sharing-editor to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: stlite-sharing-editor
path: website
- name: Publish
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: stlite-sharing-editor
directory: website
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
build-desktop:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [test-kernel, test-stlite-server, test-desktop]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
## Set up Python and Poetry environment
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('requirements*.txt') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
## Set up Node environment
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"
- name: Set up
run: make init
## Build and deploy @stlite/desktop
- name: Build @stlite/desktop
run: make desktop
- name: Check if electron-builder works
working-directory: packages/desktop
run: yarn run pack
- name: Package
working-directory: packages/desktop
run: yarn pack
- name: Upload the built tar ball as an artifact
uses: actions/upload-artifact@v3
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
with:
path: packages/desktop/stlite-desktop-v*.tgz
name: stlite-desktop-${{ github.sha }}.tgz
- name: Upload the built tar ball as an artifact (when pushed with a version tag)
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
path: packages/desktop/stlite-desktop-v*.tgz
name: stlite-desktop-${{ github.ref_name }}.tgz
publish-desktop:
if: ${{ !failure() && startsWith(github.ref, 'refs/tags/v') }} # `!failure()` is necessary to avoid skipping this job after successful build: https://github.com/actions/runner/issues/491
needs: [build-desktop]
permissions:
contents: write # Necessary for creating releases: https://github.com/softprops/action-gh-release#permissions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
scope: '@stlite'
- uses: actions/download-artifact@v3
with:
name: stlite-desktop-${{ github.ref_name }}.tgz
path: packages/desktop
- run: yarn publish stlite-desktop-v*.tgz --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: packages/desktop
- name: Create a new release
uses: softprops/action-gh-release@v1
with:
files: packages/desktop/stlite-desktop-v*.tgz
generate_release_notes: true
test-build-vscode-extension:
needs: changes
if: ${{ needs.changes.outputs.vscode-extension == 'true' }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn config set network-timeout 300000 # https://github.com/yarnpkg/yarn/issues/8242
- run: yarn install --frozen-lockfile
- run: make common
- name: Lint
run: |
yarn check:eslint
yarn check:prettier
if: runner.os == 'Linux'
working-directory: packages/vscode-stlite
- run: xvfb-run -a yarn test
if: runner.os == 'Linux'
working-directory: packages/vscode-stlite
- run: yarn test
if: runner.os != 'Linux'
working-directory: packages/vscode-stlite
- name: Build
if: success() && matrix.os == 'ubuntu-latest'
run: |
if [ $IS_RELEASE = true ]; then
VERSION=$(node -p "require('./package.json').version")
else
VERSION=${{ github.sha }}
fi
yarn run vsce package -o vscode-stlite-${VERSION}-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}.vsix
env:
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
working-directory: packages/vscode-stlite
- name: Upload the vsix built on Linux
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-latest' && ! startsWith(github.ref, 'refs/tags/v') }}
with:
path: packages/vscode-stlite/vscode-stlite*.vsix
name: vscode-stlite-${{ github.sha }}.vsix
- name: Upload the vsix built on Linux
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/v') }}
with:
path: packages/vscode-stlite/vscode-stlite*.vsix
name: vscode-stlite-${{ github.ref_name }}.vsix
publish-vscode-extension:
if: ${{ !failure() && startsWith(github.ref, 'refs/tags/v') }} # `!failure()` is necessary to avoid skipping this job after successful build: https://github.com/actions/runner/issues/491
needs:
- test-build-vscode-extension
- publish-mountable # The VSC extension uses the same version of published @stlite/mountable, so it must be released in order.
permissions:
contents: write # Necessary for creating releases: https://github.com/softprops/action-gh-release#permissions
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [marketplace, openvsx]
steps:
- uses: actions/download-artifact@v3
with:
name: vscode-stlite-${{ github.ref_name }}.vsix
- run: |
files=( vscode-stlite*.vsix )
echo "vsix_filename=${files[0]}" >> $GITHUB_ENV
- if: matrix.target == 'marketplace'
name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v1
with:
extensionFile: "${{ env.vsix_filename }}"
pat: ${{ secrets.VSCE_PAT }}
registryUrl: https://marketplace.visualstudio.com
- if: matrix.target == 'openvsx'
name: Publish to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v1
with:
extensionFile: "${{ env.vsix_filename }}"
pat: ${{ secrets.OPEN_VSX_TOKEN }}
- if: matrix.target == 'marketplace'
name: Create a new release
uses: softprops/action-gh-release@v1
with:
files: "${{ env.vsix_filename }}"
generate_release_notes: true