This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
name: Build Feature
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
pipeline:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITEA_API_URL: https://gitea.app.keskikuja.site
|
||||
PAGES_HOST: ci-reports.helm-dev.keskikuja.site
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: niko/gitea-ci-library
|
||||
path: .ci
|
||||
|
||||
- name: Bats tests
|
||||
continue-on-error: true
|
||||
run: |
|
||||
mkdir -p "reports/${GITHUB_SHA:0:8}/bats"
|
||||
bats --formatter junit tests/*.bats > "reports/${GITHUB_SHA:0:8}/bats/junit.xml" 2>&1 || \
|
||||
bats tests/*.bats > "reports/${GITHUB_SHA:0:8}/bats/results.txt" 2>&1
|
||||
|
||||
- name: Cucumber tests
|
||||
continue-on-error: true
|
||||
run: |
|
||||
mkdir -p "reports/${GITHUB_SHA:0:8}/cucumber"
|
||||
npx cucumber-js \
|
||||
--format json:"reports/${GITHUB_SHA:0:8}/cucumber/report.json" \
|
||||
--format html:"reports/${GITHUB_SHA:0:8}/cucumber/index.html" 2>&1 || \
|
||||
npx cucumber-js \
|
||||
--format json:"reports/${GITHUB_SHA:0:8}/cucumber/report.json"
|
||||
|
||||
- name: Generate report index
|
||||
run: |
|
||||
SHA8="${GITHUB_SHA:0:8}"
|
||||
BATS_PASS=$(grep -c 'ok' "reports/${SHA8}/bats/results.txt" 2>/dev/null || echo 0)
|
||||
BATS_FAIL=$(grep -c 'not ok' "reports/${SHA8}/bats/results.txt" 2>/dev/null || echo 0)
|
||||
CUCUMBER_PASS=$(jq '.summary.passed // 0' "reports/${SHA8}/cucumber/report.json" 2>/dev/null || echo 0)
|
||||
CUCUMBER_FAIL=$(jq '.summary.failed // 0' "reports/${SHA8}/cucumber/report.json" 2>/dev/null || echo 0)
|
||||
{
|
||||
echo "<!DOCTYPE html><html><head><meta charset='utf-8'>"
|
||||
echo "<title>CI report ${SHA8}</title>"
|
||||
echo "<style>body{font-family:sans-serif;margin:2em}a{color:#2563eb}table{border-collapse:collapse}"
|
||||
echo "th,td{border:1px solid #ccc;padding:8px;text-align:left}"
|
||||
echo ".pass{color:#059669}.fail{color:#dc2626}</style></head><body>"
|
||||
echo "<h1>CI report <code>${SHA8}</code></h1>"
|
||||
echo "<p>Commit: ${GITHUB_SHA}<br>Branch: ${GITHUB_REF_NAME}<br>Run: ${GITHUB_RUN_ID}</p>"
|
||||
echo "<table><tr><th>Suite</th><th>Passed</th><th>Failed</th><th>Report</th></tr>"
|
||||
echo "<tr><td>Bats</td><td class='pass'>${BATS_PASS}</td><td class='fail'>${BATS_FAIL}</td>"
|
||||
echo "<td><a href='bats/results.txt'>results.txt</a>"
|
||||
echo " | <a href='bats/junit.xml'>junit.xml</a></td></tr>"
|
||||
echo "<tr><td>Cucumber</td><td class='pass'>${CUCUMBER_PASS}</td><td class='fail'>${CUCUMBER_FAIL}</td>"
|
||||
echo "<td><a href='cucumber/index.html'>report</a>"
|
||||
echo " | <a href='cucumber/report.json'>json</a></td></tr>"
|
||||
echo "</table></body></html>"
|
||||
} > "reports/${SHA8}/index.html"
|
||||
|
||||
- name: Set commit status
|
||||
run: |
|
||||
bash .ci/scripts/report-status.sh success \
|
||||
"Tests passed" \
|
||||
"https://${PAGES_HOST}/${GITHUB_REPOSITORY}/reports/${GITHUB_SHA:0:8}/" \
|
||||
ci-tests
|
||||
|
||||
- name: Publish reports
|
||||
run: |
|
||||
bash .ci/scripts/publish-git-pages.sh "reports/${GITHUB_SHA:0:8}"
|
||||
Reference in New Issue
Block a user