# Ticket 0006: Pipeline as conf **Vaihe:** 6/12 **Status:** pending **Feature branch:** `feature/0006-pipeline-as-conf` **TDD required:** Yes **Feature file required:** Yes **Required context:** - `docs/test-plan/tdd-guide.md` - `tests/features/0006-ci-feature.feature` - Skills: `tdd`, `implementation`, `clean-code` **Pre-requisite (estotiketti):** - Pipeline-as-conf -suunnitelma (`docs/tickets/0006-plan.md` tai vastaava) on valmis ja hyväksytty. Toteutusta ei aloiteta ennen kuin `ci-flow-values.yaml`-skeema ja `ci-feature.yml`-jobirakenne on suunniteltu. --- ## TDD — Red-Green-Refactor + Dogfood ### Red Ennen workflow'ta, kirjoita validointitestit (`tests/workflows.bats`): - YAML-skeema: kaikki vaaditut `inputs` määritelty - `concurrency`-ryhmä estää rinnakkaiset ajot - `uses:`-viittaukset oikeisiin skripteihin ```bash bats tests/workflows.bats # FAIL: workflow-tiedostoa ei ole ``` ### Green Toteuta `.gitea/workflows/ci-feature.yml`. ```bash bats tests/workflows.bats # PASS: YAML validi, skeema täsmää ``` ### Dogfood Lisää kutsu `.gitea/workflows/ci.yml`:stä: ```yaml feature: if: github.ref != 'refs/heads/master' uses: ./.gitea/workflows/ci-feature.yml ``` Jokainen push feature-branchiin ajaa `ci-feature.yml`:n. ## DoD - [ ] Cucumber: `@ticket-0006 and @mock` → kaikki skenaariot GREEN - [ ] `tests/workflows.bats` — YAML-validointi läpi - [ ] 4 jobia: `start` → `unit-test` → `code-coverage` → `end` - [ ] `concurrency` estää rinnakkaiset ajot samalle branchille - [ ] Dogfood: kirjaston oma CI käyttää tätä workflow'ta - [ ] Jokainen job postaa oman commit-statuksen `report-status.sh`:lla (eri `context`-avain per job) - [ ] Branch protection: `ci/unit-test` ja `ci/code-coverage` näkyvät erillisinä checkeinä --- ## Toiminto Feature-branchin CI-workflow. Kutsuu vain `report-status.sh`:ta (Ticket 0001). Ei raporttien julkaisua MinIO:hon. **Huom:** Raporttien julkaisu (`push-reports.sh`) lisätään erillisessä tiketissä (0013). ## Trigger `workflow_call` (reusable workflow) ## Inputs | Parametri | Pakollinen | Kuvaus | |-----------|------------|--------| | `config-file` | Kyllä | Polku `ci-flow-values.yaml`:aan | | `maven-image` | Ei | Maven-kontti (esim. `maven:3.9-eclipse-temurin-21`) | | `node-image` | Ei | Node-kontti (npm-projektit) | ## Steppit (4 jobia, jokainen oma check) ``` start → unit-test → code-coverage → end ``` | Job | `context` | Toiminto | |-----|-----------|----------| | `start` | `ci/start` | `report-status.sh pending "Build started"` | | `unit-test` | `ci/unit-test` | Projektin oma testiajo → `report-status.sh success/failure` | | `code-coverage` | `ci/code-coverage` | JaCoCo / vastaava → `report-status.sh success/failure` | | `end` | `ci/end` | `report-status.sh success/failure` (kokonaistulos) | ## Concurrency ```yaml concurrency: group: feature-${{ github.ref }} cancel-in-progress: false ``` ## Verifiointi Simuloi paikallisesti (act-runner tai manuaalinen steppien ajo): 1. `report-status.sh pending` → commitin status = pending (`ci/start`) 2. Testit ajetaan → `ci/unit-test` = success/failure 3. Coverage ajetaan → `ci/code-coverage` = success/failure 4. `report-status.sh success/failure` → `ci/end` = lopullinen status ## Viitteet - `docs/workflows.md` — `ci-feature.yml` — Feature-branch - `docs/architecture.md` — Järjestelmäkaavio