Skip to content

Commit 013ed1d

Browse files
authored
Merge pull request #116 from splitio/harness-pipeline-ci-2026-07-28
ci: add Harness CI pipeline for react-native-client
2 parents bb49045 + 75bf32b commit 013ed1d

6 files changed

Lines changed: 172 additions & 121 deletions

File tree

‎.github/CODEOWNERS‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎.github/pull_request_template.md‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 68 deletions
This file was deleted.

‎.github/workflows/update-notice-year.yml‎

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
pipeline:
2+
name: react-native-client-repo
3+
identifier: reactnativeclient
4+
projectIdentifier: Harness_Split
5+
orgIdentifier: PROD
6+
tags: {}
7+
properties:
8+
ci:
9+
codebase:
10+
connectorRef: fmegithubharnessgitops
11+
repoName: react-native-client
12+
build:
13+
type: branch
14+
spec:
15+
branch: <+input>
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@<+matrix.nodeVersion>
46+
node --version
47+
npm --version
48+
- step:
49+
type: Run
50+
name: Install Dependencies
51+
identifier: Install_Dependencies
52+
spec:
53+
shell: Bash
54+
command: |-
55+
export PATH="$HOME/.local/bin:$PATH"
56+
eval "$(mise activate bash)"
57+
npm ci
58+
- step:
59+
type: Run
60+
name: Check
61+
identifier: Check
62+
spec:
63+
shell: Bash
64+
command: |-
65+
export PATH="$HOME/.local/bin:$PATH"
66+
eval "$(mise activate bash)"
67+
npm run check
68+
- step:
69+
type: Run
70+
name: Run Tests
71+
identifier: Run_Tests
72+
spec:
73+
shell: Bash
74+
command: |-
75+
export PATH="$HOME/.local/bin:$PATH"
76+
eval "$(mise activate bash)"
77+
npm run test -- --coverage
78+
- step:
79+
type: Run
80+
name: Build
81+
identifier: Build
82+
spec:
83+
shell: Bash
84+
command: |-
85+
export PATH="$HOME/.local/bin:$PATH"
86+
eval "$(mise activate bash)"
87+
npm run build
88+
- step:
89+
type: Run
90+
name: SonarQube Scan
91+
identifier: SonarQube_Scan
92+
when:
93+
stageStatus: Success
94+
condition: <+matrix.nodeVersion> == "lts"
95+
spec:
96+
shell: Sh
97+
command: |-
98+
export SONAR_SCANNER_VERSION=5.0.1.3006
99+
curl -sSLo sonar-scanner.zip \
100+
"https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip"
101+
unzip -q sonar-scanner.zip
102+
export PATH="$PWD/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin:$PATH"
103+
apt-get install -y openjdk-17-jdk -qq
104+
sonar-scanner \
105+
-Dsonar.projectKey=react-native-client \
106+
-Dsonar.sources=src \
107+
-Dsonar.test.inclusions="**/__tests__/**" \
108+
-Dsonar.host.url=https://sonar.harness.io \
109+
-Dsonar.token=<+secrets.getValue("sonarqube-token")> \
110+
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
111+
-Dsonar.exclusions="**/node_modules/**,**/.git/**"
112+
- step:
113+
type: Run
114+
name: Post Quality Gate
115+
identifier: Post_Quality_Gate
116+
when:
117+
stageStatus: Success
118+
condition: <+matrix.nodeVersion> == "lts"
119+
spec:
120+
shell: Bash
121+
command: |-
122+
#!/bin/bash
123+
set -e
124+
125+
SONAR_TOKEN="<+secrets.getValue("sonarqube-token")>"
126+
SONAR_URL="https://sonar.harness.io"
127+
SONAR_PROJECT_KEY="react-native-client"
128+
GITHUB_TOKEN="<+secrets.getValue("github-devops-token")>"
129+
GITHUB_REPO="react-native-client"
130+
COMMIT_SHA="<+codebase.commitSha>"
131+
132+
STATUS_JSON=$(curl -sf \
133+
-H "Authorization: Bearer ${SONAR_TOKEN}" \
134+
"${SONAR_URL}/api/qualitygates/project_status?projectKey=${SONAR_PROJECT_KEY}")
135+
136+
QG_STATUS=$(echo "$STATUS_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['projectStatus']['status'])")
137+
138+
case "$QG_STATUS" in
139+
OK) GH_STATE="success"; DESCRIPTION="Quality gate passed" ;;
140+
ERROR) GH_STATE="failure"; DESCRIPTION="Quality gate failed" ;;
141+
WARN) GH_STATE="success"; DESCRIPTION="Quality gate passed with warnings" ;;
142+
*) GH_STATE="pending"; DESCRIPTION="Quality gate status unknown" ;;
143+
esac
144+
145+
TARGET_URL="${SONAR_URL}/dashboard?id=${SONAR_PROJECT_KEY}"
146+
147+
curl -sf -X POST \
148+
-H "Authorization: token ${GITHUB_TOKEN}" \
149+
-H "Accept: application/vnd.github.v3+json" \
150+
-H "Content-Type: application/json" \
151+
-d "{\"state\":\"${GH_STATE}\",\"description\":\"${DESCRIPTION}\",\"context\":\"sonarqube/quality-gate\",\"target_url\":\"${TARGET_URL}\"}" \
152+
"https://api.github.com/repos/splitio/${GITHUB_REPO}/statuses/${COMMIT_SHA}"
153+
154+
echo "Posted SonarQube quality gate status: ${GH_STATE}"
155+
strategy:
156+
matrix:
157+
nodeVersion:
158+
- "lts"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
inputSet:
2+
name: reactnativeclientinputset
3+
identifier: reactnativeclientinputset
4+
orgIdentifier: PROD
5+
projectIdentifier: Harness_Split
6+
pipeline:
7+
identifier: reactnativeclient
8+
properties:
9+
ci:
10+
codebase:
11+
build:
12+
type: PR
13+
spec:
14+
number: <+trigger.prNumber>

0 commit comments

Comments
 (0)