Skip to content

Commit c1294a6

Browse files
committed
Added harness ci
1 parent b603ab2 commit c1294a6

3 files changed

Lines changed: 236 additions & 0 deletions

File tree

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
pipeline:
2+
name: javascript-browser-client-ci
3+
identifier: javascript_browser_client_ci
4+
projectIdentifier: Harness_Split
5+
orgIdentifier: PROD
6+
tags:
7+
fme-sdk: ""
8+
team: SDK
9+
properties:
10+
ci:
11+
codebase:
12+
connectorRef: fmegithubharnessgitops
13+
repoName: javascript-browser-client
14+
build: <+input>
15+
depth: 0
16+
stages:
17+
- stage:
18+
name: Build and Test
19+
identifier: Build_and_Test
20+
description: ""
21+
type: CI
22+
spec:
23+
cloneCodebase: true
24+
caching:
25+
enabled: true
26+
override: true
27+
platform:
28+
os: Linux
29+
arch: Amd64
30+
runtime:
31+
type: Cloud
32+
spec:
33+
size: flex
34+
execution:
35+
steps:
36+
- step:
37+
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
165+
spec:
166+
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+
# VERIFY: S3 upload steps require an AWS connector with write access to split-public-stage / split-public buckets.
202+
# The GHA workflow used OIDC role assumption (arn:aws:iam::<account_id>:role/gha-public-assets-role).
203+
# Check with the team whether an equivalent Harness AWS connector exists, or if S3 upload
204+
# should remain in GitHub Actions / move to a separate CD pipeline.
205+
# Once confirmed, add steps here:
206+
#
207+
# On push to development → upload umd/ to s3://split-public-stage/sdk/
208+
# On push to main → upload umd/ to s3://split-public/sdk/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
inputSet:
2+
identifier: javascript_browser_client_ci_pr
3+
name: javascript-browser-client-ci-pr
4+
orgIdentifier: PROD
5+
projectIdentifier: Harness_Split
6+
pipeline:
7+
identifier: javascript_browser_client_ci
8+
properties:
9+
ci:
10+
codebase:
11+
build:
12+
type: PR
13+
spec:
14+
number: <+trigger.prNumber>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
inputSet:
2+
identifier: javascript_browser_client_ci_push
3+
name: javascript-browser-client-ci-push
4+
orgIdentifier: PROD
5+
projectIdentifier: Harness_Split
6+
pipeline:
7+
identifier: javascript_browser_client_ci
8+
properties:
9+
ci:
10+
codebase:
11+
build:
12+
type: branch
13+
spec:
14+
branch: <+trigger.branch>

0 commit comments

Comments
 (0)