Skip to content

Commit 5c15972

Browse files
Merge pull request #185 from splitio/FME-17145
Update Harness CI
2 parents 4b5b9c2 + 697f2d5 commit 5c15972

5 files changed

Lines changed: 149 additions & 309 deletions

File tree

.harness/orgs/PROD/projects/Harness_Split/pipelines/javascript_browser_client_ci.yaml

Lines changed: 70 additions & 247 deletions
Original file line numberDiff line numberDiff line change
@@ -3,302 +3,125 @@ pipeline:
33
identifier: javascript_browser_client_ci
44
projectIdentifier: Harness_Split
55
orgIdentifier: PROD
6-
tags:
7-
fme-sdk: ""
8-
team: SDK
6+
tags: {}
97
properties:
108
ci:
119
codebase:
1210
connectorRef: fmegithubharnessgitops
1311
repoName: javascript-browser-client
1412
build: <+input>
15-
depth: 0
1613
stages:
1714
- stage:
18-
name: Build and Test
19-
identifier: Build_and_Test
15+
name: Check-Test-Build-Upload
16+
identifier: Check_Test_Build_Upload
2017
description: ""
2118
type: CI
2219
spec:
2320
cloneCodebase: true
2421
caching:
2522
enabled: true
2623
override: true
27-
platform:
28-
os: Linux
29-
arch: Amd64
30-
runtime:
31-
type: Cloud
32-
spec:
33-
size: flex
24+
paths: []
25+
buildIntelligence:
26+
enabled: false
3427
execution:
3528
steps:
3629
- step:
3730
type: Run
38-
name: Install Node
39-
identifier: Install_Node
40-
spec:
41-
shell: Bash
42-
command: |-
43-
curl https://mise.run | sh
44-
export PATH="$HOME/.local/bin:$PATH"
45-
mise use --global node@lts
46-
node --version
47-
npm --version
48-
- step:
49-
type: Run
50-
name: Install Chrome
51-
identifier: Install_Chrome
52-
spec:
53-
shell: Bash
54-
# puppeteer e2e tests require a real Chrome binary; version pinned to match GHA (125)
55-
command: |-
56-
export PUPPETEER_SKIP_DOWNLOAD=true
57-
curl -fsSL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /tmp/chrome.deb
58-
apt-get update -qq && apt-get install -y -qq /tmp/chrome.deb || true
59-
# Fallback: install via chromium if exact version not available
60-
which google-chrome-stable || apt-get install -y -qq chromium-browser
61-
CHROME_BIN=$(which google-chrome-stable || which chromium-browser || which chromium)
62-
echo "CHROME_BIN=$CHROME_BIN"
63-
export CHROME_BIN
64-
- step:
65-
type: Run
66-
name: Install Dependencies
67-
identifier: Install_Dependencies
68-
spec:
69-
shell: Bash
70-
command: |-
71-
export PATH="$HOME/.local/bin:$PATH"
72-
eval "$(mise activate bash)"
73-
export PUPPETEER_SKIP_DOWNLOAD=true
74-
npm ci
75-
- step:
76-
type: Run
77-
name: Check TypeScript Declarations
78-
identifier: Check_TypeScript_Declarations
79-
spec:
80-
shell: Bash
81-
command: |-
82-
export PATH="$HOME/.local/bin:$PATH"
83-
eval "$(mise activate bash)"
84-
npm run test-ts-decls
85-
- step:
86-
type: Run
87-
name: Check Lint and Types
88-
identifier: Check_Lint_and_Types
89-
spec:
90-
shell: Bash
91-
command: |-
92-
export PATH="$HOME/.local/bin:$PATH"
93-
eval "$(mise activate bash)"
94-
npm run check
95-
- step:
96-
type: Run
97-
name: Run Tests
98-
identifier: Run_Tests
99-
spec:
100-
shell: Bash
101-
command: |-
102-
export PATH="$HOME/.local/bin:$PATH"
103-
eval "$(mise activate bash)"
104-
CHROME_BIN=$(which google-chrome-stable || which chromium-browser || which chromium)
105-
export CHROME_BIN
106-
export PUPPETEER_SKIP_DOWNLOAD=true
107-
npm run test
108-
- step:
109-
type: Run
110-
name: Build
111-
identifier: Build
112-
spec:
113-
shell: Bash
114-
command: |-
115-
export PATH="$HOME/.local/bin:$PATH"
116-
eval "$(mise activate bash)"
117-
BUILD_BRANCH=<+codebase.branch> npm run build
118-
- step:
119-
type: Run
120-
name: SonarQube Scan
121-
identifier: SonarQube_Scan
122-
when:
123-
stageStatus: Success
124-
spec:
125-
shell: Sh
126-
command: |-
127-
export SONAR_SCANNER_VERSION=5.0.1.3006
128-
curl -sSLo sonar-scanner.zip \
129-
"https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip"
130-
unzip -q sonar-scanner.zip
131-
export PATH="$PWD/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin:$PATH"
132-
apt-get install -y openjdk-17-jdk -qq
133-
134-
VERSION=$(node -e "console.log(require('./package.json').version)")
135-
136-
if [ "<+codebase.build.type>" = "PR" ]; then
137-
sonar-scanner \
138-
-Dsonar.projectKey=javascript-browser-client \
139-
-Dsonar.projectName=javascript-browser-client \
140-
-Dsonar.sources=src \
141-
-Dsonar.host.url=https://sonar.harness.io \
142-
-Dsonar.token=<+secrets.getValue("sonarqube-token")> \
143-
-Dsonar.exclusions="**/node_modules/**,**/umd/**,**/cjs/**,**/esm/**" \
144-
-Dsonar.projectVersion="${VERSION}" \
145-
-Dsonar.pullrequest.key=<+codebase.prNumber> \
146-
-Dsonar.pullrequest.branch=<+codebase.branch> \
147-
-Dsonar.pullrequest.base=<+codebase.targetBranch>
148-
else
149-
sonar-scanner \
150-
-Dsonar.projectKey=javascript-browser-client \
151-
-Dsonar.projectName=javascript-browser-client \
152-
-Dsonar.sources=src \
153-
-Dsonar.host.url=https://sonar.harness.io \
154-
-Dsonar.token=<+secrets.getValue("sonarqube-token")> \
155-
-Dsonar.exclusions="**/node_modules/**,**/umd/**,**/cjs/**,**/esm/**" \
156-
-Dsonar.projectVersion="${VERSION}" \
157-
-Dsonar.branch.name=<+codebase.branch>
158-
fi
159-
- step:
160-
type: Run
161-
name: Post Quality Gate
162-
identifier: Post_Quality_Gate
163-
when:
164-
stageStatus: Success
31+
name: npm ci
32+
identifier: npm_ci
16533
spec:
34+
connectorRef: dockerhub
35+
image: node:lts
16636
shell: Bash
167-
command: |-
168-
#!/bin/bash
169-
set -e
170-
171-
SONAR_TOKEN="<+secrets.getValue("sonarqube-token")>"
172-
SONAR_URL="https://sonar.harness.io"
173-
SONAR_PROJECT_KEY="javascript-browser-client"
174-
GITHUB_TOKEN="<+secrets.getValue("github-devops-token")>"
175-
GITHUB_REPO="javascript-browser-client"
176-
COMMIT_SHA="<+codebase.commitSha>"
177-
178-
STATUS_JSON=$(curl -sf \
179-
-H "Authorization: Bearer ${SONAR_TOKEN}" \
180-
"${SONAR_URL}/api/qualitygates/project_status?projectKey=${SONAR_PROJECT_KEY}")
181-
182-
QG_STATUS=$(echo "$STATUS_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['projectStatus']['status'])")
183-
184-
case "$QG_STATUS" in
185-
OK) GH_STATE="success"; DESCRIPTION="Quality gate passed" ;;
186-
ERROR) GH_STATE="failure"; DESCRIPTION="Quality gate failed" ;;
187-
WARN) GH_STATE="success"; DESCRIPTION="Quality gate passed with warnings" ;;
188-
*) GH_STATE="pending"; DESCRIPTION="Quality gate status unknown" ;;
189-
esac
190-
191-
TARGET_URL="${SONAR_URL}/dashboard?id=${SONAR_PROJECT_KEY}"
192-
193-
curl -sf -X POST \
194-
-H "Authorization: token ${GITHUB_TOKEN}" \
195-
-H "Accept: application/vnd.github.v3+json" \
196-
-H "Content-Type: application/json" \
197-
-d "{\"state\":\"${GH_STATE}\",\"description\":\"${DESCRIPTION}\",\"context\":\"sonarqube/quality-gate\",\"target_url\":\"${TARGET_URL}\"}" \
198-
"https://api.github.com/repos/splitio/${GITHUB_REPO}/statuses/${COMMIT_SHA}"
199-
200-
echo "Posted SonarQube quality gate status: ${GH_STATE}"
201-
- stage:
202-
name: Deploy to S3 Stage
203-
identifier: Deploy_to_S3_Stage
204-
type: CI
205-
spec:
206-
cloneCodebase: true
207-
buildIntelligence:
208-
enabled: false
209-
execution:
210-
steps:
37+
command: npm ci
38+
envVariables:
39+
PUPPETEER_SKIP_DOWNLOAD: "true"
21140
- step:
21241
type: Run
213-
name: Build UMD Assets
214-
identifier: Build_UMD_Assets
42+
name: npm run test-ts-decls
43+
identifier: npm_run_test_ts_decls
21544
spec:
21645
connectorRef: dockerhub
21746
image: node:lts
21847
shell: Bash
219-
command: |-
220-
export PUPPETEER_SKIP_DOWNLOAD=true
221-
npm ci
222-
BUILD_BRANCH=<+codebase.branch> npm run build:umd
48+
command: npm run test-ts-decls
49+
resources:
50+
limits:
51+
memory: 2Gi
52+
cpu: "1"
22353
- step:
22454
type: Run
225-
name: Deploy to S3 Stage
226-
identifier: Deploy_to_S3_Stage
55+
name: npm run check
56+
identifier: npm_run_check
22757
spec:
22858
connectorRef: dockerhub
229-
image: amazon/aws-cli:2.31.5
59+
image: node:lts
23060
shell: Bash
231-
command: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS
232-
envVariables:
233-
BUCKET: split-public-stage
234-
SOURCE_DIR: ./umd
235-
DEST_DIR: sdk
236-
ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public
237-
AWS_DEFAULT_REGION: us-east-1
238-
infrastructure:
239-
type: KubernetesDirect
240-
spec:
241-
connectorRef: use1stage1cd
242-
namespace: harness-delegate
243-
# VERIFY: service account needs IRSA binding to the equivalent of arn:aws:iam::079419646996:role/gha-public-assets-role
244-
serviceAccountName: use1-stage-1-javascript-browser-client-s3
245-
automountServiceAccountToken: false
246-
nodeSelector: {}
247-
os: Linux
248-
delegateSelectors:
249-
- use1-stage-1-cd
250-
when:
251-
pipelineStatus: Success
252-
condition: <+trigger.event> == "PUSH" && <+codebase.branch> == "development"
253-
- stage:
254-
name: Deploy to S3 Prod
255-
identifier: Deploy_to_S3_Prod
256-
type: CI
257-
spec:
258-
cloneCodebase: true
259-
buildIntelligence:
260-
enabled: false
261-
execution:
262-
steps:
61+
command: npm run check
26362
- step:
26463
type: Run
265-
name: Build UMD Assets
266-
identifier: Build_UMD_Assets
64+
name: npm run test
65+
identifier: npm_run_test
26766
spec:
26867
connectorRef: dockerhub
26968
image: node:lts
27069
shell: Bash
27170
command: |-
272-
export PUPPETEER_SKIP_DOWNLOAD=true
273-
npm ci
274-
BUILD_BRANCH=<+codebase.branch> npm run build:umd
71+
apt-get update -qq && apt-get install -y -qq chromium
72+
export CHROME_BIN=$(command -v chromium)
73+
"$CHROME_BIN" --version
74+
npm run test
75+
resources:
76+
limits:
77+
memory: 8Gi
78+
cpu: "4"
27579
- step:
27680
type: Run
277-
name: Deploy to S3 Prod
278-
identifier: Deploy_to_S3_Prod
81+
name: npm run build
82+
identifier: npm_run_build
27983
spec:
28084
connectorRef: dockerhub
281-
image: amazon/aws-cli:2.31.5
85+
image: node:lts
28286
shell: Bash
283-
command: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS
284-
envVariables:
285-
BUCKET: split-public
286-
SOURCE_DIR: ./umd
287-
DEST_DIR: sdk
288-
ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public
289-
AWS_DEFAULT_REGION: us-east-1
87+
command: BUILD_BRANCH=<+codebase.branch> npm run build
88+
- parallel:
89+
- step:
90+
type: Run
91+
name: upload dev assets to CDN
92+
identifier: upload_dev_assets_to_CDN
93+
spec:
94+
connectorRef: dockerhub
95+
image: amazon/aws-cli:2.31.5
96+
shell: Bash
97+
command: aws s3 sync ./umd s3://split-public-stage/sdk --acl public-read --follow-symlinks --cache-control max-age=31536000,public
98+
envVariables:
99+
AWS_DEFAULT_REGION: us-east-1
100+
when:
101+
stageStatus: Success
102+
condition: <+trigger.event> == "PUSH" && <+trigger.branch> == "development"
103+
- step:
104+
type: Run
105+
name: upload prod assets to CDN
106+
identifier: upload_prod_assets_to_CDN
107+
spec:
108+
connectorRef: dockerhub
109+
image: amazon/aws-cli:2.31.5
110+
shell: Bash
111+
command: aws s3 sync ./umd s3://split-public/sdk --acl public-read --follow-symlinks --cache-control max-age=31536000,public
112+
envVariables:
113+
AWS_DEFAULT_REGION: us-east-1
114+
when:
115+
stageStatus: Success
116+
condition: <+trigger.event> == "PUSH" && <+trigger.branch> == "main"
290117
infrastructure:
291118
type: KubernetesDirect
292119
spec:
293-
connectorRef: use1prod1cd
120+
connectorRef: "<+codebase.branch == \"main\" ? \"use1prod1cd\" : \"use1stage1cd\">"
294121
namespace: harness-delegate
295-
# VERIFY: service account needs IRSA binding to the equivalent of arn:aws:iam::825951051969:role/gha-public-assets-role
296-
serviceAccountName: use1-prod-1-javascript-browser-client-s3
122+
serviceAccountName: "<+codebase.branch == \"main\" ? \"use1-prod-1-public-assets\" : \"use1-stage-1-public-assets\">"
297123
automountServiceAccountToken: false
298124
nodeSelector: {}
299125
os: Linux
300126
delegateSelectors:
301-
- use1-prod-1-cd
302-
when:
303-
pipelineStatus: Success
304-
condition: <+trigger.event> == "PUSH" && <+codebase.branch> == "main"
127+
- "<+codebase.branch == \"main\" ? \"use1-prod-1-cd\" : \"use1-stage-1-cd\">"

0 commit comments

Comments
 (0)