uusi report logiikka
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 24s
unit-tests Link to Bats reports
CI Feature / Bats tests (push) Successful in 1m37s
acc-tests Link to Cucumber reports
CI Feature / Cucumber tests (push) Successful in 1m8s
CI Feature / Report Summary (push) Successful in 5s
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 24s
unit-tests Link to Bats reports
CI Feature / Bats tests (push) Successful in 1m37s
acc-tests Link to Cucumber reports
CI Feature / Cucumber tests (push) Successful in 1m8s
CI Feature / Report Summary (push) Successful in 5s
This commit is contained in:
@@ -1,37 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
WORKSPACE_VOLUME="${1:-}"
|
REPORT_DIR="${1:-}"
|
||||||
REPORT_DIR="${2:-}"
|
|
||||||
|
|
||||||
[ -n "$WORKSPACE_VOLUME" ] || { echo "ERROR: workspace volume name required" >&2; exit 1; }
|
|
||||||
[ -n "$REPORT_DIR" ] || { echo "ERROR: report directory required" >&2; exit 1; }
|
[ -n "$REPORT_DIR" ] || { echo "ERROR: report directory required" >&2; exit 1; }
|
||||||
|
|
||||||
HAS_COVERAGE=false
|
if [ -d coverage ]; then
|
||||||
COVERAGE_SRC=""
|
|
||||||
if docker run --rm -v "$WORKSPACE_VOLUME":/data alpine sh -c '[ -d /data/coverage ] && ls -A /data/coverage | grep -q .' 2>/dev/null; then
|
|
||||||
COVERAGE_SRC="/data/coverage"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$COVERAGE_SRC" ]; then
|
|
||||||
mkdir -p "$REPORT_DIR/coverage"
|
mkdir -p "$REPORT_DIR/coverage"
|
||||||
docker run --rm -v "$WORKSPACE_VOLUME":/data alpine tar c -C "$COVERAGE_SRC" . | tar x -C "$REPORT_DIR/coverage"
|
cp -a coverage/. "$REPORT_DIR/coverage/"
|
||||||
HAS_COVERAGE=true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > "$REPORT_DIR/index.html" << EOF
|
|
||||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">
|
|
||||||
<title>Bats report ${GITHUB_SHA:0:8}</title>
|
|
||||||
<style>body{font-family:sans-serif;margin:2em;max-width:960px}
|
|
||||||
h1{color:#1e293b}a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}
|
|
||||||
</style></head><body>
|
|
||||||
<h1>Bats report <code>${GITHUB_SHA:0:8}</code></h1>
|
|
||||||
<ul>
|
|
||||||
<li><a href="test-report.html">Test results</a></li>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if [ "$HAS_COVERAGE" = true ]; then
|
|
||||||
echo '<li><a href="coverage/index.html">Coverage report</a></li>' >> "$REPORT_DIR/index.html"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo '</ul></body></html>' >> "$REPORT_DIR/index.html"
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
bats:
|
bats:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ inputs.bats-image }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -31,34 +33,16 @@ jobs:
|
|||||||
path: .ci
|
path: .ci
|
||||||
|
|
||||||
- name: Run bats tests
|
- name: Run bats tests
|
||||||
id: bats-tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
docker volume create bats-workspace
|
mkdir -p reports/bats
|
||||||
tar c . | docker run --rm -i -v bats-workspace:/data alpine tar x -C /data
|
bashcov -- bats tests/ > reports/bats/results.txt 2>&1
|
||||||
mkdir -p "reports/${GITHUB_SHA:0:8}/bats"
|
|
||||||
set +e
|
|
||||||
docker run --rm \
|
|
||||||
-v bats-workspace:/data \
|
|
||||||
--entrypoint bash ${{ inputs.bats-image }} \
|
|
||||||
-c 'cd /data && bashcov -- bats tests/' \
|
|
||||||
> "reports/${GITHUB_SHA:0:8}/bats/results.txt" 2>&1
|
|
||||||
BATS_EXIT=$?
|
|
||||||
bash .ci/.gitea/scripts/bats-coverage.sh bats-workspace "reports/${GITHUB_SHA:0:8}/bats"
|
|
||||||
docker volume rm bats-workspace > /dev/null 2>&1
|
|
||||||
bash .ci/.gitea/scripts/bats-report.sh "reports/${GITHUB_SHA:0:8}/bats"
|
|
||||||
echo "BATS_EXIT=${BATS_EXIT}" >> "${GITHUB_ENV}"
|
|
||||||
exit ${BATS_EXIT}
|
|
||||||
|
|
||||||
- name: Publish bats reports
|
- name: Post-process reports
|
||||||
if: always()
|
|
||||||
run: bash .ci/scripts/publish-git-pages.sh bats
|
|
||||||
|
|
||||||
- name: Report status
|
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
if [ "${BATS_EXIT}" = "0" ]; then
|
bash .ci/.gitea/scripts/bats-coverage.sh reports/bats
|
||||||
bash .ci/scripts/report-status.sh success "Link to Bats reports" unit-tests bats
|
bash .ci/.gitea/scripts/bats-report.sh reports/bats
|
||||||
else
|
|
||||||
bash .ci/scripts/report-status.sh failure "Link to Bats reports" unit-tests bats
|
- name: Report
|
||||||
fi
|
if: always()
|
||||||
|
run: bash .ci/scripts/ci-report.sh "Bats test report" unit-tests bats
|
||||||
|
|||||||
@@ -33,36 +33,14 @@ jobs:
|
|||||||
path: .ci
|
path: .ci
|
||||||
|
|
||||||
- name: Run cucumber tests
|
- name: Run cucumber tests
|
||||||
id: cucumber-tests
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
mkdir -p "reports/${GITHUB_SHA:0:8}/cucumber"
|
mkdir -p reports/cucumber
|
||||||
set +e
|
|
||||||
npx cucumber-js \
|
npx cucumber-js \
|
||||||
--format json:"reports/${GITHUB_SHA:0:8}/cucumber/report.json" \
|
--format json:reports/cucumber/report.json \
|
||||||
--format html:"reports/${GITHUB_SHA:0:8}/cucumber/index.html" 2>&1
|
--format html:reports/cucumber/report.html 2>&1
|
||||||
CUCUMBER_EXIT=$?
|
|
||||||
echo "CUCUMBER_EXIT=${CUCUMBER_EXIT}" >> "${GITHUB_ENV}"
|
|
||||||
exit ${CUCUMBER_EXIT}
|
|
||||||
|
|
||||||
- name: Publish cucumber reports
|
- name: Report
|
||||||
if: always()
|
|
||||||
run: bash .ci/scripts/publish-git-pages.sh cucumber
|
|
||||||
|
|
||||||
- name: Report status
|
|
||||||
if: always()
|
if: always()
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: bash .ci/scripts/ci-report.sh "Cucumber test report" acc-tests cucumber
|
||||||
if [ "${CUCUMBER_EXIT}" = "0" ]; then
|
|
||||||
if [ -f "reports/${GITHUB_SHA:0:8}/cucumber/index.html" ]; then
|
|
||||||
bash .ci/scripts/report-status.sh success "Link to Cucumber reports" acc-tests cucumber
|
|
||||||
else
|
|
||||||
bash .ci/scripts/report-status.sh success "Link to Cucumber reports" acc-tests
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -f "reports/${GITHUB_SHA:0:8}/cucumber/index.html" ]; then
|
|
||||||
bash .ci/scripts/report-status.sh failure "Link to Cucumber reports" acc-tests cucumber
|
|
||||||
else
|
|
||||||
bash .ci/scripts/report-status.sh failure "Link to Cucumber reports" acc-tests
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DESCRIPTION="${1:-}"
|
||||||
|
CONTEXT="${2:-}"
|
||||||
|
SUITE="${3:-}"
|
||||||
|
|
||||||
|
[ -n "$DESCRIPTION" ] || { echo "ERROR: description argument required" >&2; exit 1; }
|
||||||
|
[ -n "$CONTEXT" ] || { echo "ERROR: context argument required" >&2; exit 1; }
|
||||||
|
[ -n "$SUITE" ] || { echo "ERROR: suite argument required" >&2; exit 1; }
|
||||||
|
|
||||||
|
REPORT_DIR="reports/${SUITE}"
|
||||||
|
|
||||||
|
if [ ! -d "$REPORT_DIR" ]; then
|
||||||
|
echo "ERROR: $REPORT_DIR not found" >&2
|
||||||
|
bash .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$REPORT_DIR"
|
||||||
|
|
||||||
|
FILES=()
|
||||||
|
while IFS= read -r -d '' f; do
|
||||||
|
FILES+=("$(basename "$f")")
|
||||||
|
done < <(find . -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true)
|
||||||
|
|
||||||
|
SUBDIRS=()
|
||||||
|
while IFS= read -r -d '' d; do
|
||||||
|
name="${d#./}"
|
||||||
|
[ -f "$name/index.html" ] && SUBDIRS+=("$name")
|
||||||
|
done < <(find . -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true)
|
||||||
|
|
||||||
|
TOTAL=$(( ${#FILES[@]} + ${#SUBDIRS[@]} ))
|
||||||
|
|
||||||
|
if [ "$TOTAL" -eq 0 ]; then
|
||||||
|
echo "ERROR: no reportable items in $REPORT_DIR" >&2
|
||||||
|
bash .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SHA8="${GITHUB_SHA:0:8}"
|
||||||
|
|
||||||
|
humanize() {
|
||||||
|
local name="$1"
|
||||||
|
name="${name%.*}"
|
||||||
|
name="${name//-/ }"
|
||||||
|
name="${name//_/ }"
|
||||||
|
echo "${name^}"
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_index() {
|
||||||
|
local html
|
||||||
|
html='<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
|
||||||
|
html+="<title>$DESCRIPTION</title>"
|
||||||
|
html+='<style>body{font-family:sans-serif;margin:2em;max-width:960px}h1{color:#1e293b}ul{list-style:none;padding:0}li{margin:.5em 0;padding:.5em;background:#f8fafc;border-radius:6px}a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}</style>'
|
||||||
|
html+="</head><body><h1>$DESCRIPTION</h1><ul>"
|
||||||
|
for f in "${FILES[@]}"; do
|
||||||
|
html+="<li><a href=\"$f\">$(humanize "$f")</a></li>"
|
||||||
|
done
|
||||||
|
for d in "${SUBDIRS[@]}"; do
|
||||||
|
html+="<li><a href=\"$d/index.html\">${d^}</a></li>"
|
||||||
|
done
|
||||||
|
html+='</ul></body></html>'
|
||||||
|
printf '%s' "$html" > index.html
|
||||||
|
}
|
||||||
|
|
||||||
|
cd - > /dev/null
|
||||||
|
|
||||||
|
# Stage reports for backward-compatible publish
|
||||||
|
STAGED="reports/${SHA8}/${SUITE}"
|
||||||
|
mkdir -p "$STAGED"
|
||||||
|
cp -a "$REPORT_DIR/." "$STAGED/"
|
||||||
|
|
||||||
|
if [ "$TOTAL" -eq 1 ]; then
|
||||||
|
if [ ${#FILES[@]} -eq 1 ]; then
|
||||||
|
ENTRY="${FILES[0]}"
|
||||||
|
else
|
||||||
|
ENTRY="${SUBDIRS[0]}/index.html"
|
||||||
|
fi
|
||||||
|
bash .ci/scripts/publish-git-pages.sh "$SUITE"
|
||||||
|
URL="${GIT_PAGES_URL}/${GITHUB_REPOSITORY}/reports/${SHA8}/${SUITE}/${ENTRY}"
|
||||||
|
bash .ci/scripts/report-status.sh success "$DESCRIPTION" "$CONTEXT" "" "$URL"
|
||||||
|
else
|
||||||
|
bash .ci/scripts/publish-git-pages.sh "$SUITE"
|
||||||
|
bash .ci/scripts/report-status.sh success "$DESCRIPTION" "$CONTEXT" "$SUITE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$STAGED"
|
||||||
@@ -79,16 +79,14 @@ Ei monoliittista `ci-tests.yml`. Jokainen testityyppi tai operaatio on oma `work
|
|||||||
|
|
||||||
## 3. Exit-koodin käsittely
|
## 3. Exit-koodin käsittely
|
||||||
|
|
||||||
Jokainen testi kaappaa komentonsa exit-koodin eksplisiittisesti:
|
`set -e` on oletuksena käytössä Gitea Actions -stepeissä — ensimmäinen feilaava komento pysäyttää stepin
|
||||||
|
ja exit-koodi välittyy natiivisti. Ylimääräistä `EXIT=$?` + `echo >> GITHUB_ENV` -käärettä ei tarvita.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
<testikomento> > results.txt 2>&1
|
<testikomento> > results.txt 2>&1
|
||||||
EXIT=$?
|
|
||||||
echo "EXIT=${EXIT}" >> "${GITHUB_ENV}"
|
|
||||||
exit ${EXIT}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Miksi ei pipeä (`| tee`):**
|
**Miksi ei pipeä (`| tee`):**
|
||||||
@@ -101,8 +99,8 @@ Jokainen testi kaappaa komentonsa exit-koodin eksplisiittisesti:
|
|||||||
<komento> > results.txt 2>&1
|
<komento> > results.txt 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
Ilman `EXIT=$?` + `exit ${EXIT}` komento voi feilata mutta job menee läpi vihreänä — `container:`-modessa
|
`set -e` ei pelasta pipe-tilanteessa — `|` syö exit-koodin kuten ennenkin. Redirectillä exit-koodi
|
||||||
shellin käyttäytyminen vaihtelee.
|
välittyy luonnollisesti.
|
||||||
|
|
||||||
## 4. Konttipolitiikka
|
## 4. Konttipolitiikka
|
||||||
|
|
||||||
@@ -120,38 +118,15 @@ valmiin `ci-container-build-<kontti>.yml`-pohjan jossa `workflow_dispatch`-tuki
|
|||||||
|
|
||||||
### 4.1 CI-kontin ajaminen jobissa
|
### 4.1 CI-kontin ajaminen jobissa
|
||||||
|
|
||||||
CI-kontin voi ajaa joko `container:`-direktiivillä (kaikki stepit kontissa)
|
Ainoa sallittu tapa on `container:`-direktiivi. `docker run` komennolla kontin
|
||||||
tai `docker run --rm`:llä stepin sisällä (checkout natiivisti). Molemmat tavat
|
käynnistäminen stepin sisällä on anti-pattern.
|
||||||
toimivat.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Tapa A: container:-direktiivi
|
|
||||||
jobs:
|
jobs:
|
||||||
<työkalu>:
|
<työkalu>:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ${{ inputs.<image-name> }}
|
image: ${{ inputs.<image-name> }}
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: <owner>/gitea-ci-library
|
|
||||||
path: .ci
|
|
||||||
- name: Run <työkalu>
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir -p "reports/${GITHUB_SHA:0:8}/<suite>"
|
|
||||||
<komento> > "reports/${GITHUB_SHA:0:8}/<suite>/results.txt" 2>&1
|
|
||||||
EXIT=$?
|
|
||||||
echo "EXIT=${EXIT}" >> "${GITHUB_ENV}"
|
|
||||||
exit ${EXIT}
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# Tapa B: docker run --rm stepin sisällä (kuten example-bats-tests.yml)
|
|
||||||
jobs:
|
|
||||||
<työkalu>:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -162,86 +137,86 @@ jobs:
|
|||||||
- name: Run <työkalu>
|
- name: Run <työkalu>
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
docker volume create ws-<suite>
|
mkdir -p "reports/<suite>"
|
||||||
tar c . | docker run --rm -i -v ws-<suite>:/data alpine tar x -C /data
|
<komento> > "reports/<suite>/results.txt" 2>&1
|
||||||
mkdir -p "reports/${GITHUB_SHA:0:8}/<suite>"
|
|
||||||
set +e
|
|
||||||
docker run --rm \
|
|
||||||
-v ws-<suite>:/data \
|
|
||||||
--entrypoint bash ${{ inputs.<image-name> }} \
|
|
||||||
-c 'cd /data && <komento>' \
|
|
||||||
> "reports/${GITHUB_SHA:0:8}/<suite>/results.txt" 2>&1
|
|
||||||
EXIT=$?
|
|
||||||
docker volume rm ws-<suite> > /dev/null 2>&1
|
|
||||||
echo "EXIT=${EXIT}" >> "${GITHUB_ENV}"
|
|
||||||
exit ${EXIT}
|
|
||||||
|
|
||||||
- name: Publish <suite> reports
|
- name: Post-process reports
|
||||||
if: always()
|
|
||||||
run: bash .ci/scripts/publish-git-pages.sh <suite>
|
|
||||||
|
|
||||||
- name: Report status
|
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
if [ "${EXIT}" = "0" ]; then
|
<mahdollinen_raporttien_jälkikäsittely>
|
||||||
bash .ci/scripts/report-status.sh success "<kuvaus>" <context> <suite>
|
|
||||||
else
|
- name: Report
|
||||||
bash .ci/scripts/report-status.sh failure "<kuvaus>" <context> <suite>
|
if: always()
|
||||||
fi
|
run: bash .ci/scripts/ci-report.sh "<kuvaus>" <context> <suite>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Malli:** `example-bats-tests.yml` (tapa B).
|
Jos testi tuottaa raportteja suoraan ilman jälkikäsittelyä, Post-process-steppiä ei tarvita.
|
||||||
|
Jos jälkikäsittely on tarpeen (coverage-extraktio, HTML-generointi raa'asta outputista),
|
||||||
|
se tehdään omassa stepissä `if: always()` — katso tarkemmin [Raporttitasot](#5-raporttitasot).
|
||||||
|
|
||||||
|
**Mallit:**
|
||||||
|
- `example-cucumber-tests.yml` — ei post-processia
|
||||||
|
- `example-bats-tests.yml` — post-process coverage + report
|
||||||
|
|
||||||
## 5. Raporttitasot
|
## 5. Raporttitasot
|
||||||
|
|
||||||
Testi tuottaa raportin `reports/${GITHUB_SHA:0:8}/<suite>/`-hakemistoon. `publish-git-pages.sh` julkaisee sen,
|
Testi tuottaa raportin `reports/<suite>/`-hakemistoon. Yksi `ci-report.sh`-kutsu hoitaa sekä
|
||||||
`report-status.sh` linkittää commit-statusin siihen. Molemmat `if: always()`.
|
julkaisun että commit-statuksen — erillistä Publish + Report Status -kaksivaiheisuutta ei tarvita.
|
||||||
|
|
||||||
### Taso 1: Pelkkä teksti
|
### Taso 1: Ei jälkikäsittelyä
|
||||||
|
|
||||||
Kun testi tuottaa vain stdout/stderr — tallennetaan `results.txt`:
|
Kun testi tuottaa raportit suoraan (kuten `pytest --html` tai `cucumber-js --format html`):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
mkdir -p "reports/${GITHUB_SHA:0:8}/<suite>"
|
mkdir -p "reports/<suite>"
|
||||||
<testikomento> > "reports/${GITHUB_SHA:0:8}/<suite>/results.txt" 2>&1
|
<testikomento>
|
||||||
EXIT=$?
|
|
||||||
echo "EXIT=${EXIT}" >> "${GITHUB_ENV}"
|
|
||||||
exit ${EXIT}
|
|
||||||
|
|
||||||
- name: Publish reports
|
- name: Report
|
||||||
if: always()
|
if: always()
|
||||||
shell: bash
|
run: bash .ci/scripts/ci-report.sh "<kuvaus>" <context> <suite>
|
||||||
run: bash .ci/scripts/publish-git-pages.sh <suite>
|
```
|
||||||
|
|
||||||
- name: Report status
|
### Taso 2: Jälkikäsittely tarvitaan
|
||||||
if: always()
|
|
||||||
|
Kun testi tuottaa raakadataa (stdout, coverage-tiedostot) joka pitää muuntaa tai siirtää
|
||||||
|
`reports/<suite>/`-hakemistoon, käytetään Post-process-steppiä:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Run tests
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ "${EXIT}" = "0" ]; then
|
mkdir -p "reports/<suite>"
|
||||||
bash .ci/scripts/report-status.sh success "<kuvaus>" <context> <suite>
|
<testikomento> > "reports/<suite>/results.txt" 2>&1
|
||||||
else
|
|
||||||
bash .ci/scripts/report-status.sh failure "<kuvaus>" <context> <suite>
|
- name: Post-process reports
|
||||||
fi
|
if: always()
|
||||||
|
run: |
|
||||||
|
<coverage-extraktio>
|
||||||
|
<HTML-generointi raa'asta outputista>
|
||||||
|
|
||||||
|
- name: Report
|
||||||
|
if: always()
|
||||||
|
run: bash .ci/scripts/ci-report.sh "<kuvaus>" <context> <suite>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Taso 2: HTML-raportti
|
**Malli:** `example-bats-tests.yml`.
|
||||||
|
|
||||||
Kun testi tuottaa strukturoitua dataa (JUnit XML, coverage, tms.) — generoidaan HTML ja `index.html`:
|
### Monta raportoitavaa tiedostoa
|
||||||
|
|
||||||
|
Kun `reports/<suite>/`-hakemistossa on useita tiedostoja tai alihakemistoja,
|
||||||
|
`ci-report.sh` generoi automaattisesti `reports/<suite>/index.html` jos hakemistossa
|
||||||
|
on enemmän kuin yksi raportoitava item.
|
||||||
|
|
||||||
```
|
```
|
||||||
reports/<sha8>/<suite>/
|
reports/<suite>/
|
||||||
├── index.html ← generoitu: linkit alla oleviin
|
|
||||||
├── results.txt ← testin stdout
|
├── results.txt ← testin stdout
|
||||||
├── junit.xml ← testin JUnit XML -output
|
├── junit.xml ← testin JUnit XML -output
|
||||||
└── junit.html ← generoitu HTML (xsltproc, tms.)
|
└── junit.html ← generoitu HTML (xsltproc, tms.)
|
||||||
```
|
```
|
||||||
|
|
||||||
`index.html` linkittää kaikkiin raporttitiedostoihin. Selain avaa sen ja navigoi sieltä
|
|
||||||
yksittäisiin raportteihin.
|
|
||||||
|
|
||||||
## 6. Nimeäminen
|
## 6. Nimeäminen
|
||||||
|
|
||||||
Tiedostonimet `.gitea/workflows/`-kansiossa noudattavat yhtenäistä rakennetta, jotta
|
Tiedostonimet `.gitea/workflows/`-kansiossa noudattavat yhtenäistä rakennetta, jotta
|
||||||
@@ -457,8 +432,9 @@ Gitean Settings → Branches → Add Rule:
|
|||||||
|
|
||||||
| Skripti | Käyttötarkoitus |
|
| Skripti | Käyttötarkoitus |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `report-status.sh` | POSTaa commit-statuksen linkillä |
|
| `ci-report.sh` | Yhdistetty raportointi: julkaisee git-pagesiin ja asettaa commit-statuksen. Korvaa erilliset `publish-git-pages.sh` + `report-status.sh` -kutsut. Käyttö: `bash .ci/scripts/ci-report.sh "<kuvaus>" <context> <suite>` |
|
||||||
| `publish-git-pages.sh` | Julkaisee raporttihakemiston git-pagesiin |
|
| `report-status.sh` | POSTaa commit-statuksen linkillä (kutsutaan `ci-report.sh`:n sisältä) |
|
||||||
|
| `publish-git-pages.sh` | Julkaisee raporttihakemiston git-pagesiin (kutsutaan `ci-report.sh`:n sisältä) |
|
||||||
| `ci-validate.sh` | Validoi `.conf`-tiedoston (kutsutaan `config-provider.yml`:stä) |
|
| `ci-validate.sh` | Validoi `.conf`-tiedoston (kutsutaan `config-provider.yml`:stä) |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -499,7 +475,7 @@ Ei pipeä (`|`) komennon perässä — se syö exit-koodin. Käytä redirectiä
|
|||||||
|
|
||||||
### Commit-status vain raporttilinkille (ADR 0007)
|
### Commit-status vain raporttilinkille (ADR 0007)
|
||||||
|
|
||||||
`report-status.sh`-skriptiä käytetään VAIN kun on raportti linkitettäväksi.
|
`ci-report.sh`-skriptiä käytetään VAIN kun on raportti linkitettäväksi.
|
||||||
Tool-jobit (build, deploy) luottavat Gitean natiiviin job-statukseen.
|
Tool-jobit (build, deploy) luottavat Gitean natiiviin job-statukseen.
|
||||||
|
|
||||||
### Providerin checkout ei kuulu consumerille
|
### Providerin checkout ei kuulu consumerille
|
||||||
|
|||||||
Reference in New Issue
Block a user