Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/robot-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
branches: [main]
push:
branches: [main]
paths-ignore:
- 'docs/badge.json'

permissions:
security-events: write
contents: write

jobs:
lint:
Expand Down Expand Up @@ -77,3 +80,44 @@ jobs:
with:
name: robot-results
path: results/

- name: Generate test result badge
if: always()
run: |
python3 - << 'EOF'
import json
try:
from robot.api import ExecutionResult
result = ExecutionResult('results/output.xml')
stats = result.statistics.total
passed = stats.passed
failed = stats.failed
total = passed + failed
if failed == 0:
color = "brightgreen"
message = f"{passed}/{total} passed"
else:
color = "red"
message = f"{passed}/{total} passed, {failed} failed"
except Exception as e:
print(f"Could not parse test results: {e}")
color = "lightgrey"
message = f"error: {e}"
badge = {"schemaVersion": 1, "label": "tests", "message": message, "color": color}
with open('docs/badge.json', 'w') as f:
json.dump(badge, f)
print(f"Badge written: {badge}")
EOF

- name: Commit test result badge
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/badge.json
if git diff --staged --quiet; then
echo "No changes to badge.json"
else
git commit -m "chore: update test result badge"
git push
fi
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Robot Framework E2E Testing Workshop — 42 Vienna

[![Robot Framework Tests](https://github.com/HackXIt/42vienna-robotframework-workshop/actions/workflows/robot-tests.yml/badge.svg)](https://github.com/HackXIt/42vienna-robotframework-workshop/actions/workflows/robot-tests.yml)
[![Test Results](https://img.shields.io/endpoint?url=https://hackxit.github.io/42vienna-robotframework-workshop/badge.json)](https://github.com/HackXIt/42vienna-robotframework-workshop/actions/workflows/robot-tests.yml)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/HackXIt/42vienna-robotframework-workshop)

**Browser Library & Playwright for Web Testing**

Expand Down
1 change: 1 addition & 0 deletions docs/badge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schemaVersion": 1, "label": "tests", "message": "unknown", "color": "lightgrey"}
Loading