Skip to content

Commit

Permalink
adding badges to workflow and README
Browse files Browse the repository at this point in the history
Signed-off-by: Tullio Sebastiani <[email protected]>
  • Loading branch information
tsebastiani committed May 10, 2024
1 parent 01dde6e commit 1527cdb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,49 @@ 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: |
find krkn-lib-docs/ -type f ! -name 'index.html' -type d ! -name '.git' -delete
cp -R docs/build/html/* krkn-lib-docs
# 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:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 1527cdb

Please sign in to comment.