-
Notifications
You must be signed in to change notification settings - Fork 957
Expand file tree
/
Copy pathconfig.yml
More file actions
1441 lines (1362 loc) · 48.8 KB
/
Copy pathconfig.yml
File metadata and controls
1441 lines (1362 loc) · 48.8 KB
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
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
version: 2.1
# ========================================
# ANCHORS & ALIASES
# ========================================
# Base configurations
default_image: &default_image
docker:
- image: cimg/node:22.14.0
default_resource_class: &default_resource_class
resource_class: medium
default_working_dir: &default_working_dir
working_directory: ~/bit
defaults: &defaults
<<: [*default_image, *default_resource_class, *default_working_dir]
# Windows configurations
windows_default_resource_size: &windows_default_resource_size
size: medium
windows_default_working_dir: &windows_default_working_dir
working_directory: C:\Users\circleci\project\bit
windows_default_executor_name: &windows_default_executor_name
name: win/default
windows_default_executor: &windows_default_executor
executor:
<<: [*windows_default_executor_name, *windows_default_resource_size]
windows_defaults: &windows_defaults
<<: [*windows_default_executor, *windows_default_working_dir]
# Filters
semver_tags_only_filters: &semver_tags_only_filters
filters:
# ignore any commit on any branch by default
branches:
ignore: /.*/
# only act on version tags
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
master_only_filter: &master_only_filter
filters:
branches:
only: master
# ========================================
# ORBS
# ========================================
orbs:
win: circleci/windows@5.0
slack: circleci/slack@5.2.3
# ========================================
# COMMANDS
# ========================================
commands:
# Bundle installation with hoisting and overrides (Linux/macOS)
install_bit_bundle:
parameters:
os:
type: string
default: "linux"
cpu:
type: string
default: "x64"
directory:
type: string
default: "bit-${BIT_VERSION}"
steps:
- run:
name: install bit bundle for <<parameters.os>> <<parameters.cpu>>
command: >
cd <<parameters.directory>> &&
pnpm init &&
echo "node-linker=hoisted" >> .npmrc &&
echo "registry=https://node-registry.bit.cloud" >> .npmrc &&
pnpm dlx @ialdama/jsonmod --key pnpm.overrides.uri-js --values npm:uri-js-replace &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.cross-spawn@7" --values "^7.0.5" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.lodash@4" --values "4.17.21" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.trim@0" --values "0.0.3" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.@teambit/harmony" --values "0.4.7" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.postcss@8" --values "^8.4.19" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.ajv@6" --values "^6.12.6" &&
pnpm add @teambit/bit --os=<<parameters.os>> --cpu=<<parameters.cpu>>
# Bundle installation for Windows (with Windows-specific configs)
install_bit_bundle_windows:
parameters:
cpu:
type: string
default: "x64"
directory:
type: string
default: "bit-${BIT_VERSION}"
steps:
- run:
name: install bit bundle for Windows <<parameters.cpu>>
command: >
cd <<parameters.directory>> &&
pnpm init &&
echo "node-linker=hoisted" >> .npmrc &&
echo "registry=https://node-registry.bit.cloud" >> .npmrc &&
echo "prefer-symlinked-executables=false" >> .npmrc &&
pnpm dlx @ialdama/jsonmod --key pnpm.neverBuiltDependencies --values cpu-features --values ssh2 &&
pnpm dlx @ialdama/jsonmod --key pnpm.overrides.uri-js --values npm:uri-js-replace &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.cross-spawn@7" --values "^7.0.5" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.lodash@4" --values "4.17.21" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.trim@0" --values "0.0.3" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.@teambit/harmony" --values "0.4.7" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.postcss@8" --values "^8.4.19" &&
pnpm dlx @ialdama/jsonmod --key "pnpm.overrides.ajv@6" --values "^6.12.6" &&
pnpm add @teambit/bit --os=win32 --cpu=<<parameters.cpu>>
# Bit configuration
bit_config:
parameters:
env:
default: 'hub-stg'
# default: 'hub'
type: string
token:
default: $BIT_CLOUD_PROD_TOKEN
type: string
bin_name:
default: bit
type: string
steps:
- run: '<<parameters.bin_name>> config set analytics_reporting false'
- run: '<<parameters.bin_name>> config set error_reporting false'
- run: '<<parameters.bin_name>> config set user.name CI'
- run: '<<parameters.bin_name>> config set user.email ci@bit.dev'
- run: '<<parameters.bin_name>> config set registry https://node-registry.bit.cloud'
# - run: '<<parameters.bin_name>> config set user.token <<parameters.token>>'
- run: '<<parameters.bin_name>> config set hub_domain <<parameters.env>>.bit.dev'
- run: '<<parameters.bin_name>> config set package-manager.cache /home/circleci/package-manager-cache'
# Optimize node_modules size for BVM distributions
optimize_node_modules:
parameters:
platform:
default: ''
type: string
steps:
- run:
name: optimize node_modules size<<# parameters.platform >> for <<parameters.platform>><</parameters.platform>>
command: >
cd bit-${BIT_VERSION} &&
node ../bit/scripts/cleanup-node-modules.js ./node_modules --keep-teambit-maps &&
echo "Node modules optimized successfully<<# parameters.platform >> for <<parameters.platform>><</parameters.platform>>"
# NPM setup
bit_global_for_npm:
steps:
- run:
name: 'create npm global dir'
command: 'mkdir -p /home/circleci/.npm-global/bin'
- run:
name: 'link bit to path'
command: 'ln -sf /home/circleci/bit/bit/bin/bit.js /home/circleci/.npm-global/bin/bit'
- run: "echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV"
- run: which bit
set_bit_cloud_registry:
steps:
- run:
name: set bit cloud registry in npm config
command: npm config set @teambit:registry=https://node-registry.bit.cloud
- run:
name: set bit cloud registry in npm config
command: npm config set @bitdev:registry=https://node-registry.bit.cloud
setup_pnpm:
steps:
- run:
name: Install pnpm
command: >
npm config set prefix '~/.npm-global' &&
npm install --global pnpm@10.14.0 &&
echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV
# BVM setup
install_bvm:
steps:
- run: npm config set prefix '~/.npm-global'
- run: npm install --global @teambit/bvm
- run: "echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV"
- run: bvm config set RELEASE_TYPE nightly
bvm_upgrade:
steps:
- run: bvm config set DEFAULT_LINK bbit
- run: bvm config set RELEASE_TYPE nightly
- run: bvm upgrade
# - run: bvm install 1.11.42
- run: bvm link --verbose
- bit_config:
env: "hub"
bin_name: "bbit"
- run: bbit
- run: bbit -v
- save_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
paths:
- /home/circleci/.bvm
# SSH & Git setup
update_ssh_agent:
steps:
# add the id_rsa to ssh_agent to make sure we authenticate with the correct user
- run: 'chmod 400 ~/.ssh/id_rsa'
- run: 'ssh-add ~/.ssh/id_rsa'
set_git_credentials:
steps:
- run:
name: 'set GitHub token'
command: export GH_RELEASE_GITHUB_API_TOKEN=$ghToken
- add_ssh_keys:
fingerprints:
- 'SHA256:fF5QridDUgTXkn8xIMZQNbn9sPN5QhNhc3jr8y8e2LI ci@bit.dev'
- run:
name: set git user.name and user.email
command: 'git config --global user.email "ci@bit.dev" && git config --global user.name "CircleCI"'
# - run:
# name: 'replace git protocol from ssh to http' # to not get the authenticate error
# command: sed -i 's/git@github.com:teambit\/bit.git/https:\/\/github.com\/teambit\/bit.git/g' .git/config
# - run: mkdir -p ~/.ssh
# - run: SCAN=$(ssh-keyscan github.com )
# - run: echo $SCAN >> ~/.ssh/known_hosts
- run: cd bit && git remote rm origin
# todo: find a better way. currently, the ssh doesn't work, see the commented steps above.
- run: cd bit && git remote add origin https://davidfirst:$GH_RELEASE_GITHUB_API_TOKEN@github.com/teambit/bit.git
# Windows setup
windows_set_node_version:
parameters:
version:
default: 22.14.0
type: string
steps:
- run: choco upgrade nvm -y
- run: nvm -v
- run: nvm install 22.14.0
- run: nvm use 22.14.0
- run: node -v
windows_add_bvm_to_path:
steps:
- run: New-Item $Profile.CurrentUserAllHosts -Force
- run: Add-Content -Path $Profile.CurrentUserAllHosts -Value '$env:PATH = "C:\Users\circleci\AppData\Local\.bvm;$env:PATH"'
- run: $Env:Path.Split(';')
# Version & Build setup
setup_bit_version:
steps:
- run:
name: print bit version
command: npm view @teambit/bit version
- run:
name: Setup bit version environment variables
command: echo "export BIT_VERSION=$(npm view @teambit/bit version)" >> $BASH_ENV && source $BASH_ENV
- run:
name: create empty folder
command: mkdir bit-${BIT_VERSION}
compress_bit:
steps:
- run:
name: Compress Bit
command: >
tar -cvf bit-${BIT_VERSION}.tar.gz
--exclude=bit-${BIT_VERSION}/.npmrc
--exclude=bit-${BIT_VERSION}/package.json
--exclude=bit-${BIT_VERSION}/pnpm-lock.yaml
bit-${BIT_VERSION}
# Docker commands
docker_build_and_push:
parameters:
docker_build_base_image_arg_name:
default: 'BASE_IMAGE'
type: string
docker_build_base_image_arg_value:
default: 'node:22.14.0'
type: string
image_name:
default: 'bitcli/bit'
type: string
docker_file_name:
default: 'Dockerfile-bit'
type: string
# I want this to be something like '-node-<<parameters.node_version>>' but I don't think we can access other params here
docker_tag_suffix:
default: ''
type: string
bit_version_arg_name:
default: 'BIT_VERSION'
type: string
steps:
- docker_build_internal:
image_name: "<<parameters.image_name>>"
docker_file_name: "<<parameters.docker_file_name>>"
docker_tag_suffix: "<<parameters.docker_tag_suffix>>"
bit_version_arg_name: "<<parameters.bit_version_arg_name>>"
docker_build_base_image_arg_name: "<<parameters.docker_build_base_image_arg_name>>"
docker_build_base_image_arg_value: "<<parameters.docker_build_base_image_arg_value>>"
- docker_push:
image_name: "<<parameters.image_name>>"
docker_tag_suffix: "<<parameters.docker_tag_suffix>>"
docker_build_internal:
parameters:
docker_build_base_image_arg_name:
default: 'BASE_IMAGE'
type: string
docker_build_base_image_arg_value:
default: 'node:22.14.0'
type: string
image_name:
default: 'bitcli/bit'
type: string
docker_file_name:
default: 'Dockerfile-bit'
type: string
docker_tag_suffix:
default: ""
type: string
bit_version_arg_name:
default: 'BIT_VERSION'
type: string
steps:
- run: |
cd bit/scripts && docker build -f ./docker-teambit-bit/<<parameters.docker_file_name>> \
--build-arg <<parameters.docker_build_base_image_arg_name>>=<<parameters.docker_build_base_image_arg_value>> \
--build-arg <<parameters.bit_version_arg_name>>=`npm show @teambit/bit version` \
-t <<parameters.image_name>>:`npm show @teambit/bit version`<<parameters.docker_tag_suffix>> .
- run: |
cd bit/scripts && docker build -f ./docker-teambit-bit/<<parameters.docker_file_name>> \
--build-arg <<parameters.docker_build_base_image_arg_name>>=<<parameters.docker_build_base_image_arg_value>> \
--build-arg <<parameters.bit_version_arg_name>>=`npm show @teambit/bit version` \
-t <<parameters.image_name>>:latest<<parameters.docker_tag_suffix>> .
docker_push:
parameters:
image_name:
default: 'bitcli/bit'
type: string
docker_tag_suffix:
default: ''
type: string
steps:
- run: echo "$DOCKER_PASS" | docker login --username $DOCKER_USER --password-stdin
- run: cd bit && docker push <<parameters.image_name>>:`npm show @teambit/bit version`<<parameters.docker_tag_suffix>>
- run: cd bit && docker push <<parameters.image_name>>:latest<<parameters.docker_tag_suffix>>
# Common cache operations
restore_common_caches:
steps:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.1.0-v1
- run: npm view @teambit/bit version > ./version.txt
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
# Complete Bit environment setup
setup_bit_environment:
parameters:
env:
default: "hub"
type: string
token_env_var:
default: "BIT_CLOUD_PROD_TOKEN"
type: string
steps:
- bit_global_for_npm
- bit_config:
env: "<<parameters.env>>"
- restore_cache:
key: bitsrc-ssh-key3
- restore_common_caches
- run: bit config set user.token ${<<parameters.token_env_var>>}
# Test results and artifacts storage
store_test_results_and_artifacts:
parameters:
test_results_path:
default: "junit"
type: string
artifacts_path:
default: "junit"
type: string
logs_path:
default: "~/Library/Caches/Bit/logs"
type: string
steps:
- store_test_results:
path: <<parameters.test_results_path>>
- store_artifacts:
path: <<parameters.artifacts_path>>
- store_artifacts:
path: <<parameters.logs_path>>
# Windows Bit environment setup
windows_setup_bit_environment:
steps:
- attach_workspace:
at: .
- windows_add_bvm_to_path
- windows_set_node_version
- restore_cache:
key: v2-bvm-folder-{{ checksum "version.txt" }}
- run: bit -v
- run:
name: 'save SHA to a file'
command: 'echo $CIRCLE_SHA1 > .circle-sha'
- restore_cache:
key: windows_bitsrc-ssh-key-v1
- restore_cache:
key: windows_bitsrc-registry-v1
- bit_config:
token: "fake-token"
# E2E test command
e2e_test_cmd:
parameters:
bit_bin:
type: string
default: ""
steps:
- attach_workspace:
at: ./
# - run:
# # there are bugs in version 6.4.1 see https://github.com/teambit/bit/issues/1746
# name: 'update npm to latest version'
# command: 'npm i -g npm@latest'
- bit_global_for_npm
- bit_config
- restore_cache:
key: bitsrc-ssh-key3
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.1.0-v1
- run: npm view @teambit/bit version > ./version.txt
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
# add the id_rsa to ssh_agent to make sure we authenticate with the correct user
# - run: 'chmod 400 ~/.ssh/id_rsa'
# - run: 'ssh-add ~/.ssh/id_rsa'
- run: 'cd bit && mkdir junit'
- run: 'bit config set package-manager.cache /home/circleci/package-manager-cache'
# Make sure when we run bit from e2e tests we run it from the global not from here
# - run: 'rm -rf bit/node_modules/.bin/bit'
- run:
name: 'Run e2e tests'
# I tried really hard to split by timing. but it didn't work.
# CircleCI’s “split by timings” relies on per-testcase durations, but in our suite most time happens in
# before/after hooks, so testcase times are near-zero while the suite shows the full wall time.
# With no meaningful per-test weights, the splitter can’t balance work across 25 machines, leading to uneven distribution
command: 'cd bit && circleci tests glob "$(pwd)/e2e/**/*.e2e*.ts" | circleci tests split --split-by=filesize | xargs npm run mocha-circleci << parameters.bit_bin >>'
environment:
MOCHA_FILE: junit/e2e-test-results.xml
when: always
- store_test_results:
path: bit/junit
- store_artifacts:
path: bit/junit
- store_artifacts:
path: ~/Library/Caches/Bit/logs
# ========================================
# JOBS
# ========================================
jobs:
# ========== Basic Setup Jobs ==========
checkout_code:
<<: *defaults
steps:
- checkout
- run:
name: 'save SHA to a file'
command: 'echo $CIRCLE_SHA1 > .circle-sha'
- persist_to_workspace:
root: /home/circleci
paths:
- bit
set_ssh_key:
<<: *defaults
working_directory: ~/.ssh
steps:
- run: 'echo "-----BEGIN RSA PRIVATE KEY-----" >> ~/.ssh/id_rsa'
- run: 'echo ${testerBitsrcSSHPrivateKey} >> id_rsa'
- run: 'echo "-----END RSA PRIVATE KEY-----" >> ~/.ssh/id_rsa'
- run: 'echo ${testerBitsrcSSHPublicKey} >> id_rsa.pub'
- save_cache:
key: bitsrc-ssh-key3
paths:
- ~/.ssh/id_rsa
- ~/.ssh/id_rsa.pub
set_npm_registries:
<<: *defaults
steps:
# - run:
# name: setting npmjs registry
# command: echo "//registry.npmjs.org/:_authToken=${npmjsRegistryToken}" >> ~/.npmrc
# - run: npm whoami
# prod registry
# - run: npm config set @bit:registry https://node.bit.dev
- run: npm config set @bit:registry https://node-registry.bit.cloud
# - run: echo "//node.bit.dev/:_authToken=$registryProdToken" >> ~/.npmrc
- run: echo "//node-registry.bit.cloud/:_authToken=$registryProdToken" >> ~/.npmrc
# - run: echo "always-auth=true" >> ~/.npmrc
# stage registry
# -
# run: 'npm config set @bit:registry https://node-stg.bit.dev'
# -
# run: 'echo "//node-stg.bit.dev/:_authToken=$registryStgToken" >> ~/.npmrc'
- save_cache:
key: bitsrc-registry10
# key: bitsrc-registry-stg-v2
paths:
- ~/.npmrc
setup_harmony:
resource_class: large
<<: *defaults
environment:
BIT_FEATURES: cloud-importer-v2
steps:
- attach_workspace:
at: ./
- restore_common_caches
- run: echo $BIT_FEATURES
- run: node -v
- run: npm -v
# - run:
# name: 'install husky globally'
# command: 'npm i -g husky'
- install_bvm
- bvm_upgrade
- run: cd bit && bbit init
- run:
name: bbit install
command: cd bit && bbit install
- save_cache:
key: core-aspect-env-v0.1.0-v1
paths:
- /home/circleci/Library/Caches/Bit/capsules/caec9a107
# - run: cd bit && bbit compile
# the following 3 commands should help debugging a random error on Circle: "sh: 1: babel: not found"
# - run: cd bit && ls -l node_modules/@babel
# - run: cd bit && ls -l node_modules/@babel/cli/bin
# - run: cd bit && ls -l node_modules/.bin
- persist_to_workspace:
root: .
paths:
- bit
- .pnpm-store
- store_artifacts:
path: ~/Library/Caches/Bit/logs
- store_artifacts:
path: bit/yarn.lock
# ========== Quality Assurance Jobs ==========
lint:
<<: *defaults
resource_class: medium
steps:
- run:
name: 'save SHA to a file'
command: 'echo $CIRCLE_SHA1 > .circle-sha'
- restore_cache:
keys:
- 'repo-{{ checksum ".circle-sha" }}'
- attach_workspace:
at: ./
- run:
name: 'run OXlint'
command: 'cd bit && npm run oxlint'
- run:
name: 'run ESLint'
command: 'cd bit && node --max-old-space-size=4096 node_modules/eslint/bin/eslint.js "{src,e2e,scopes,components}/**/*.{ts,tsx}" --format junit -o junit/eslint-results.xml'
environment:
NODE_OPTIONS: --max-old-space-size=4096
- store_test_results_and_artifacts:
test_results_path: bit/junit
artifacts_path: bit/junit
check_circular_dependencies:
<<: *defaults
steps:
- attach_workspace:
at: ./
- bit_global_for_npm
- bit_config
- restore_cache:
key: bitsrc-ssh-key3
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.1.0-v1
- run:
name: 'check circular dependencies'
command: 'cd bit && ./scripts/circular-deps-check/ci-check.sh'
check_env_cache_sync:
<<: *defaults
steps:
- attach_workspace:
at: ./
- run:
name: 'check env cache synchronization'
command: 'cd bit && ./scripts/check-env-cache-sync.sh'
generate_and_check_types:
<<: *defaults
steps:
- attach_workspace:
at: ./
- run:
name: 'run TSC'
command: 'cd bit && npm run check-types'
- run:
name: 'make sure there is no "ramda" imported to Harmony'
command: 'cd bit && ./scripts/validate-no-ramda.sh'
- run:
name: 'make sure there is no import aspects from default export'
command: 'cd bit && ./scripts/validate-import-named-aspects.sh'
- run:
name: 'make sure the packages used in legacy are specified in package.json'
command: 'cd bit && node scripts/validate-pkg-exist-in-pkg-json.js'
# ========== Documentation & Notifications ==========
generate_docs:
<<: *defaults
steps:
- attach_workspace:
at: ./
- run:
name: 'generate docs'
command: 'cd bit && npm run doc-gen'
- run:
name: Setup generate doc build number environment variables
command: echo "$CIRCLE_BUILD_NUM" > DOC_GEN_BUILD_NUM.txt
- store_artifacts:
path: bit/dist/cli.md
- persist_to_workspace:
root: .
paths:
- DOC_GEN_BUILD_NUM.txt
# ========== Bit CI Jobs ==========
bit_pr:
# uncomment in case this job fails with "Killed".
# resource_class: 2xlarge
resource_class: xlarge
<<: *defaults
environment:
# BIT_FEATURES: cloud-importer-v2
NODE_OPTIONS: --max-old-space-size=30000
steps:
- attach_workspace:
at: ./
- setup_bit_environment
- run:
name: setting npmjs registry with publishing permission
command: echo "//registry.npmjs.org/:_authToken=${npmjsRegistryToken}" >> ~/.npmrc
- run:
name: 'bit ci pr'
command: 'cd bit && bit ci pr --build'
no_output_timeout: '50m'
environment:
NODE_OPTIONS: --max-old-space-size=30000
- store_artifacts:
path: ~/Library/Caches/Bit/logs
bit_merge:
# uncomment in case this job fails with "Killed".
# resource_class: 2xlarge
resource_class: xlarge
<<: *defaults
environment:
BIT_FEATURES: cloud-importer-v2
NODE_OPTIONS: --max-old-space-size=30000
steps:
- attach_workspace:
at: ./
- setup_bit_environment
- update_ssh_agent
- set_git_credentials
- run:
name: setting npmjs registry with publishing permission
command: echo "//registry.npmjs.org/:_authToken=${npmjsRegistryToken}" >> ~/.npmrc
- run:
name: If no component has changed, exit the job
command: |
if cd bit && bit diff | grep -q "there are no modified components to diff"; then
echo "No changes detected, halting job to prevent further workflow execution."
circleci-agent step halt
fi
- run: cd bit && npm run generate-cli-reference
- run: cd bit && npm run generate-cli-reference-json
- run: cd bit && npm run generate-cli-reference-docs
- run: cd bit && bit status # just to make sure that the new cli-reference.mdx file is valid
- run: cd bit && npm run generate-core-aspects-ids
- run:
name: 'bit ci merge'
command: 'cd bit && bit ci merge --build --auto-merge-resolve manual ${BIT_CI_MERGE_EXTRA_FLAGS}'
# command: 'cd bit && bit ci merge --build --auto-merge-resolve manual --increment-by 3 ${BIT_CI_MERGE_EXTRA_FLAGS}'
no_output_timeout: '50m'
environment:
NODE_OPTIONS: --max-old-space-size=30000
- store_artifacts:
path: ~/Library/Caches/Bit/logs
# ========== Testing Jobs ==========
e2e_test:
<<: *defaults
# changing from medium to large, doesn't affect the performance
# resource_class: large
environment:
BITSRC_ENV: stg
BIT_FEATURES: cloud-importer-v2
parallelism: 25
steps:
- e2e_test_cmd
# makes sure the newly published version doesn't break bit
e2e_test_bbit:
<<: *defaults
environment:
BITSRC_ENV: stg
BIT_FEATURES: cloud-importer-v2
parallelism: 25
steps:
- attach_workspace:
at: ./
- bit_global_for_npm
- restore_common_caches
- install_bvm
- bvm_upgrade
- e2e_test_cmd:
bit_bin: "--bin_bit=bbit"
# setup job: creates cleaned bit bundle and persists to workspace (runs once)
setup_bundle_simulation:
<<: *defaults
environment:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
steps:
- attach_workspace:
at: ./
- set_bit_cloud_registry
- setup_bit_version
- setup_pnpm
- run: mkdir bit-bundle-test
- install_bit_bundle:
directory: "bit-bundle-test"
- run:
name: apply cleanup script to bundled installation with UI deps removal
command: >
cd bit-bundle-test &&
node ../bit/scripts/cleanup-node-modules.js ./node_modules --remove-ui-deps --remove-esm
- persist_to_workspace:
root: .
paths:
- bit-bundle-test
# test job: uses cleaned bit bundle from workspace and runs e2e tests (parallelized)
e2e_test_bundle_simulation:
<<: *defaults
environment:
BITSRC_ENV: stg
BIT_FEATURES: cloud-importer-v2
parallelism: 25
steps:
- attach_workspace:
at: ./
- restore_common_caches
- run:
name: setup cleaned bit binary
command: >
mkdir -p /home/circleci/.npm-global/bin &&
cd bit-bundle-test &&
BIT_BIN=$(find node_modules -name "bit" -type f -path "*/bin/*" | head -1) &&
echo "Found bit binary at: $BIT_BIN" &&
chmod +x $(pwd)/$BIT_BIN &&
ln -sf $(pwd)/$BIT_BIN /home/circleci/.npm-global/bin/bit-cleaned &&
chmod +x /home/circleci/.npm-global/bin/bit-cleaned &&
echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV
- run:
name: verify cleaned binary works
command: source $BASH_ENV && bit-cleaned --version
- e2e_test_cmd:
bit_bin: "--bin_bit=bit-cleaned"
# ========== Utility Jobs ==========
harmony_deploy_approval_job:
<<: *defaults
steps:
- run: 'echo "starting harmony deploy"'
# ========== Bundle Version Jobs ==========
bundle_version_linux:
<<: *defaults
environment:
# do not download chromium when installing puppeteer
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
steps:
- attach_workspace:
at: ./
- set_bit_cloud_registry
- setup_bit_version
- setup_pnpm
- install_bit_bundle
- optimize_node_modules
- run:
name: copy lockfile
command: mkdir lockfile && cp bit-${BIT_VERSION}/pnpm-lock.yaml lockfile
- compress_bit
- run:
name: move to linux folder
command: mkdir linux && mv bit-${BIT_VERSION}.tar.gz linux/bit-${BIT_VERSION}.tar.gz
- run:
name: install bit for Linux arm64
command: >
cd bit-${BIT_VERSION} &&
pnpm install --os=linux --cpu=arm64
- optimize_node_modules:
platform: arm64
- compress_bit
- run:
name: move to linux-arm64 folder
command: mkdir linux-arm64 && mv bit-${BIT_VERSION}.tar.gz linux-arm64/bit-${BIT_VERSION}.tar.gz
- persist_to_workspace:
root: .
paths:
- linux
- linux-arm64
- lockfile
- store_artifacts:
path: linux
- store_artifacts:
path: linux-arm64
- store_artifacts:
path: lockfile
bundle_version_macos:
<<: *defaults
environment:
# do not download chromium when installing puppeteer
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
steps:
- attach_workspace:
at: ./
- set_bit_cloud_registry
- setup_bit_version
- setup_pnpm
- install_bit_bundle:
os: "darwin"
- optimize_node_modules
- compress_bit
- run:
name: move to macos folder
command: mkdir macos && mv bit-${BIT_VERSION}.tar.gz macos/bit-${BIT_VERSION}.tar.gz
- run:
name: install bit for macOS arm64
command: >
cd bit-${BIT_VERSION} &&
pnpm install --os=darwin --cpu=arm64
- optimize_node_modules:
platform: arm64
- compress_bit
- run:
name: move to macos-arm64 folder
command: mkdir macos-arm64 && mv bit-${BIT_VERSION}.tar.gz macos-arm64/bit-${BIT_VERSION}.tar.gz
- persist_to_workspace:
root: .
paths:
- macos
- macos-arm64
- store_artifacts:
path: macos
- store_artifacts:
path: macos-arm64
bundle_version_windows:
<<: *defaults
environment:
# do not download chromium when installing puppeteer
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
steps:
- attach_workspace:
at: ./
- set_bit_cloud_registry
- setup_bit_version
- setup_pnpm
- install_bit_bundle_windows
- optimize_node_modules
- compress_bit
- run:
name: move to windows folder
command: mkdir windows && mv bit-${BIT_VERSION}.tar.gz windows/bit-${BIT_VERSION}.tar.gz
- persist_to_workspace:
root: .
paths:
- windows
- store_artifacts:
path: windows
harmony_publish_to_gcloud:
docker:
- image: bitcli/node-gcloud-sdk
<<: *defaults
steps:
- attach_workspace:
at: ./
- run:
name: Setup bit version environment variables
command: echo "export BIT_VERSION=$(npm view @teambit/bit version)" >> $BASH_ENV && source $BASH_ENV
- run:
name: Configure gcloud auth
command: echo "${COMMAND_GCLOUD_AUTHENTICATE}" > /tmp/gcloud-service-key.json && gcloud auth activate-service-account --key-file=/tmp/gcloud-service-key.json
- run:
name: Upload Lockfile
command: gsutil cp lockfile/pnpm-lock.yaml gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/pnpm-lock.yaml && sha256sum lockfile/pnpm-lock.yaml > checksum.txt && gsutil cp checksum.txt gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/pnpm-lock.checksum.txt
- run:
name: Upload tar file (Linux)
command: gsutil cp linux/bit-${BIT_VERSION}.tar.gz gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-linux-x64.tar.gz && mv linux/bit-${BIT_VERSION}.tar.gz bit-${BIT_VERSION}-linux-x64.tar.gz && sha256sum bit-${BIT_VERSION}-linux-x64.tar.gz > checksum.txt && gsutil cp checksum.txt gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-linux-x64.checksum.txt
- run:
name: Upload tar file (Linux-arm64)
command: gsutil cp linux-arm64/bit-${BIT_VERSION}.tar.gz gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-linux-arm64.tar.gz && mv linux-arm64/bit-${BIT_VERSION}.tar.gz bit-${BIT_VERSION}-linux-arm64.tar.gz && sha256sum bit-${BIT_VERSION}-linux-arm64.tar.gz > checksum.txt && gsutil cp checksum.txt gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-linux-arm64.checksum.txt
- run:
name: Upload tar file (Windows)
command: gsutil cp windows/bit-${BIT_VERSION}.tar.gz gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-win-x64.tar.gz && mv windows/bit-${BIT_VERSION}.tar.gz bit-${BIT_VERSION}-win-x64.tar.gz && sha256sum bit-${BIT_VERSION}-win-x64.tar.gz > checksum.txt && gsutil cp checksum.txt gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-win-x64.checksum.txt
- run:
name: Upload tar file (OSX)
command: gsutil cp macos/bit-${BIT_VERSION}.tar.gz gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-darwin-x64.tar.gz && mv macos/bit-${BIT_VERSION}.tar.gz bit-${BIT_VERSION}-darwin-x64.tar.gz && sha256sum bit-${BIT_VERSION}-darwin-x64.tar.gz > checksum.txt && gsutil cp checksum.txt gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-darwin-x64.checksum.txt
- run:
name: Upload tar file (OSX-arm64)
command: gsutil cp macos-arm64/bit-${BIT_VERSION}.tar.gz gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-darwin-arm64.tar.gz && mv macos-arm64/bit-${BIT_VERSION}.tar.gz bit-${BIT_VERSION}-darwin-arm64.tar.gz && sha256sum bit-${BIT_VERSION}-darwin-arm64.tar.gz > checksum.txt && gsutil cp checksum.txt gs://bvm.bit.dev/bit/versions/${BIT_VERSION}/bit-${BIT_VERSION}-darwin-arm64.checksum.txt
- run: cd bit && node scripts/update-bit-gcp-index.js
- run:
name: Update index.json
command: gsutil cp bit/index.json gs://bvm.bit.dev/bit/index.json
- run:
name: clear index.json cache
command: gsutil setmeta -h "Cache-Control:no-cache" gs://bvm.bit.dev/bit/index.json
- store_artifacts:
path: bit/index.json
# ========== Docker Jobs ==========
docker_build_node_22:
machine:
image: ubuntu-2004:202111-02
steps:
- attach_workspace:
at: ./
- docker_build_and_push:
docker_build_base_image_arg_value: "node:22.14.0"
docker_tag_suffix: "-node-22.14.0"
docker_non_root_build_node_22:
machine:
image: ubuntu-2004:202111-02
steps:
- attach_workspace:
at: ./
- docker_build_and_push:
docker_build_base_image_arg_value: "node:22.14.0"
image_name: "bitcli/bit-non-root"
docker_file_name: "Dockerfile-bit-non-root"
docker_tag_suffix: "-node-22.14.0"
docker_build_alpine:
machine:
image: ubuntu-2004:202111-02
steps:
- attach_workspace:
at: ./
- docker_build_and_push:
docker_build_base_image_arg_value: "node:22.14.0-alpine"
# image_name: "bitcli/bit-alpine"
docker_file_name: "Dockerfile-bit-alpine"
docker_tag_suffix: "-alpine-node-22.14.0"