Files
gitea-ci-library/docs/tickets/0003-push-reports-sh.md
T
moilanik 9a59cbc185
CI — gitea-ci-library / feature (push) Failing after 1s
CI — gitea-ci-library / master (push) Has been skipped
tiketit ja featuret vaihe 1
2026-06-08 09:34:47 +03:00

105 lines
3.0 KiB
Markdown

# Ticket 0003: `push-reports.sh`
**Vaihe:** 3/12
**Status:** pending
**Feature branch:** `feature/0003-push-reports-sh`
**TDD required:** Yes
**Feature file required:** Yes
**Required context:**
- `docs/test-plan/tdd-guide.md`
- `tests/features/0003-push-reports.feature`
- Skills: `tdd`, `implementation`, `clean-code`, `bash-script`
---
## TDD — Red-Green-Refactor
### Red
Kirjoita `tests/push-reports.bats` mock-MinIO:a vasten:
- `mc cp --recursive` kopioi oikeaan polkuun
- URL-tulostus: `{MINIO_BASE}/{repo}/{commit_short}/{report_type}/index.html`
- Raporttityypit: `cucumber`, `jacoco`, `junit`, `site`
- `index_title`-parametri välittyy oikein
- Lähdehakemistoa ei ole → exit 1
```bash
bats tests/push-reports.bats
# FAIL
```
### Green
`scripts/push-reports.sh` — mc cp + URL-tulostus + indeksipäivitys (`report-service/generate-index.sh`).
```bash
bats tests/push-reports.bats
# PASS
```
### Refactor
Poista duplikaatio, varmista mc-alias-konfigurointi.
## DoD
- [ ] Cucumber: `@ticket-0003 and @mock` → kaikki skenaariot GREEN
- [ ] `tests/push-reports.bats` — kaikki testit läpi
- [ ] Raportit kopioituvat oikeaan MinIO-polkuun
- [ ] URL-tulostus deterministinen
- [ ] Indeksisivut päivittyvät (`report-service/generate-index.sh`)
---
## Toiminto
Puskaa testiraporttihakemiston MinIO:hon ja päivittää indeksisivut. Palauttaa URL:n, joka syötetään `report-status.sh`:lle commit-statusviestin `url`-kenttään.
## Rajapinta
```bash
push-reports.sh <report_type> <source_dir> [index_title]
```
| Parametri | Pakollinen | Kuvaus |
|-----------|------------|--------|
| `report_type` | Kyllä | `cucumber`, `jacoco`, `junit`, `site` |
| `source_dir` | Kyllä | Paikallinen hakemisto |
| `index_title` | Ei | Näkyvä nimi indeksisivulla |
## Toiminta
1. `mc cp --recursive {source_dir} minio/reports/{repo}/{commit_short}/{report_type}/`
2. Päivitä `/reports/{repo}/{commit_short}/index.html` — lisää linkki tähän raporttiin
3. Päivitä `/reports/{repo}/index.html` — varmista että build on listalla
4. Tulosta URL: `{MINIO_BASE_URL}/{repo}/{commit_short}/{report_type}/index.html`
## URL-rakenne
```
{MINIO_BASE}/{repo_slug}/{commit_short}/{report_type}/index.html
```
## Ympäristömuuttujat
- `MINIO_BASE_URL` — Org variable
- `MINIO_ACCESS_KEY` — Org secret (alias: `mc`)
- `MINIO_SECRET_KEY` — Org secret (alias: `mc`)
- `GITHUB_REPOSITORY` — Automaattinen
- `GITHUB_SHA` — Automaattinen (8 merkkiä)
## Verifiointi
```bash
bash scripts/push-reports.sh cucumber target/cucumber-report "Cucumber Reports"
# → https://reports.example.com/temperature-store/abc12345/cucumber/overview-features.html
```
Tarkista:
- MinIO-bucketissa raportit oikeassa polussa
- `/reports/temperature-store/abc12345/index.html` sisältää linkin
- `/reports/temperature-store/index.html` sisältää buildin
## Viitteet
- `docs/shared-scripts.md` — Rajapinnan määrittely
- `docs/report-hosting.md` — MinIO-konfiguraatio ja URL-rakenne
- `docs/design-rationale.md` — Periaate 5: Raportit ovat selailtavia URL:n takana