From 24ca7665ff0ed65758c296fe9bf412e9f0c67381 Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Fri, 10 May 2024 10:41:16 +0200 Subject: [PATCH] adding badges to workflow and README Signed-off-by: Tullio Sebastiani fix --- .github/workflows/test.yaml | 40 +++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 2 files changed, 42 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4b86804..c5e12d5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -79,6 +79,46 @@ jobs: run: | docker push quay.io/krkn-chaos/krkn-service-hijacking:latest docker push quay.io/krkn-chaos/krkn-service-hijacking:${GITHUB_REF##*/} + badge: + name: Generate and Publish Coverage Badge + runs-on: ubuntu-latest + needs: + - build-image + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Check out doc repo + uses: actions/checkout@master + with: + repository: krkn-chaos/krkn-lib-docs + path: krkn-lib-docs + ssh-key: ${{ secrets.KRKN_LIB_DOCS_PRIV_KEY }} + - name: Download json coverage + uses: actions/download-artifact@v3 + with: + name: coverage.json + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Copy badge on GitHub Page Repo + env: + COLOR: red + run: | + # generate coverage badge on previously calculated total coverage + # and copy in the docs page + export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") + [[ $TOTAL > 90 ]] && COLOR=green + echo "TOTAL: $TOTAL" + echo "COLOR: $COLOR" + curl "https://img.shields.io/badge/coverage-$TOTAL%25-$COLOR" > ./krkn-lib-docs/coverage_badge_hijacking.svg + - name: Push updated Coverage Badge + run: | + cd krkn-lib-docs + git add . + git config user.name "krkn-chaos" + git config user.email "<>" + git commit -m "[KRKN SERVICE HIJACKING] Coverage Badge ${GITHUB_REF##*/}" + git push # publish: diff --git a/README.md b/README.md index 9aa5dbc..13f131f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # Service Hijacking Mock Webservice +![coverage](https://krkn-chaos.github.io/krkn-lib-docs/coverage_badge_hijacking.svg) +![action](https://github.com/krkn-chaos/krkn-service-hijacking/actions/workflows/test.yaml/badge.svg) This is the mock webservice used in the [Krkn](https://github.com/krkn-chaos/krkn) Service Hijacking scenario.