Skip to content

Commit bd34f2b

Browse files
committed
Test: Sonarqube workflow with result print in CI-Pipeline
1 parent 641cf9c commit bd34f2b

2 files changed

Lines changed: 17 additions & 248 deletions

File tree

.github/workflows/sonarqube.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ jobs:
5757
working-directory: project/frontend
5858
run: npm ci
5959

60+
- name: Run frontend tests with coverage
61+
working-directory: project/frontend
62+
run: npm run test:coverage --if-present
63+
continue-on-error: true
64+
6065
# =====================================================
6166
# SONARCLOUD SCAN
6267
# =====================================================
@@ -114,8 +119,8 @@ jobs:
114119
echo ""
115120
echo ":warning: Konnte die Metriken nicht abrufen."
116121
echo ""
117-
echo "- **HTTP Status:** \`${HTTP_CODE}\`"
118-
echo "- **Project Key:** \`${PROJECT_KEY}\`"
122+
echo "- **HTTP Status:** ${HTTP_CODE}"
123+
echo "- **Project Key:** ${PROJECT_KEY}"
119124
echo "- **Dashboard:** [${SONAR_HOST}/project/overview?id=${PROJECT_KEY}](${SONAR_HOST}/project/overview?id=${PROJECT_KEY})"
120125
} >> "$SUMMARY_FILE"
121126
exit 0
@@ -129,10 +134,11 @@ jobs:
129134
}
130135
131136
get_sub() {
132-
local path_enc sub_resp
133-
path_enc=$(printf '%s' "$1" | sed 's|/|%2F|g')
134-
sub_resp=$(curl -s -u "${SONAR_TOKEN}:" \
135-
"${SONAR_HOST}/api/measures/component?component=${PROJECT_KEY}:${path_enc}&metricKeys=$2")
137+
local sub_resp
138+
sub_resp=$(curl -s -u "${SONAR_TOKEN}:" -G \
139+
--data-urlencode "component=${PROJECT_KEY}:$1" \
140+
--data-urlencode "metricKeys=$2" \
141+
"${SONAR_HOST}/api/measures/component")
136142
echo "${sub_resp}" | jq -r --arg k "$2" \
137143
'if (.component? and .component.measures?) then
138144
((.component.measures[] | select(.metric==$k) | .value) // "-")
@@ -163,7 +169,7 @@ jobs:
163169
{
164170
echo "## SonarCloud Analyse – LazyCook"
165171
echo ""
166-
echo "**Quality Gate:** ${QG_EMOJI} \`${QG_ICON}\` "
172+
echo "**Quality Gate:** ${QG_EMOJI} **${QG_ICON}**"
167173
echo "**Dashboard:** [${SONAR_HOST}/project/overview?id=${PROJECT_KEY}](${SONAR_HOST}/project/overview?id=${PROJECT_KEY})"
168174
echo ""
169175
echo "### Coverage"
@@ -215,6 +221,10 @@ jobs:
215221
| "| " + $p + " | " + $b + " | " + $l + " | " + $pct + "% | " + $n + " |"
216222
'
217223
echo ""
224+
fi
225+
echo "[Volle Duplikat-Ansicht in SonarCloud öffnen](${SONAR_HOST}/component_measures?id=${PROJECT_KEY}&metric=duplicated_lines_density&view=list)"
226+
echo ""
227+
218228
echo "### Ratings & Issues"
219229
echo ""
220230
echo "| Bewertung | Wert | Anzahl |"

project/.github/workflows/sonar.yml

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

0 commit comments

Comments
 (0)