Commit 3ae64e79 authored by Adrian DC's avatar Adrian DC
Browse files

docs(prepare): implement 'About / Quality' badges page

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent b38f7e1d
Loading
Loading
Loading
Loading
Loading
+98 −0
Changes for docs/prepare.sh: 98 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -43,6 +43,104 @@ diff -u "${root_path}/CHANGELOG.md" "${docs_path}/.cache/about/changelog.md" ||
  cat "${root_path}/LICENSE"
} >"${docs_path}/.cache/about/license.md"

# Generate about/quality
{
  projectKey=$(grep '^sonar\.projectKey=' "${root_path}/sonar-project.properties" | cut -d'=' -f2)
  projectName=$(grep '^sonar\.projectName=' "${root_path}/sonar-project.properties" | cut -d'=' -f2)
  projectUrl=$(grep '^repo_url:' "${root_path}/mkdocs.yml" | cut -d':' -f2- | xargs echo)
  echo '# Quality'
  echo ''
  echo '---'
  echo ''
  echo "## Tags"
  echo ''
  echo '<table>'
  echo '  <tbody>'
  echo '    <tr>'
  echo '      <td>'
  echo '        <b>GitLab</b>'
  echo '      </td>'
  echo '      <td>'
  echo "        <a href=\"${projectUrl}/-/commits/${branch}/\">"
  echo "          <img src=\"${projectUrl}/-/badges/release.svg?key_text=release&key_width=60\" alt=\"Releae\" style=\"max-width: 100%;\">"
  echo '        </a>'
  echo '      </td>'
  echo '    </tr>'
  echo '    <tr>'
  echo '      <td>'
  echo '        <b>SonarCloud</b>'
  echo '      </td>'
  echo '      <td>'
  echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}\">"
  echo "          <img src=\"https://sonarcloud.io/api/project_badges/quality_gate?project=${projectKey}\" alt=\"Quality gate\" style=\"max-width: 100%\">"
  echo '        </a>'
  echo '      </td>'
  echo '    </tr>'
  echo '  </tbody>'
  echo '</table>'
  for branch in 'main' 'develop'; do
    echo ''
    echo '---'
    echo ''
    echo "## Branch ${branch}"
    echo ''
    echo '<table>'
    echo '  <tbody>'
    echo '    <tr>'
    echo '      <td>'
    echo '        <b>GitLab</b>'
    echo '      </td>'
    echo '      <td>'
    echo "        <a href=\"${projectUrl}/-/commits/${branch}/\">"
    echo "          <img src=\"${projectUrl}/badges/${branch}/pipeline.svg\" alt=\"Build\" style=\"max-width: 100%;\">"
    echo '        </a>'
    echo '      </td>'
    echo '    </tr>'
    echo '    <tr>'
    echo '      <td>'
    echo '        <b>SonarCloud</b>'
    echo '      </td>'
    echo '      <td>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=alert_status\" alt=\"Quality Gate Status\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=bugs&branch=${branch}\" alt=\"Bugs\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=code_smells&branch=${branch}\" alt=\"Code Smells\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=coverage&branch=${branch}\" alt=\"Coverage\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=duplicated_lines_density&branch=${branch}\" alt=\"Duplicated Lines (%)\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=ncloc&branch=${branch}\" alt=\"Lines of Code\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=reliability_rating&branch=${branch}\" alt=\"Reliability Rating\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=security_rating&branch=${branch}\" alt=\"Security Rating\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=sqale_index&branch=${branch}\" alt=\"Technical Debt\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=sqale_rating&branch=${branch}\" alt=\"Maintainability Rating\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo "        <a href=\"https://sonarcloud.io/summary/overall?id=${projectKey}&branch=${branch}\">"
    echo "          <img src=\"https://sonarcloud.io/api/project_badges/measure?project=${projectKey}&metric=vulnerabilities&branch=${branch}\" alt=\"Vulnerabilities\" style=\"max-width: 100%\">"
    echo '        </a>'
    echo '      </td>'
    echo '    </tr>'
    echo '  </tbody>'
    echo '</table>'
  done
} >"${docs_path}/.cache/about/quality.md"

# Show cache
echo ' '
ls -laR "${docs_path}/.cache/"
+1 −0
Changes for mkdocs.yml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ nav:
  - About:
      - ‣ Changelog: about/changelog.md
      - ‣ License: about/license.md
      - ‣ Quality: about/quality.md

# Pages theme
theme: