Skip to content

Commit d4d7519

Browse files
author
arthosofteq
authored
Merge pull request #2653 from RedisInsight/feature/RI-4439-improve-ci-builds
Feature/ri 4439 improve ci builds
2 parents cb71774 + 2ed7606 commit d4d7519

File tree

2 files changed

+217
-17
lines changed

2 files changed

+217
-17
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const whitelist = {
2+
'linux': {
3+
'appimage': 1,
4+
'appimage:x64': 1,
5+
'deb': 1,
6+
'deb:x64': 1,
7+
'rpm': 1,
8+
'rpm:x64': 1,
9+
'snap': 1,
10+
'snap:x64': 1,
11+
},
12+
'mac': {
13+
'dmg': 1,
14+
'dmg:x64': 1,
15+
'dmg:arm64': 1,
16+
},
17+
'windows': {
18+
'nsis': 1,
19+
'nsis:x64': 1,
20+
}
21+
};
22+
23+
(() => {
24+
const os = process.argv[2];
25+
const targets = process.argv[3]?.split(" ") || [];
26+
27+
if (targets.length) {
28+
targets.forEach((target) => {
29+
if (!whitelist[os]?.[target]) {
30+
throw new Error(`Target ${target} for ${os} is not allowed. \nAllowed targets: ${Object.keys(whitelist[os] || {}).join(',')}`);
31+
}
32+
})
33+
}
34+
})()

.circleci/config.yml

Lines changed: 183 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ aliases:
164164
key: v1-ui-deps-{{ checksum "yarn.lock" }}
165165
api-deps-cache-key: &apiDepsCacheKey
166166
key: v1-ui-deps-{{ checksum "redisinsight/api/yarn.lock" }}
167+
manual-build-conditions: &manual-build-conditions
168+
or:
169+
- << pipeline.parameters.linux >>
170+
- << pipeline.parameters.mac >>
171+
- << pipeline.parameters.windows >>
172+
ignore-for-manual-build: &ignore-for-manual-build
173+
when:
174+
not: *manual-build-conditions
167175

168176
orbs:
169177
win: circleci/[email protected]
@@ -179,6 +187,17 @@ executors:
179187
image: ubuntu-2004:2023.04.2
180188
docker_layer_caching: true
181189

190+
parameters:
191+
linux:
192+
type: string
193+
default: &ignore ""
194+
mac:
195+
type: string
196+
default: *ignore
197+
windows:
198+
type: string
199+
default: *ignore
200+
182201
jobs:
183202
# Test jobs
184203
unit-tests-ui:
@@ -479,6 +498,21 @@ jobs:
479498
destination: tests/e2e/report
480499

