Skip to content

Commit 51700a0

Browse files
committed
Update pipeline python-client
1 parent 0e723da commit 51700a0

1 file changed

Lines changed: 53 additions & 53 deletions

File tree

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

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,35 @@ pipeline:
3636
execution:
3737
steps:
3838
- step:
39-
type: Run
40-
name: Post Quality Gate to GitHub
41-
identifier: Post_Quality_Gate_to_GitHub
39+
timeout: 30m
40+
type: Test
41+
name: Run Python Tests
42+
identifier: run_tests
4243
spec:
44+
connectorRef: account.harnessImage
45+
image: python:3.7.16-alpine
4346
shell: Sh
4447
command: |-
45-
# Get SonarQube quality gate status
46-
curl -u <+secrets.getValue('sonarqube-token')>: \
47-
-s "https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}"
48-
49-
curl -u <+secrets.getValue('sonarqube-token')>: -s 'https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}' | jq -r .projectStatus.status
50-
51-
QUALITY_GATE_STATUS=$(curl -u <+secrets.getValue('sonarqube-token')>: -s 'https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}' | jq -r .projectStatus.status)
48+
apk update
49+
apk add --no-cache krb5-dev musl-dev libffi-dev build-base
5250
53-
echo "QUALITY_GATE_STATUS: $QUALITY_GATE_STATUS"
51+
# Run pytest with JUnit XML report output
52+
cd /harness
53+
pip install --upgrade pip
54+
pip install -U setuptools pip wheel
55+
pip install Cython==3.0.12
56+
pip install aiohttp==3.8.4
57+
pip install cryptography==45.0.7
58+
pip install pycparser==2.21
5459
55-
# Set GitHub status based on quality gate
56-
if [ "$QUALITY_GATE_STATUS" = "OK" ]; then
57-
STATE="success"
58-
DESCRIPTION="SonarQube Quality Gate passed"
59-
else
60-
STATE="failure"
61-
DESCRIPTION="SonarQube Quality Gate failed"
62-
fi
60+
apk add redis
61+
redis-server /etc/redis.conf &
6362
64-
# Post status to GitHub
65-
curl -X POST \
66-
-H "Authorization: token ${<+secrets.getValue('github-devops-token')>}" \
67-
-H "Content-Type: application/json" \
68-
-d "{
69-
\"state\": \"${STATE}\",
70-
\"description\": \"${DESCRIPTION}\",
71-
\"context\": \"sonarqube/qualitygate\",
72-
\"target_url\": \"https://sonar.harness.io/dashboard?id=python-client&pullRequest=${<+codebase.prNumber>}\"
73-
}" \
74-
"https://api.github.com/repos/splitio/python-client/statuses/<+codebase.commitSha>"
63+
pip install redis==5.0.8
64+
python setup.py test
65+
envVariables:
66+
PYTHONPATH: ${PYTHONPATH}:.
67+
PYTEST_ADDOPTS: "--verbose"
7568
- step:
7669
type: Run
7770
name: Install and Run SonarQube Scanner
@@ -109,35 +102,42 @@ pipeline:
109102
- name: SONAR_SCANNER_PATH
110103
timeout: 10m
111104
- step:
112-
timeout: 30m
113-
type: Test
114-
name: Run Python Tests
115-
identifier: run_tests
105+
type: Run
106+
name: Post Quality Gate to GitHub
107+
identifier: Post_Quality_Gate_to_GitHub
116108
spec:
117-
connectorRef: account.harnessImage
118-
image: python:3.7.16-alpine
119109
shell: Sh
120110
command: |-
121-
apk update
122-
apk add --no-cache krb5-dev musl-dev libffi-dev build-base
111+
# Get SonarQube quality gate status
112+
curl -u <+secrets.getValue('sonarqube-token')>: \
113+
-s "https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}"
123114
124-
# Run pytest with JUnit XML report output
125-
cd /harness
126-
pip install --upgrade pip
127-
pip install -U setuptools pip wheel
128-
pip install Cython==3.0.12
129-
pip install aiohttp==3.8.4
130-
pip install cryptography==45.0.7
131-
pip install pycparser==2.21
115+
curl -u <+secrets.getValue('sonarqube-token')>: -s 'https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}' | jq -r .projectStatus.status
132116
133-
apk add redis
134-
redis-server /etc/redis.conf &
117+
QUALITY_GATE_STATUS=$(curl -u <+secrets.getValue('sonarqube-token')>: -s 'https://sonar.harness.io/api/qualitygates/project_status?projectKey=python-client&pullRequest=${<+codebase.prNumber>}' | jq -r .projectStatus.status)
135118
136-
pip install redis==5.0.8
137-
python setup.py test
138-
envVariables:
139-
PYTHONPATH: ${PYTHONPATH}:.
140-
PYTEST_ADDOPTS: "--verbose"
119+
echo "QUALITY_GATE_STATUS: $QUALITY_GATE_STATUS"
120+
121+
# Set GitHub status based on quality gate
122+
if [ "$QUALITY_GATE_STATUS" = "OK" ]; then
123+
STATE="success"
124+
DESCRIPTION="SonarQube Quality Gate passed"
125+
else
126+
STATE="failure"
127+
DESCRIPTION="SonarQube Quality Gate failed"
128+
fi
129+
130+
# Post status to GitHub
131+
curl -X POST \
132+
-H "Authorization: token ${<+secrets.getValue('github-devops-token')>}" \
133+
-H "Content-Type: application/json" \
134+
-d "{
135+
\"state\": \"${STATE}\",
136+
\"description\": \"${DESCRIPTION}\",
137+
\"context\": \"sonarqube/qualitygate\",
138+
\"target_url\": \"https://sonar.harness.io/dashboard?id=python-client&pullRequest=${<+codebase.prNumber>}\"
139+
}" \
140+
"https://api.github.com/repos/splitio/python-client/statuses/<+codebase.commitSha>"
141141
rollbackSteps: []
142142
rollbackSteps: []
143143
caching:

0 commit comments

Comments
 (0)