481500
# Build jobs
501+
manual-build-validate:
502+
parameters:
503+
os:
504+
type: string
505+
default: ""
506+
target:
507+
type: string
508+
default: ""
509+
docker:
510+
- image: cimg/node:18.15.0
511+
steps:
512+
- checkout
513+
- run:
514+
command: |
515+
node .circleci/build/manual-build-validate.js << parameters.os >> << parameters.target >>
482516
setup-sign-certificates:
483517
executor: linux-executor
484518
steps:
@@ -533,6 +567,10 @@ jobs:
533567
description: Build RedisStack archives
534568
type: boolean
535569
default: true
570+
target:
571+
description: Build target
572+
type: string
573+
default: ""
536574
steps:
537575
- checkout
538576
- node/install:
@@ -580,11 +618,11 @@ jobs:
580618
export RI_CLOUD_CAPI_URL=$RI_CLOUD_CAPI_URL_STAGE
581619
582620
if [ << parameters.env >> == 'stage' ]; then
583-
UPGRADES_LINK=$UPGRADES_LINK_STAGE SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY_STAGE yarn package:stage
621+
UPGRADES_LINK=$UPGRADES_LINK_STAGE SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY_STAGE yarn package:stage --linux << parameters.target >>
584622
exit 0;
585623
fi
586624
587-
UPGRADES_LINK='' SEGMENT_WRITE_KEY='' yarn package:stage
625+
UPGRADES_LINK='' SEGMENT_WRITE_KEY='' yarn package:stage --linux << parameters.target >>
588626
- when:
589627
condition:
590628
equal: [ true, << parameters.redisstack >> ]
@@ -613,7 +651,6 @@ jobs:
613651
- release/RedisInsight*.snap
614652
- release/*-linux.yml
615653
- release/redisstack
616-
617654
macosx:
618655
macos:
619656
xcode: 14.2.0
@@ -624,6 +661,14 @@ jobs:
624661
type: enum
625662
default: stage
626663
enum: ['stage', 'prod', 'dev']
664+
redisstack:
665+
description: Build RedisStack archives
666+
type: boolean
667+
default: true
668+
target:
669+
description: Build target
670+
type: string
671+
default: ""
627672
steps:
628673
- checkout
629674
- node/install:
@@ -665,24 +710,34 @@ jobs:
665710
export RI_CLOUD_IDP_GH_ID=$RI_CLOUD_IDP_GH_ID_STAGE
666711
export RI_CLOUD_API_URL=$RI_CLOUD_API_URL_STAGE
667712
export RI_CLOUD_CAPI_URL=$RI_CLOUD_CAPI_URL_STAGE
713+
export UPGRADES_LINK=''
714+
export SEGMENT_WRITE_KEY=''
668715
669716
if [ << parameters.env >> == 'stage' ]; then
670-
UPGRADES_LINK=$UPGRADES_LINK_STAGE SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY_STAGE yarn package:stage && yarn package:mas
717+
export UPGRADES_LINK=$UPGRADES_LINK_STAGE
718+
export SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY_STAGE
719+
fi
720+
721+
# handle manual builds
722+
if [ << parameters.target >> ]; then
723+
yarn package:stage --mac << parameters.target >>
671724
rm -rf release/mac
672-
mv release/mas-universal/RedisInsight-mac-universal-mas.pkg release/RedisInsight-mac-universal-mas.pkg
673725
exit 0;
674726
fi
675727
676-
UPGRADES_LINK='' SEGMENT_WRITE_KEY='' yarn package:stage && yarn package:mas
728+
yarn package:stage && yarn package:mas
677729
rm -rf release/mac
678730
mv release/mas-universal/RedisInsight-mac-universal-mas.pkg release/RedisInsight-mac-universal-mas.pkg
679731
no_output_timeout: 60m
680-
681-
- run:
682-
name: Repack dmg to tar
683-
command: |
684-
ARCH=x64 ./.circleci/redisstack/dmg.repack.sh
685-
ARCH=arm64 ./.circleci/redisstack/dmg.repack.sh
732+
- when:
733+
condition:
734+
equal: [ true, << parameters.redisstack >> ]
735+
steps:
736+
- run:
737+
name: Repack dmg to tar
738+
command: |
739+
ARCH=x64 ./.circleci/redisstack/dmg.repack.sh
740+
ARCH=arm64 ./.circleci/redisstack/dmg.repack.sh
686741
- persist_to_workspace:
687742
root: .
688743
paths:
@@ -701,6 +756,10 @@ jobs:
701756
type: enum
702757
default: stage
703758
enum: ['stage', 'prod', 'dev']
759+
target:
760+
description: Build target
761+
type: string
762+
default: ""
704763
steps:
705764
- checkout
706765
- attach_workspace:
@@ -733,12 +792,11 @@ jobs:
733792
export RI_CLOUD_CAPI_URL=$RI_CLOUD_CAPI_URL_STAGE
734793
735794
if [ << parameters.env >> == 'stage' ]; then
736-
UPGRADES_LINK=$UPGRADES_LINK_STAGE SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY_STAGE yarn package:stage
737-
rm -rf release/win-unpacked
738-
exit 0;
795+
UPGRADES_LINK=$UPGRADES_LINK_STAGE SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY_STAGE yarn package:stage --win << parameters.target >>
796+
else
797+
UPGRADES_LINK='' SEGMENT_WRITE_KEY='' yarn package:stage --win << parameters.target >>
739798
fi
740799
741-
UPGRADES_LINK='' SEGMENT_WRITE_KEY='' yarn package:stage
742800
rm -rf release/win-unpacked
743801
shell: bash.exe
744802
no_output_timeout: 20m
@@ -780,7 +838,6 @@ jobs:
780838
- <<: *urlScan
781839
- <<: *validate
782840
- <<: *virustotalReport
783-
784841
virustotal-report:
785842
executor: linux-executor
786843
steps:
@@ -879,6 +936,15 @@ jobs:
879936
applicationVersion=$(jq -r '.version' redisinsight/package.json)
880937
881938
aws s3 cp release/ s3://${AWS_BUCKET_NAME_TEST}/public/rs-ri-builds/${CIRCLE_BUILD_NUM} --recursive
939+
release-aws-manual:
940+
executor: linux-executor
941+
steps:
942+
- checkout
943+
- attach_workspace:
944+
at: .
945+
- run:
946+
command: |
947+
aws s3 cp release/ s3://${AWS_BUCKET_NAME_TEST}/public/manual-builds/${CIRCLE_BUILD_NUM} --recursive --exclude "*" --include "RedisInsight*"
882948
883949
release-aws-private:
884950
executor: linux-executor
@@ -1035,9 +1101,11 @@ jobs:
10351101
10361102
done
10371103
1104+
10381105
workflows:
10391106
# FE Unit tests for "fe/feature" or "fe/bugfix" branches only
10401107
frontend-tests:
1108+
<<: *ignore-for-manual-build
10411109
jobs:
10421110
- unit-tests-ui:
10431111
name: UTest - UI
@@ -1048,6 +1116,7 @@ workflows:
10481116
- /^fe/bugfix.*/
10491117
# BE Unit + Integration (limited RTEs) tests for "be/feature" or "be/bugfix" branches only
10501118
backend-tests:
1119+
<<: *ignore-for-manual-build
10511120
jobs:
10521121
- unit-tests-api:
10531122
name: UTest - API
@@ -1104,6 +1173,7 @@ workflows:
11041173
- Build app - Linux (stage)
11051174
# Workflow for feature, bugfix, main branches
11061175
feature-main-branch:
1176+
<<: *ignore-for-manual-build
11071177
jobs:
11081178
# Approve to run all (unit, integration, e2e) tests
11091179
- approve:
@@ -1161,8 +1231,103 @@ workflows:
11611231
only:
11621232
- /^e2e/feature.*/
11631233
- /^e2e/bugfix.*/
1234+
# Manual builds using web UI
1235+
manual-build-linux:
1236+
when: << pipeline.parameters.linux >>
1237+
jobs:
1238+
- manual-build-validate:
1239+
name: Validating build parameters
1240+
os: linux
1241+
target: << pipeline.parameters.linux >>
1242+
- setup-sign-certificates:
1243+
name: Setup sign certificates (stage)
1244+
requires:
1245+
- Validating build parameters
1246+
- setup-build:
1247+
name: Setup build (stage)
1248+
env: stage
1249+
requires:
1250+
- Setup sign certificates (stage)
1251+
- linux:
1252+
name: Build app - Linux (stage)
1253+
env: stage
1254+
target: << pipeline.parameters.linux >>
1255+
redisstack: false
1256+
requires:
1257+
- Setup build (stage)
1258+
- store-build-artifacts:
1259+
name: Store build artifacts (stage)
1260+
requires:
1261+
- Build app - Linux (stage)
1262+
- release-aws-manual:
1263+
name: Release AWS stage
1264+
requires:
1265+
- Build app - Linux (stage)
1266+
manual-build-mac:
1267+
when: << pipeline.parameters.mac >>
1268+
jobs:
1269+
- manual-build-validate:
1270+
name: Validating build parameters
1271+
os: mac
1272+
target: << pipeline.parameters.mac >>
1273+
- setup-sign-certificates:
1274+
name: Setup sign certificates (stage)
1275+
requires:
1276+
- Validating build parameters
1277+
- setup-build:
1278+
name: Setup build (stage)
1279+
env: stage
1280+
requires:
1281+
- Setup sign certificates (stage)
1282+
- macosx:
1283+
name: Build app - MacOS (stage)
1284+
env: stage
1285+
redisstack: false
1286+
target: << pipeline.parameters.mac >>
1287+
requires:
1288+
- Setup build (stage)
1289+
- store-build-artifacts:
1290+
name: Store build artifacts (stage)
1291+
requires:
1292+
- Build app - MacOS (stage)
1293+
- release-aws-manual:
1294+
name: Release AWS stage
1295+
requires:
1296+
- Build app - MacOS (stage)
1297+
manual-build-windows:
1298+
when: << pipeline.parameters.windows >>
1299+
jobs:
1300+
- manual-build-validate:
1301+
name: Validating build parameters
1302+
os: windows
1303+
target: << pipeline.parameters.windows >>
1304+
- setup-sign-certificates:
1305+
name: Setup sign certificates (stage)
1306+
requires:
1307+
- Validating build parameters
1308+
- setup-build:
1309+
name: Setup build (stage)
1310+
env: stage
1311+
requires:
1312+
- Setup sign certificates (stage)
1313+
- windows:
1314+
name: Build app - Windows (stage)
1315+
env: stage
1316+
target: << pipeline.parameters.windows >>
1317+
requires:
1318+
- Setup build (stage)
1319+
- store-build-artifacts:
1320+
name: Store build artifacts (stage)
1321+
requires:
1322+
- Build app - Windows (stage)
1323+
- release-aws-manual:
1324+
name: Release AWS stage
1325+
requires:
1326+
- Build app - Windows (stage)
1327+
11641328
# build electron app (dev) from "build" branches
11651329
build:
1330+
<<: *ignore-for-manual-build
11661331
jobs:
11671332
- setup-sign-certificates:
11681333
name: Setup sign certificates (dev)
@@ -1203,6 +1368,7 @@ workflows:
12031368

12041369
# Main workflow for release/* and latest branches only
12051370
release:
1371+
<<: *ignore-for-manual-build
12061372
jobs:
12071373
# unit tests (on any commit)
12081374
- unit-tests-ui:

0 commit comments

Comments
 (0)